Euler angles

From CGAFaq

Jump to: navigation, search

Any 3D rotation about the origin can be composed as a series of three rotations around coordinate axes, with the three angles described collectively as Euler angles. This is the usage in computer graphics, which applies the term to any one of 24 different axis conventions; some other literature restricts the term to one specific convention.

Euler angles are one of several common representations for 3D rotations, a way of denoting a unique rotation with numbers. Other common representations include quaternions, axis-angle, angular velocity, and rotation matrices. Any representation requires at least three numbers, though four are required to avoid certain technical problems. Euler angles use minimal space, but are somewhat expensive to convert to and from matrices. Composing two rotations in Euler angle form is prohibitively expensive. It is also difficult to decide if two triples, even in the same system, represent the same rotation. Interpolation of Euler angles can be used to animate rotation, but the results are often poor compared to other methods.

Any system of Euler angles suffers from gimbal lock, where certain values of the middle angle cause the other two to have the same effect. This singularity of the representation can cause numerical and behavioral difficulties.

Contents

Derivation

A rotation transforms one orthonormal basis to another, leaving the origin fixed. Suppose x, y, z are the three mutually perpendicular unit-length vectors of the initial basis, and that a, b, c give the rotated basis. A rotation around the x axis can pivot the c vector into the xz plane, zeroing the y component. Then a rotation around the y axis can further pivot c in the xz plane to become z, zeroing the x component. Now a and b, being perpendicular to c, must lie in the xy plane, and a rotation around the z axis can pivot b to become y, zeroing its x component. This simultaneously forces a to become x.

Let R represent the target rotation, and let rot(xx), rot(yy), rot(zz) be the three axis rotations aligning a, b, c with x, y, z as described. Denoting composition by juxtaposition, we have

rot(zz) rot(yy) rot(xx) R = I.

The inverse of rotation by θ is rotation by −θ, thus

R = rot(x,−θx) rot(y,−θy) rot(z,−θz).

Compositions read from right to left, so this is an Euler angle system with fixed (static) axis rotations ordered zyx, angles (−θz, −θy, −θx).

Adding a multiple of 360° to any angle will not change the composite rotation; this is one source of duplication. Another can be seen in the x-axis rotation, which could just as well have been 180°−θx.

For a static-axis xyz system, pivot a around z into the xz plane, then around y to become x; finish by pivoting b around x to become y, simultaneously bringing c to z.

24 systems

As Andrew S. Tannenbaum wrote, “The nice thing about standards is that there are so many to choose from.” In fact, within computer graphics alone many Euler angle conventions are used, so it is necessary to know all the possibilities.

Twelve of the 24 conventions are variations of the examples given. The second axis must be different from either of the other two, but there are no other constraints. Specifically, the last axis can be the same as the first. Thus the static-axis systems are

xyzs, xyxs, xzys, xzxs, yzxs, yzys, yxzs, yxys, zxys, zxzs, zyxs, zyzs

The other twelve conventions use rotating, or body-aligned, axes rather than static axes, but are otherwise the same. This merely reverses the composition order, and thus reverses the order in which the angles are listed.

Conversions

The matrix for an axis-aligned rotation depends on a few conventions. Assume the matrix is used to rotate column vectors in a right-handed orthonormal coordinate system, where a positive rotation around x pivots y to z. Then the three matrices are

To get the matrix for, say, the xyzs rotation with angles (θx, θy, θz), multiply these together as specified. With cx =cos θx, sx =sin θx, and so on, the result is

Similarly, the xyxs rotation with angles (θx, θy, θx′) is

For these conventions, as for any, the conversion from angles to matrix is a matter of coding the trigonometry and arithmetic shown. Conversion from matrix to angles requires numerical care. More details on both can be found in Euler angles from matrix.

QR decomposition

The procedure used to derive Euler angles for 3D rotations is a special case of the numerical linear algebra technique known as QR decomposition using Givens plane rotations. A planar rotation in the subspace spanned by basis vectors ei and ej can pivot those components of an n-dimensional vector v = (v1,…,vi,…,vj,…,vn) so as to force the vj component to be zero. A series of such rotations can force all but one component of v, say v1, to be zero. Further rotations that do not disturb that component (that is, in planes perpendicular to it) can force zeros into other vectors.

For a rotated orthonormal basis in n-dimensional space, n(n−1)/2 such axis-aligned planar rotations will suffice to reach the standard basis. Thus 2D rotations, for example, can be represented with only one angle, while 4D rotations require six of these generalized “Euler angles”. Only in 3D does an axis select a plane, so in 4D and above we require another naming scheme. Using pairs of indices to name a planar subspace, the 3D system xyzs is ⟨2&3,1&3,1&2⟩, and one 4D system is ⟨3&4,2&4,1&4,2&3,1&3,1&2⟩.

Personal tools