相关疑难解决方法(0)

Tait-Bryan 角度的四元数

我正在用 SharpDX 编写一个相机,并在四元数的帮助下旋转它。

  • 相机旋转通过俯仰(X 旋转)、偏航(Y 旋转)和滚动(Z 旋转)进行设置,即所谓的“Tiat-Bryan”角度(这些不是具有XYX 旋转的欧拉角,也不是 XYZ)。
  • 我使用左手坐标系:X+ 向右,Y+ 向上,Z+ 向下。
  • 如果我围绕 X 旋转(“俯仰”),正值会使相机向下看。如果我绕 Y 旋转(“偏航”),正值会使相机向左看。如果我绕 Z 轴旋转(“滚动”),相机会顺时针滚动。

我已经能够从四元数 s 获得俯仰、偏航和滚转。以下 C# 代码:

public static class QuaternionExtensions
{        
    public static Vector3 GetPitchYawRoll(this Quaternion q)
    {
        return new Vector3(q.GetPitch(), q.GetYaw(), q.GetRoll());
    }

    public static float GetPitch(this Quaternion q)
    {
        return q.GetK().GetPitch();
    }

    public static float GetYaw(this Quaternion q)
    {
        return q.GetK().GetYaw();
    }

    public static float GetRoll(this Quaternion q)
    {
        // This is M12 * M22 of rotation …
Run Code Online (Sandbox Code Playgroud)

camera rotation quaternions sharpdx

5
推荐指数
1
解决办法
3862
查看次数

标签 统计

camera ×1

quaternions ×1

rotation ×1

sharpdx ×1