变桨偏航累积opengl

时间:2019-01-25 09:59:54

标签: c++ opengl camera rotation trigonometry

我正在尝试为可视化相机实现超过360度的偏航角,例如在Maya,Blender,Unreal Engine,Unity等中。所有此应用程序都可以在gui中显示大于360度的角度,并且没有任何角度万向节锁定问题。

当前的psevdo代码;

Quaternion rotation; //relative (local rotation)
Quaternion parentRotation;
    //it is psevdo code where we calculate delta angle that user generate on current frame by mouse
void SetDeltaWorldRotationFromUserInput(Quaternion value)
{
    SetWorldRotation(value);
}

void SetWorldRotation(Quaternion value)
{
    SetLocalRotation(parentQuaternion.inverted() * value); //get/set local rotation
}

void SetLocalRotation(Quaternion value)
{
    rotation = value; //this we save new local rotation but i want to save somehow more then 360 degree 
    auto eulersForGui = value.toEulers(); //it is current eulers but i want to accumulate and show in gui accumulate rotation. like currentRotation + delta or somehow

    auto deltaEulers = (value * rotation.inverted()).toEulers(); //i can get delta eulers but i can't add it to euelers and don't know what i need to do with this value

}

1 个答案:

答案 0 :(得分:0)

我在评论部分留下了指向您问题的链接。但是,作为对您的问题的快速解答,我认为该网页上的这句话应该为您指明正确的方向:

  

“旋转序列可以用一系列四元数相乘来表示,产生一个生成的四元数,该四元数对组合后的旋转进行编码。”

上面的引用可以指多个四元数,每个四元数围绕一个不同的轴旋转以获得3D组合旋转,或者围绕同一轴的多个旋转累积到单个旋转的360度以上。

相关问题