【问题标题】:Dot product function does not yield the angle of rotation点积函数不产生旋转角度
【发布时间】: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


    【解决方案1】:

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

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

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

    由于您是围绕原点旋转,因此只有垂直于旋转轴的点的分量会受到旋转的影响。

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

    【讨论】:

      猜你喜欢
      • 2021-08-31
      • 1970-01-01
      • 2018-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-19
      • 2014-02-26
      相关资源
      最近更新 更多