0
votes

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

}
1
As your question title suggests, accumulation the angles, not the quaternion - you can re-calculate the quaternion when the angles are updated.meowgoesthedog
I rotate object around pivot and then recalculate it position relate it parent by invert paren quaternion after that i loose my original angle and in any case eulers can't be simplest added to last eulersIgor Shumakov
Don't understand what you mean; why do you need to re-calculate the angles if you can just store them? Use the accumulated angles to calculate the local quaternion and multiply it with the parent quaternion to obtain the global transformation.meowgoesthedog
I don't know how accumulate eulers. I know that i can't simplest add yaw to yaw. Can you explain it somehow. Thanks for answer anywayIgor Shumakov
You can accumulate the angles directly based on mouse movements - that's how every game / CAD software does it, but you cannot combine Euler angle transformations by adding them; these are two different concepts.meowgoesthedog

1 Answers

0
votes

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.