Page 7-2: Euler Angles Toy

# Page 7-2: Euler Angles Toy

## Box 1: Euler Angles

We use the term "Euler Angles" to refer to the representation of a 3D rotation as a sequence of 3 rotations about fixed axes. For example, we can represent a rotation in 3D as a sequence of 3 rotations: one about the X axis, one about the Y axis, and one about the Z axis. The important point is these axes are fixed: we decide them ahead of time. I have chosen X, Y then Z. Once I've chosen them, I need to stick with these 3 axes in this order.

This representation comes from a theorem that mathematician Leonhard Euler had: any rotation in 3D can be represented as a sequence of rotations about fixed axes. The theorem is very general: any set of axes can work (providing no two consecutive axes are parallel).

Once we choose a convention (a set of axes and their order), we only need 3 numbers to represent an arbitrary 3D rotation: the amount of rotation around each axis.

A thing that makes Euler Angles tricky is that the different rotations interact. The first rotation changes the coordinate system (frame) that the next rotation takes place in, so we need to interpret each of the angles with respect to the others. If only one of the axes is non-zero, things are easy.

In class, we showed a bunch of complicated situations that come up :

1. In some circumstances, you can get into a configuration where there are only two possible directions to rotate (you can cause a particular change to happen). This is called gimbal lock. For XYZ Euler angles this occurs when the rotation about the Y axis is 90 degrees, causing the X axis to align with the Z axis (and perform the same motion).
2. Different sets of angles may represent the same rotation. That means that interpolating between two close things might lead to weird paths, or that comparing sets of angles is hard.
3. In general, it can be hard to know what changes to the different rotations will do.

To demonstrate these things in class, I built an interactive toy. I've included it at the bottom of this page. While you are welcome to read the code, I don't recommend it. You should play with the toy to see how Euler angles work.

In the view, you'll see three objects. For the ones on the left and right, there is a choice drop down to let you choose the axes and their order. Then you can use the sliders to adjust the angles and see what happens. There are buttons that put things into gimbal lock, and another one that creates two rotations that are the same rotations, but with very different parameters - interpolation between the two yields a crazy path. The center object will interpolate between the left and right (but only if they are using the same axes and order).

I recommend that you spend some time playing with the Euler Angle toy (below) to build up your intuitions about how Euler Angles work, and the problems they have.

Then you can move on to the next page to consider some alternatives.