现在的位置: 首页 > 综合 > 正文

Interactive Computer Graphics :3.10.4 Rotation About an Arbitrary Axis 绕任意轴旋转

2018年05月27日 ⁄ 综合 ⁄ 共 943字 ⁄ 字号 评论关闭

先将物体平移到原点,再绕X轴旋转到Y=0的平面,再绕Y轴旋转到与Z轴重合。最后再平移回去。

M = T(p0)Rx(−θx)Ry(−θy)Rz(θ)Ry(θy)Rx(θx)T(−p0)

P0是物体中心。θ是绕轴旋转角度

d = αy * αy+ αz * αz .

设归一化的旋转轴是αx αy αz 

Rx(θx) =

1 0 0 0
0 αz/d −αy/d 0
0 αy/d αz/d 0
0 0 0 1

Ry(θy) =
d 0 −αx 0
0 1 0 0
αx 0 d 0
0 0 0 1

书上接下来一段公式有些错误,这里更正一下。

3.11.3 Rotation About a Fixed Point
In Section 3.10, we showed that we can perform a rotation about a fixed point, other
than the origin, by first moving the fixed point to the origin, then rotating about
the origin, and finally moving the fixed point back to its original location. Using the
example from Section 3.11, the following sequence sets the matrix mode, then forms
the required matrix for a 45-degree rotation about the line through the origin and
the point (1, 2, 3) with a fixed point of (4, 5, 6):
mat4 R, ctm;
float thetax, thetay;
const float Radians_To_Degrees = 180.0/M_PI;
thetax = Radians_To_Degrees*acos(3.0/sqrt(13.0));
thetay = Radians_To_Degrees*acos(sqrt(13.0/14.0));
R = RotateX(-thetax)*RotateY(-thetay)*RotateZ(45.0)*RotateY(thetay)*RotateX(thetax);
ctm = Translate(4.0, 5.0, 6.0)*R* Translate(-4.0, -5.0, -6.0);

抱歉!评论已关闭.