Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions

Lecture



Euler angles are angles that describe the rotation of an absolutely rigid body in three-dimensional Euclidean space. They were introduced by Leonhard Euler.

Compared with Euler angles, quaternions make it possible to combine rotations and to avoid the problem of being unable to rotate about an axis independently of rotations already performed about the other axes (see Quaternions and rotation of space).

Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions

Euler angles.

Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions

Animation of a sphere being rotated in turn through the Euler angles

Euler angles are angles that describe the rotation of an absolutely rigid body in three-dimensional Euclidean space. They consist of three components (ψ, θ, φ), each of which is an angle of rotation about some axis.

Leonhard Euler described rotation the way it is shown in the picture below:

Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions

Z-X-Z intrinsic angles (classical)

Euler angles define three rotations of a system that bring it from any position into the current one. Let us denote the initial coordinate system as Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions and the final one as Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions. The intersection of the coordinate planes Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions and Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions is called the line of nodes Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions.

  • The angle Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions between the axis Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions and the line of nodes is the angle of precession.
  • The angle Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions between the axes Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions and Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions is the angle of nutation.
  • The angle Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions between the line of nodes and the axis Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions is the angle of intrinsic rotation.

Rotating the system through these angles is called precession, nutation, and rotation through the intrinsic angle (spin). Such rotations are non-commutative, and the final position of the system depends on the order in which the rotations are performed. In the case of Euler angles, a series of three rotations is performed:

  1. By the angle Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions about the axis Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions. This carries the axis Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions into Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions.
  2. By the angle Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions about the axis Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions. This carries the axis Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions into Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions.
  3. By the angle Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions about the axis Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions. This carries the axis Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions into Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions.

This sequence is sometimes called 3,1,3 (or Z,X,Z), but such notation can lead to ambiguity.

Formulas

Euler angles describe a sequential combination of passive rotations about the axes of the rotating coordinate system. The matrices of these rotations have the form

Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions

Performing these rotations in sequence gives the matrix

Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions

The product Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions, where Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions are the coordinates of the point before rotation, gives the coordinates of the point in the moving coordinate system after rotation. Before and after the rotation, the coordinates of the point in the fixed coordinate system remain unchanged.

Tait–Bryan angles

As you can see, Euler described rotation about two axes using three components. First a rotation about the first axis, then about the second, and finally a rotation about the first axis again. In his mind he pictured something like a spinning top.

What we actually use in game engines today is an extension, an alternative form of Euler angles devised by Peter Tait and George Bryan for aviation. They describe rotation about three different axes (better known as yaw->pitch->roll) as three components. Visually this looks like those familiar rotating nested rings that science-fiction authors love to use when they need to show a spaceship engine or an ancient alien artifact.

Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions

Generally speaking, rotations can be intrinsic/moving (Intrinsic) or extrinsic/static (Extrinsic).

Moreover, they are further divided into two groups:

  1. Proper Euler angles: z-x-z, x-y-x, y-z-y, z-y-z, x-z-x, y-x-y

  2. Tait–Bryan angles (or yaw, pitch, roll): x-y-z, y-z-x, z-x-y, x-z-y, z-y-x, y-x-z

So there are 12 possible variants in total.

As already mentioned, game engines use

Yaw -> Pitch -> Roll. Formally speaking, this is Z-X-Y Intrinsic.

This is the most convenient variant for most tasks (not only for aircraft):

  • Z — yaw. Convenient for a compass/map, since you can always tell which way something is heading/flying/crawling. Free of gimbal lock.

  • X — pitch. An aircraft usually doesn't fly straight up or down. In games, the angle at which a player's camera can be tilted is also usually limited to between -89 and +89 degrees. Which means there's no gimbal lock here either.

  • Y — roll. Aircraft aren't allowed to roll too heavily. And a player's camera usually has zero roll anyway.

Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions

Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions

The upshot: zero problems with gimbal lock in typical tasks!

Performance:

  • Cost of converting Tait–Bryan angles to a matrix: 3 sincos, 15 multiplications, 4 additions.

  • Cost of converting a matrix to Tait–Bryan angles: 2 atan2, 1 asin.

Quaternion

A quaternion is a system of hypercomplex numbers that forms a four-dimensional vector space over the field of real numbers.

Nothing clear yet?

One more time: a quaternion is a system of hypercomplex numbers that forms a four-dimensional vector space over the field of real numbers.

Let's break it down piece by piece:

1. Hypercomplex numbers are elements of algebraic structures constructed by generalizing the notion of number beyond complex numbers. You could say these are finite-dimensional algebras over the field of real numbers (that is, numbers on which there is a pair of operations resembling addition and multiplication).

1.1. Complex numbers — numbers of the form z = a + bi,

where a,b are real numbers,

i is the imaginary unit (that is, a number such that i2 = -1)

2. A four-dimensional vector space over the field of real numbers — that's Vec4.

So how did imaginary units come about in the first place?

Long ago there was the problem of solving a cubic equation: x3 + px + q = 0

If you tweak it a little, you get the following: x3 = -px - q or x3 = kx + b (on the left — a cubic parabola, on the right — a straight line).

Graphically, the solution reduces to finding the intersection of the graph of the cubic parabola and the line. Visually it's clear that any line intersects a cubic parabola in 1, 2, or 3 points. In other words, a solution always exists.

And in the 16th century a wonderful formula — Cardano's formula — was invented for this:

Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions

Oops. Something doesn't add up. You can't take the square root of -121. But a solution does exist. So what do we do?

In 1572 Rafael Bombelli proposed pretending that the square root of a negative number is some kind of number. We, of course, know that no such numbers exist, but let's imagine anyway that it does exist and that, like ordinary numbers, it can be added to other numbers, multiplied, raised to a power, and so on. This is how imaginary numbers came about.

But… how does this work? How can you even picture the square root of a negative number?

And what exactly is a «negative number» anyway?

Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions

How can you take 4 cows away from 3? How can you have less than nothing? As late as the 18th century, negative numbers were still considered nonsense that ought to be gotten rid of.

Even though it's a theoretical number, it has useful properties. It can be used to describe all sorts of relationships (a debt, for example: -20 owed, 50 earned. Result: -20 + 50 = 30 rubles in your pocket).

Plus and minus signs automatically fix a direction — you don't need a whole sentence to describe the change after each transaction. The same is true of imaginary numbers. They are «normal» to exactly the same extent as any other numbers. If -1, 1/3, and 0 «exist», then let's imagine that some number i also exists, where i2 = -1.

In other words, multiplying i by itself gives us -1: i*i = -1. Strange new ideas can turn out to be extremely useful.

A visual understanding of negative and imaginary numbers

What does the equation x2 = 9 mean?

1 * x2 = 9 or 1 * x * x = 9

What can we substitute for x? 3 and -3. In other words, «3 times 3, or 3 times -3 and flip the result».

Now let's think about x2 = -1:

1 * x * x = -1

What can we substitute here? Neither a positive nor a negative number fits… But what if… we rotate? Sounds crazy, but what if we imagine x as a «90-degree rotation», then applying x twice we perform a rotation of 180 degrees on the coordinate axis, and 1 flips into -1!

Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions

Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions

Understanding complex numbers

So it turns out i2 = -1 has a right to exist. It then follows that any number z can be represented as a pair of numbers z = a + bi, where a,b are real numbers and i is the imaginary unit. The number a is called the real part of the number z, and a,b is the imaginary part.

The pair of numbers a,b is usually represented as a radius vector on the complex plane, which forms a triangle in which the angle between the vector and the axis of abscissas is called the argument, and the hypotenuse is the distance of the number from zero.

Applying ordinary algebra, we get an interesting effect:

  1. Addition and subtraction work analogously to addition and subtraction of vectors — we simply shift the point on the plane.

  2. When multiplying complex numbers by each other (taking into account the properties of the imaginary unit), our point starts to rotate around the origin and scale.

Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions

Imagine we're on a boat, moving on a heading of 3 units East for every 4 units North. We want to change our heading by 45 degrees counterclockwise. What will the new heading be?

  1. z1 = 3 + 4i

  2. z2 = 1 + i

Multiplying: z1*z2 = (3 + 4i)(1 + i) = 3 + 3i + 4i + 4i2 = 3 + 7i + 4(-1) = -1 + 7i

Our new heading: 1 unit West and 7 units North. And all without any sines or cosines! Literally in a couple of seconds!

You could say that complex numbers unite algebra, geometry, and trigonometry into a single whole.

So what is a quaternion, after all?

So, a quaternion is an expression of this form:

q = xi + yj + zk + w,

where x,y,z,w are real, and i,j,k are imaginary numbers that have the following properties:

i2 = j2 = k2 = ijk = -1

and, accordingly:

ij=k jk=i ki=j

ji=-k kj=-i ik=-j

If you look closely, this is very similar to the cross product:

x×y=z y×z=x z×x=y

y×x=−z z×y=−x x×z=−y

And that's no coincidence: quaternions were invented by William Hamilton in 1843. Three years later he also invented the dot and cross product. Originally for those same quaternions — as the vector and scalar parts of the product of two quaternions whose scalar part is equal to zero. «Vector» and «scalar» are terms that also arrived together with quaternions.

Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions

Henri Poincaré wrote about quaternions: «Their appearance gave a powerful impetus to the development of algebra; starting from them, science moved along the path of generalizing the concept of number, arriving at the concepts of matrix and linear operator that permeate modern mathematics. It was a revolution in arithmetic similar to the one Lobachevsky made in geometry».

Quaternions were originally invented to solve spatial problems in mathematical physics. We use them to rotate bodies in 3D.

Where and why do we use quaternions?

  1. To represent rotation. Instead of 9 numbers for a mat3, you can use just 4! Saves memory and speeds up reading/writing.

  2. Creating a quaternion from an axis-angle representation is very fast.

  3. Rotating quaternions (multiplying them) is more numerically stable compared with rotating via matrices.

  4. No gimbal lock, unlike with Euler angles.

Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions

  1. In skeletal animation, for skinning. There's also a thing called a dual quaternion. It lets you correctly bend arms and legs (vertices) along their longitudinal axes.

Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions

Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions

  1. Animation. You can make a smooth rotation between two quaternions using spherical interpolation. With Euler angles, correct interpolation (along the shortest path) is only possible about a single axis.

Euler Angles (Nutation, Precession, Rotation) and Tait–Bryan Angles (Yaw, Pitch, Roll), Quaternions

So does that mean xyz is the axis, and w is the angle?

No! (x, y, z, w) is simply a point on the surface of a hypersphere (3-sphere). More precisely, a 3-hemisphere.

Let's start with 2D

Suppose we want to use a complex number purely for rotations. We have some angle φ, and we need to convert it into a complex number, multiply it by others, and then get the result back as an angle. Or, for example, we want to rotate a bunch of radius vectors by an angle φ. Quickly.

What do we need to do so that multiplying two complex numbers gives only a rotation, without scaling? Clever people determined that: «When complex numbers are multiplied, their moduli are multiplied and their arguments are added».

That means the modulus of z must be equal to 1. Graphically — it must be a point on the surface of a circle. So, in order to rotate a point in 2D (or to add the angles φ1 + φ2), the multiplier must be defined as z = cosφ + isinφ!

Notice that neither the real part nor the imaginary part alone forms either a vector or an angle. They work as a pair. They are projections, shadows of the vector on the axes. To keep the angle the same while changing one number, you have to change the other proportionally.

And on top of that, we have a starting point, a zero angle: 1 + 0i.

Moving on to 3D

Here things are a bit more complicated. Imagine four axes perpendicular to one another, one of which is the axis of real numbers. xyzw is a point on the surface of a hypersphere at a constant distance of 1 from the center, and the angle of rotation is the projection of xyz from the imaginary axes onto the axis of real numbers.

So a quaternion can be assembled like this (via axis-angle):

q = cos(φ/2) + u sin(φ/2), where u is a unit vector from (x,y,z)

If the modulus of (x,y,z,w) is not equal to 1, then along with the rotation we will also start scaling points/vectors, moving them along a spiral. So NEVER change the w component separately from xyz!

First, you'll be scaling, and second, the angle of rotation will depend on the current values of (x,y,z).

Why φ/2? Because the rotation of an arbitrary vector v is done via qvq-1. This is related to the fact that v is (x,y,z), while q is (x,y,z,w). After qv, the rotated v stops being purely «imaginary» and acquires a scalar part. It's necessary to multiply by q-1, in order to return the rotated v to its «imaginary» part.

See also

  • [[b12464]]
  • Rotation matrix
  • Six degrees of freedom
  • Gimbal frame folding

See also

created: 2024-03-20
updated: 2026-03-10
232



Was this answer useful?
Choose a quick rating so we can improve the next answer for you.
How satisfied are you?


Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Linear Algebra and Analytical Geometry"

Terms: Linear Algebra and Analytical Geometry