Why does rotating via viewport give different values than inspector rotations?
For some reason I am not understanding how/why rotating items via the viewport handles (such as a character's knee bone) works differently than entering a text value for the rotation into the inspector.
Like why do the values keep rotating to multiples of 360 and when do they reset to 0-360? i.e. why does the inspector show -1440 sometimes instead of 0?
Also see these screen shots to see what I mean about viewport vs inpector rotations? I would expect them to work the same like in other 3D apps such as LW where the text fields match exactly whether you enter a value or click and drag.
And in my examples another weird thing that the Unity IDE does, is that it changes the Y & Z values even when I have ONLY clicked on the locked X axis handle to constrain rotation via the viewport. Hopefully these screenshots show you what I am confused about. Any help is appreciated :)
(this is Unity 3.3 windows btw)
Answer by loopyllama · Mar 25, 2011 at 04:40 AM
You are viewing the rotation through euler angles, or an x y z in degrees. Internally the rotation is represented through quaternions which is 4 floats (these 4 floats are not simply angles or degrees). To answer your question a 0 degree rotation is the same thing as a 360 or -360 degree rotation...meaning your model is at the same angle, at that frame. You will see equivalent values "flicker" like this is the viewport because you are viewing the internal quaternion converted to an euler angle. Rest assured knowing there is nothing broken about this and it is normal. Quaternion's solve the problem of gimbal lock which plagues euler angles.
Thanks, I appreciate your response, and I understand that 0,-360 and other multiples are the same thing - but I'm assu$$anonymous$$g it would be nice to have the viewport report consistent values. For example, why does undo report -360 when it was 0 a second ago? And isn't gimbal lock just dealt with by using Local vs World coordinates?
Also, can you address why if I want to constrain rotation to the X axis, why other Y & Z values change when using the viewport, but (correctly so) not via just entering a value in the X textbox? To me that is highly strange...?
Regarding display of Euler angles, although it's possible to display Euler angles in 'canonical' form and get more consistent results, it's not that important overall, I$$anonymous$$O. Aliasing is an inherent characteristic of Euler angles, and is just something that has to be expected when working with them. As for gimbal lock, quaternions don't really 'solve' the problem of gimbal lock, per se. Whether gimbal lock is a possibility is more a function of how your orientations are stored and manipulated. (That's a little brief, but I'm out of characters :)
Thanks for your clarification, and I'm sorry I'm being dense here. I think it's less of me debating Quaternions vs Euler and more contesting how the Unity Inspector IDE works unexpectedly (at least for me in comparison to Lightwave layout).
For example see the 2nd image above - why does the Y & Z change to -180 when all I did was rotate the X axis in the viewport?? is this an equivalent angle or something? Can't the IDE tell I only wanted to rotate X alone? Does my confusion make sense? Hope I don't run you out of characters again ;-)
when you type in a rotation into the inspector you are entering an euler angle that gets converted to a quaternion internally. when you rotate in the viewport you are seeing the value change in the inspector that is a quaternion converted to an euler angle, which can and will "flicker" depending on the direction and amount of rotation.
and for clarity, quaternions are indeed free of gimbal lock. here is more info about gimbal lock with pretty pictures: http://en.wikipedia.org/wiki/Gimbal_lock#The_quaternion_solution
Answer by jeffreylmeyer · Dec 05, 2016 at 02:12 AM
So how do we calculate the same values the inspector shows? For example if I have Inspector values of: Transform.rotation.x = 160 , .y =-30, .z=0 how do I get those values in C#?
The engine should provide that in a simple manner... I'm guessing somehow they convert 0 to 360 into -1 to +1 ??? and what is the point?
Your answer
Follow this Question
Related Questions
How do I see what Reference properties and Value properties I can address in GetComponent in C#? 0 Answers
Inspactor Roation to Vector3 0 Answers
Project turns "read only" after a while 0 Answers
automatic levelling out airplane when near the ground? 0 Answers
Very basic rotation BUG. transform.up = transform.up sets Y rotation to 0. 1 Answer