和二维点同理,我们把三维点表示成四维 Homogeneous Coordinates
xyz→wxwywzw=xyz1 Translation
100001000010txtytz1xyz1=x+txy+tyz+tz1 Scaling
sx0000sy0000sz00001xyz1=xsxysyzsz1 Rotation
我们默认是右手系,即默认逆时针旋转.
-
绕 x-axis 旋转:10000cosθsinθ00−sinθcosθ00001
-
绕 y-axis 旋转:cosθ0−sinθ00100sinθ0cosθ00001
-
绕 z-axis 旋转:cosθsinθ00−sinθcosθ0000100001
多个 Translation/Rotation/Scaling/Reflection 可以合成一个 Affine 矩阵. (并且这些 Basic Operations 也都是 Affine Transformations). 其 Matrix Form 是
x′y′z′1=adg0beh0cfp0mnl1xyz1
在 VRML 里,Transformation 定义为数据结构:
1 2 3 4 5 6
| Transform { translate dx, dy, dz; rotation ax, ay, az, theta; scale sz, sy, sz; children [...]; }
|
生效顺序为 scale→rotation→translation