简体   繁体   中英

Pitch Yaw Roll accumulation opengl

I'm trying to implement yaw pitch roll for visualisation camera yaw pitch roll more then 360 degree like in Maya, Blender, Unreal Engine, Unity etc. All this application can show angles in gui more then 360 degree and no have any Gimbal lock problems.

current psevdo code;

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

}

I had left a link in the comment section to your question. However as a quick answer to your problem I think this quote from that webpage should point you in the right direction:

"A sequence of rotations can be represented by a series of quaternions multiplied together, producing a single resulting quaternion that encodes the combined rotations."

The quote above can refer to either multiple quaternions each rotating around a different axis to get the combined rotation in 3D, or multiple rotations about the same axis that would accumulate to a single rotation that is more than 360 degrees.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM