Euler And Matrix - achilles288/robot-kinematics GitHub Wiki
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.
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.
Finding
Starting with , it is found that
Finding
For ,
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 , the sign affected by is removed as follow.
Finding
With similar approach in previous step, at and ,
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 , the above equations don't work and another approach is to be observed.
If ,
Substituting in and applying angle sum and difference trigonometric identity,
In Gimbal Lock, both yaw and roll are rotating at the same axis and one of them can be any value. Here, is taken zero.
If ,
Similar approach to previous case with ,