Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • This does not yield correct values for a lot of different inputs, but especially inputs where the euler axis of the quaternion is non-zero for all x, y, and z. For example, we expect that an input of Quaternion.Euler(12, 34, 56) would give us 34 from your yRotation() implementation, but instead it gives 27.6. This makes it unsuitable if the reason for this implementation is to isolate monoaxial rotations from input noise. Commented Oct 8 at 23:05
  • I think in order to properly decompose per-axis component(s) out of any 3D rotation, you need to account for the rotation order with which your engine constructs rotation/transform matrices. (Word on the street is, Unity composes rotations in ZYX order, although Unity's docs say it uses ZXY. I guess I can't be certain which it is unless I write some code to test it myself...) I briefly tried to derive a formula for this, but I tapped out and returned to using Unity's built-in Euler decomposition. Non-trivial! Commented Oct 15 at 18:40
  • @LyrePyre Thanks! Tested it myself and found the same not-working result. :-/ Marked the question as incorrect. The question minorlogic linked to in the comments below the question (and now linked in this answer as well) might be the answer you want. Commented Oct 17 at 15:42