Determining yaw, pitch, and roll from a rotation matrix

In 3-D graphics, we get to choose:

  • world and model coordinate systems: Y-up versus Z-up
  • image coordinates: (0,0) in the lower left versus the upper left
  • rotation signs, polygon windings, and 3-D coordinate axes: left-handed/clockwise versus right-handed/counter-clockwise
  • angular units: radians versus degrees
  • light direction: toward the source versus away from the source
  • vectors: as row matrices versus column matrices
  • 4-D component orderings: x-y-z-w versus w-x-y-z
  • matrix serialization: row-major versus column-major
  • transform matrices: pre-multiplied versus post-multiplied
  • indices: zero-origin versus 1,2,3
  • multi-axis rotation order and spherical coordinates: so many choices!

None of these is very complicated. Issues arise when people become accustomed to particular conventions, assume thereā€™s only one correct way, and donā€™t document their choices.

For the record, here are some conventions JMonkeyEngine generally follows:

  • Y-up/Z-forward world coordinates
  • Y-up/Z-forward model coordinates
  • Viewport coordinates have (0,0) in the lower left.
  • 2-D texture images have (0,0) in the upper left unless ā€œflippedā€ (but ā€œflippedā€ is the default!)
  • Positive rotations are right-handed/counter-clockwise.
  • Triangle windings are right-handed/counter-clockwise.
  • 3-D coordinate axes are right-handed.
  • Angles are measured in radians (with notable exceptions).
  • The direction of a light points away from the source.
  • Vectors multiply like column matrices.
  • Quaternions and 4-D vectors serialize in x-y-z-w order.
  • Matrices serialize in row-major order (with notable exceptions).
  • Transform matrices are pre-multiplied.
  • When converting between 3-D coordinate systems, the order of application is: scale, then rotate, then translate.
  • Indices are zero-origin (with notable exceptions).
  • Multi-axis rotations follow Tait-Bryan conventions, in x-z-y intrinsic order (equivalent to y-zā€™-xā€™ā€™ extrinsic).
  • Spherical coordinates are (distance, longitude, latitude).

Please correct me if I got any of these wrong!
Such things ought to be documented in our Wiki, but I canā€™t find them.

7 Likes