Once you enter into the amazing 3-Dimensional space you notice that there are several concepts to use if you want to apply transformations over your 3D models. We are talking about rotations, translations and scaling. We can rotate a in the 3D space using: Euler angles, rotation Matrices and quaternions.

**EULER ANGLES**

The rotation method most widely used is the one that uses the rotational descriptors yaw, roll and pitch. A 3D body can be rotated about three orthogonal axes, and depending on the axis the rotation is carried out, each one of these rotational descriptors is used, according the following picture.

However, the use of these rotations bring problems. One of this problems is that the operations’ order is important to the final result. Another important issue we coped some time ago is the well known “gimbal lock”. This effect drives to the loss of one degree of freedom (DOF) in a three-dimensional space that occurs when the axes of two of the three gimbals are driven into a parallel configuration, locking the system into rotation in a degenerate two-dimensional space.

**ROTATION MATRIX**

Another way to implement a rotation is by using the Rotation Matrix, which is a Matrix of 3×3 size containing the information about the rotations in the three axis. The main problem with encoding rotations in a 3×3 matrix is the inevitable numericaldrift encountered by using the finite precision arithmetic within a computer. A 3×3 rotation matrix is orthogonal, and it’s 9 components encode the 3 degrees of freedom of the rotation. As computations on the matrix are performed, the components of the matrix naturally drift, violating the orthogonal constraint. This means that the matrix is no longer a valid rotation matrix and abnormalities in the transform will start to appear. These abnormalities are manifested as visual distortions and artefacts within the rendered object on screen.

**QUATERNIONS**

Encoding rotations with a quaternion can solve many of the problems mentioned above. Since quaternions have 4 degrees of freedom (DOF) there is only 1 redundant constraint, which is far easier to enforce than matrix orthogonality.

A quaternion represents two things: the axis about which the rotation occurs – which is represented by a x,y and z component- and the amount of rotation which will occur about the previous axis. This amount of rotation is represented by w. With these four values, it is possible to build a matrix which will contain all the rotations perfectly, with no chance of gimbal lock problem.

The use of the quaternions has advantages over the two aforementioned methods, which are detailed in the following list:

- - Quaternions avoid the gimbal lock problem.
- - Modify a rotation is easier with quaternions.
- - Quaternions also avoid the drifting problem of the rotation matrices.
- - Quaternions allow smoother interpolations in rotations.

Do not forget to check out our AR Browser and Image Matching SDKs.

Tags: 3D, quaternions
## Recent Comments