Jump to content
  • Advertisement

Opengl accumulte delta eulers >180 from result quaternion

Recommended Posts

I'm trying to understand how maya, blender, unity etc get new eulers in widget while user rotate model in local coordinate system by gizmo in viewport.
This applications somehow save rotate in eulers but perform operation in quaternions. I can't understand how they save/convert quaternion to eulers and get eulers more than 180 degree
If i simplest convert result quaternion to eulers i can't get result like in applications above. I can't get angle more 180

Unity for example


This is my code explain my attemps to do that.

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

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

void SetLocalRotation(Quaternion value)
    rotation = value; // we save new local rotation but i want to save somehow more then 180 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
eulersRotation += deltaEulers; //it is similar wrong. I don't know how to do it correctly


Edited by DAddill

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!