Euler Angles

Written by Paul Bourke
June 2000


Rotations about each axis are often used to transform between different coordinate systems, for example, to direct the virtual camera in a flight simulator. These angles often go by different names, in the discussion here I will use a right hand coordinate system (y "forward", x to the right, and z upwards). As such rotation about the z axis will be referred to as direction, rotation about the y axis is roll (sometimes called bank), and rotation about the x axis is pitch. Further, a rotation will be considered positive if it is clockwise when looking down the axis towards the origin. Other conventions will be left as an exercise for the reader.

The three rotation matrices are given below, note that they seem asymmetric with respect to the sign of the sin() term.

Rotation by tx about the x axis

x'
y'
z'
 = 
1 0 0
0 cos(tx) sin(tx)
0 -sin(tx) cos(tx)
x
y
z

Rotation by ty about the y axis

x'
y'
z'
 = 
cos(ty) 0 -sin(ty)
0 1 0
sin(ty) 0 cos(ty)
x
y
z

Rotation angle tz about the z axis

x'
y'
z'
 = 
cos(tz) sin(tz) 0
-sin(tz) cos(tz) 0
0 0 1
x
y
z

A characteristic of applying these transformations is that the order is important. If the rotation matrices above are called Rx(t), Ry(t), and Rz(t) respectively then applying the rotations in the order Rz(t) Rx(t) Ry(t) will in general result in a different result to another order, say Rx(t) Ry(t) Rz(t). In what follows a particular order will be discussed and the other combinations will be left up to the reader to derive based on the same approach. The particular order of rotations applied here is to rotate about the y axis first (roll), they the x axis (pitch), then the z axis (direction). This is perhaps the most common order is usage in games and flight simulators.

x'
y'
z'
= Rz(t) Rx(t) Ry(t)
x
y
z

The single (combined) matrix is

cos(tz) cos(ty) + sin(tz) sin(tx) sin(ty)    sin(tz) cos(tx)    -cos(tz) sin(ty) + sin(tz) sin(tx) cos(ty)
-sin(tz) cos(ty) + cos(tz) sin(tx) sin(ty)    cos (tz) cos(tx)    sin(tz) sin(ty) + cos(tz) sin(tx) cos(ty)
cos(tx) sin(ty)    -sin(tx)    cos(tx) cos(ty)

One other requirement is given a new coordinate system how does one derive the corresponding three Euler angles. If the orthonormal vectors of the new coordinate system are X,Y,Z then the transformation matrix from (1,0,0), (0,1,0), (0,0,1) to the new coordinate system is

Xx Yx Zx
Xy Yy Zy
Xz Yz Zz

Matching the elements of the two matrices above firstly gives
Yz = -sin(tx)

so
tx = asin(-Yz)

Also

cos(tx) (-sin(ty), cos((ty)) = (Xz, Zz)

so
ty = atan2(Xz, Zz))

And lastly

cos(tx) (sin(tz, cos(tz)) = (Yx, Yy)

so
tz = atan2(Yx, Yy)

Note: