点积函数不产生旋转角度

Dot product function does not yield the angle of rotation

在玩四元数时,我注意到我无法使用该向量与其原始位置之间的点积找到该向量的旋转角度。在我的示例中,我将一个向量绕任意轴旋转了 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 弧度?我在这里不明白什么?

感谢您的关注。

使用点积,您测量的是初始向量与旋转向量之间的角度,这通常与应用的旋转幅度不同。

想象一下,如果您的点在旋转轴上,那么在应用旋转时该点不会移动。要对此进行测试,请将您的点设置为 (1, 1, 0)/sqrt(2),并且角度应为零。

然后将点设置为 (1,-1,0)/sqrt(2) 你应该得到你预期的 pi/2.

因为是绕原点旋转,所以只有垂直于旋转轴的点的分量受旋转影响。

一个很好的参考: https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula