I thought I understand Euler rotation, but I’m learning that it’s doing some things I do not, in fact, understand.
Let’s say that I want to rotate an object around its Y axis some degree amount between 0 and 360. I would think that I would do something like this:
this.entity.setLocalEulerAngles(0,135,0);
But that doesn’t actually set the object to 0, 135, 0
. It actually sets the object to 180, 45, 180
. Upon further investigation, I learned that these conversions happen on-the-fly:
• 0-90
degrees y … 0, 0–90, 0
(exact value mapping)
• 90-180
degrees y … 180, 90–0, 180
(90 assigned as 90, 180 assigned as 0)
• 180-270
degrees y … 180, 0–-90, 180
(180 assigned as 0, 270 assigned as -90)
• 270-360
degrees y … 0, -90–0, 0
(270 assigned as -90, 360 assigned as 0)
I haven’t bothered to investigate values in excess of 360.
I’m sure this is proper/correct (I’m guessing it has to do with gimbal lock), I’m just wondering what I should do to get predictable assignment (i.e. if there’s a conversion going on, I’d rather do it myself before assignment so that it assigns the exact values I specify).
Oh, also, I created a test project that shows this.