Comments and answers for "Quaternion.Euler doesn't work right?"
http://answers.unity.com/questions/1133897/quaternioneuler-doesnt-work-right.html
The latest comments and answers for the question "Quaternion.Euler doesn't work right?"Comment by DSivtsov on DSivtsov's comment
http://answers.unity.com/comments/1856891/view.html
The little correction to @streeetwalker
> *Remember that the order of Rotations
> matters. So first rotating x by 100,
> and then y by zero, and finally z by
> zero, ends up the same thing rotating
> x by 80, and then y by 180 and then z
> by 180*
**But it nothing change, He is absolute right**
[Transform.localEulerAngles][1]
...
> **In Unity these rotations are performed around the Z axis, the X axis, and the Y axis, in that order.**
[1]: http://file:///E:/Unity/2021.1.5f1/Editor/Data/Documentation/en/ScriptReference/Transform-localEulerAngles.htmlTue, 24 Aug 2021 22:35:32 GMTDSivtsovComment by Mizdotexe on Mizdotexe's answer
http://answers.unity.com/comments/1856820/view.html
Can someone explain why this works please?Tue, 24 Aug 2021 15:30:24 GMTMizdotexeComment by streeetwalker on streeetwalker's comment
http://answers.unity.com/comments/1718236/view.html
@zukahara,
if you:<br><br>
Debug.Log( Quaternion.Euler( 100f, 0, 0 ).eulerAngles );
You see printed: (80.0, 180.0, 180.0)
Those are two different representations of
exactly the same set of rotations
<br><br>Remember that the order of Rotations matters. So first rotating x by 100, and then y by zero, and finally z by zero, ends up the same thing rotating x by 80, and then y by 180 and then z by 180.<br><br>
To say that the Quaternion calculation is wrong because, "it took my 100 degrees and now it's 80 degrees" is a mistake in your thinking about it. You have forgotten to apply the rotations on the the other two axes.:<br><br>
For any given set of rotations, there may be more than one set of equivalent rotations.
Debug.Log( Quaternion.Euler( 100f, 0f, -45f ).eulerAngles );
Yields: (80.0, 180.0, 135.0)
And Debug.Log( Quaternion.Euler( 80.0f, 180.0f, 135.0f ).eulerAngles );
Yields: (80.0, 180.0, 135.0)
Go figure! Once in Quaternion form, the representation has been optimized.
:<br><br>The important thing in Unity is to trust Quaternions and deal with Euler angles as little as possible. Do not convert from Eulers to Quaterinons and back to Eulers and Back to Quaternions in order to clamp rotations, or other operations. You can drive yourself crazy!:<br><br>
Quaternions were invented by William Hamilton nearly two hundred years ago based on the mathematics of Leonhard Euler from a hundred years earlier. The are mathematical constructs that have been proven. They are perfect, as such constructs are.:<br><br>
There are no bugs in Unity's Quaternion class!Tue, 14 Apr 2020 07:26:00 GMTstreeetwalkerComment by zukahara on zukahara's answer
http://answers.unity.com/comments/1718149/view.html
It's an old post but maybe will somebody anwser :)
Im working with Rotations in unity, had the same problem and found this discussion.
Sorry, but for me does the correct answer no sense.
$$anonymous$$y thoughts:
Fakt is that:
Quaternion.Identity * Quaterion.Euler(45f, 45f, 45f) == Quaterion.Euler(45f, 45f, 45f)
Because of the property of Identity
I. e. my Initial Rotation is the Identity.
Consequently:
Quaternion DesiredRot = initialRot * Quaternion.Euler(100f, 0f, 0f);
Is equal to Quaternion.Euler(100f, 0f, 0f).
$$anonymous$$y Question is:
Why shows this
> Debug.Log(DesiredRot.eulerAngles.x);
80° ins$$anonymous$$d of 100°?
I did some tests with
Quaternion.Euler(100f, 0f, -45f);
converted Euler(100, 0, -45) to Quaternion, back to Euler and i will get (80.0, 180.0, 135.0). That's equal to an euler rotation of (-100, 0, -45)
and that isn't right.
Quaternion qTest= Quaternion.Euler(100f, 0f, -45f);
Debug.Log(qTest.eulerAngles);
I think there is a bug or I'm wrong? :)Mon, 13 Apr 2020 22:27:15 GMTzukaharaAnswer by DiegoWw
http://answers.unity.com/answers/1648035/view.html
@Glabrezu is correct. Additionally, you can "kinda" assign an Euler angle by doing:
objToRotate.transform.rotation = Quaternion.Identity * Quaternion.Euler(90f, 0, 0);Fri, 12 Jul 2019 14:50:33 GMTDiegoWwAnswer by Glabrezu
http://answers.unity.com/answers/1134436/view.html
Found an article about Quaternions.
If anyone else has this problem, you can't just assign a rotation to a Quaternion apparently. You take your initial Quaternion and then multiply it by the second one, which should contain the rotation which you want to apply to the first one.
So you should basically do it like that:
Quaternion initialRot = objToRotate.transform.rotation;
objToRotate.transform.rotation = initialRot * Quaternion.Euler(90f, 0, 0);
This example just rotates the object by 90 degrees.Wed, 27 Jan 2016 23:15:34 GMTGlabrezu