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);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值