Interactive Computer Graphics :3.10.4 Rotation About an Arbitrary Axis 繞任意軸旋轉

先將物體平移到原點,再繞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);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章