Skip to content

Euler And Matrix

khantkyawkhaung edited this page Mar 31, 2020 · 5 revisions

There are many forms to represent orientation in 3D space. Matrices, Euler angles and quaternions. In this API, most computations are done with matrices. Euler Angles is simply a set of roll, pitch and yaw. It represents 3 successive rotations in 3 axes and the order may be different. Compared with other representations, this is much easier to visualize and less difficult to learn for most people. Many 3D modeling softwares implement this representation.

Airplane model showing Euler angles

Matrices are mainly used in the back-end and Euler angles in the front-end. So, it is necessary that the conversions between these two forms is to be researched.

For the sequence of rotations, the order is taken as yaw, pitch and roll.

Rotation matrix from Euler angles

Rotation matrix from Euler angles

Finding theta

Starting with R20, it is found that

Finding theta

Finding theta

Finding psi

For cos(theta) != 0,

Finding psi

Finding psi

To compute the above equation using atan2 function, it is observed that the sign of each parameter is important for determining the quadrant. So, to obtain the correct quadrant of psi, the sign affected by cos theta is removed as follow.

Finding psi

Finding phi

With similar approach in previous step, at R00 and R10,

Finding phi

What If Gimbal Lock?

Gimbal Lock is the state where the Euler rotations loss one degree of freedom. When the second order rotation takes a 90 degree rotation, the third rotation axis becomes identical to the previous first rotation axis.

Since cos(theta) = 0, the above equations don't work and another approach is to be observed.

If theta = pi/2,

Substituting sin(theta) = 1 in R01 R02 and applying angle sum and difference trigonometric identity,

Trigonometric identity

Trigonometric identity

In Gimbal Lock, both yaw and roll are rotating at the same axis and one of them can be any value. Here, psi is taken zero.

Finding phi

If theta = -pi/2,

Similar approach to previous case with sin(theta) = -1,

Trigonometric identity

Trigonometric identity

Finding phi

#Next page: C API Documentation