- Home /
Euler to Quaternion conversion returns unexpected result at exactly 180 degree rotation on Y axis
Hi, i am having a hard time understanding some unexpected behaviour of "Quaternion.Euler(Vector3)".
I have built a component which simulates "servomotor-like" rotation to a specific angle on a given axis and it's working perfectly fine so far, however as soon as the initial local rotation of my pivot object on the Y axis equals exactly 180 degrees, the returned Quaternion looks like this:
(To minimize the margin of error, i replicated the conversion as simple as possible)
I am currently using the x-component of the Quaternion in my rotation coroutine, but obviously "-4.107527E-08" is not quite suitable for that.
When the rotation on Y or Z changes even ever so slightly, everything reverts to working as expected, while the rotation on the X axis does not seem to make a difference.
Sure i could just go with "179.9" degrees on Y, but that seems like a dirty fix.
I hope someone can point me into the right direction here. (no pun intended)
the internals (x y z w) should only be touched when you know Quaternions. always use the unity functions that manipulate them. if you want to lerp one axis, lerp the angle representation before the conversion to a Quaternion.
Your answer
Follow this Question
Related Questions
Determine degrees rotated around an arbitrary axis 0 Answers
Limiting the rotation of an object 1 Answer
Rotation losing precision 0 Answers
Trying to get the angle of a camera object based on players forward, is not distance independent 0 Answers
Rotation angles not corresponding (inspector, debugging) 0 Answers