【发布时间】:2020-10-31 14:01:21
【问题描述】:
在玩四元数时,我注意到我无法使用该向量与其原始位置之间的点积来找到向量的旋转角度。在我的示例中,我将向量围绕任意轴旋转了 90 度,但点积产生了不同的角度。
// Axis of rotation (unit vector).
Vec3 Axis = Vec3(1, 1, 0) / sqrt(1 + 1 + 0);
// Creates a quaternion that will rotate a point by 90 degrees around the (1, 1, 0) axis.
Quat q(cos(3.14 / 4), Axis * sin(3.14 / 4));
// Creates a point.
Vec3 Point = Vec3(1, 0, 0);
// Rotates the point by q.
Quat Rot = q * Quat(0, Point) * q.GetConjugate();// Rot == (0, 0.5, 0.5, -0.707)
// Getting Rot's coordinates.
Vec3 v = Vec3(Rot.x, Rot.y, Rot.z);
// Angle is equal to 1.047, but it should be 1.57 (3.14/2)...
float Angle = acos(Dot(Point, v));
请注意,每个向量和四元数的长度都是 1。
我觉得这很有趣,因为旋转 90 度的向量与其原始位置之间的最短角度是 90 度。
所以我的问题是:为什么我没有得到 1.57 弧度?我在这里不明白什么?
感谢您的关注。
【问题讨论】:
标签: rotation dot-product