[英]3d maths in Flash AS3
I'm trying to code a 3d wall like http://www.flashloaded.com/flashcomponents/3dwall/ 我正在尝试对3d墙进行编码,例如http://www.flashloaded.com/flashcomponents/3dwall/
The shape I am looking to create is like a bath or arena where it is a curve cornered rectangle with sloping sides. 我要创建的形状就像一个浴池或竞技场,它是一个弯曲的,带有倾斜边的矩形矩形。
The image below shows what i'm trying to achieve if viewed from above. 下图显示了从上方看时我要达到的目标。 I hope that helps.
希望对您有所帮助。
Can anyone give me some ideas on the maths to create this shape using primitive rectangle shapes. 谁能给我一些数学上的想法,以使用原始矩形形状创建此形状。
Thanks, Josh 谢谢,乔希
http://en.wikipedia.org/wiki/Matrix_multiplication http://en.wikipedia.org/wiki/Matrix_multiplication
http://en.wikipedia.org/wiki/Transformation_matrix http://en.wikipedia.org/wiki/Transformation_matrix
http://www.devmaster.net/wiki/Transformation_matrices http://www.devmaster.net/wiki/Transformation_matrices
A rectangle has 4 3D points (vectors) 矩形具有4个3D点(向量)
To move/rotate/scale just multiply each vector by the transformation matrix. 要移动/旋转/缩放,只需将每个向量乘以变换矩阵即可。
For perpective projection (camera) look at: http://en.wikipedia.org/wiki/3D_projection 有关透视投影(相机),请访问: http : //en.wikipedia.org/wiki/3D_projection
For example: you can create rectangles and rotate them around an axis to create a cylinder like this: 例如:您可以创建矩形并围绕轴旋转它们,以创建如下所示的圆柱体:
(source: flashloaded.com ) (来源: flashloaded.com )
your pit:
你的坑:
note: the angle is not correct, it should be pi-a (180º-a)注意:角度不正确,应为pi-a(180º-a)
![]()
create all rectangles centered at origin (0,0,0), then rotate them as needed and move to desired position.
创建所有以原点(0,0,0)为中心的矩形,然后根据需要旋转它们并移动到所需位置。 I recommend you to code the matrix routines first like rotate(), move(), scale() and a simple paint function (just line drawing, without perspective) the rest is just playing with the matrices.
我建议您首先对矩阵例程进行编码,例如rotate(),move(),scale()和简单的绘制函数(仅绘制线条,不使用透视图),其余的仅用于处理矩阵。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.