From Using Quaternions for Visualisation
on June 6, 2017


To my regular readers, I apologize for the absence of a blog in recent weeks. A severe tummy bug during a conference in Seoul followed by a shocking bout of jetlag in Phoenix (Thursday in Seoul and Monday in Phoenix via a weekend in Coventry is not to be recommended) are my only excuses. However, during the trip to Phoenix I accomplished one of my lifetime goals and this is the subject of this week’s blog.


When I first joined the UK’s military flight test establishment at Boscombe Down, the Multi-Role Combat Aircraft (it had not yet been named Tornado) was coming towards the end of its initial flight trials and about to enter service. My job was to predict the consequences of a circuit failure in the terrain following radar, for which we simulated the multiplex systems and injected failures to find out how the aircraft responded. All my work was boringly “wings level”, but the experts in the performance division were busy examining the aircraft’s handling during aerobatic manoeuvres. They used Hamiltonian Quaternions to describe the motion of the aircraft, but I only needed to use the simpler Euler equations of motion. I felt somehow cheated from using this exotic-sounding mathematics.

In Euler’s equations of motion, the aircraft attitude is expressed in pitch, roll and yaw, but the arithmetic gets in a mess when pitch attitudes approach +/-90 degrees. My work with helicopter autopilots was all based on modest angles of bank, and Flight Data Monitoring for airliners is similarly restricted to relatively gentle manoeuvres, hence Euler’s equations have been good enough for all my work. Until now.


An Accident Investigation Board asked if Flight Data Services could provide an animation of the motion of an aircraft in extreme attitudes. A quick inspection of the recorded attitudes showed me that the Euler restriction on pitch attitudes was going to be broken, so now was my chance to learn about Hamilton and his mathematics.


Sir William Rowan Hamilton was an Irish mathematician. On the bridge at Broome is a plaque:




In case you can’t read it, it says:

Here as he walked by
on the 16th of October 1843
Sir William Rowan Hamilton
in a flash of genius discovered
the fundamental formula for
quaternion multiplication
i2 = j2 = k2 = ijk = −1
& cut it on a stone of this bridge.


Apparently the formula is no longer visible, but we can look at this in two steps.


Complex Numbers

Many readers will have done complex numbers at school or university. These are a combination of a normal “real” part and an “imaginary” part. The imaginary part is a proportion of the square root of minus one, with:

Image 2

If we plot positive real numbers to the right and positive complex numbers upwards, we can plot a value

Image 3

Image 4


If we multiply this value by i, we get:


Image 5

Plotting this as a red point, and adding lines to the origin for illustration purposes only, we can see this has moved anticlockwise. Trust me, if I could get Excel and Word to work nicely, the angle would be 90 degrees.


Image 6


Doing this again creates another rotation:


Image 7


Image 8


So the green point is where the blue point ends up after two rotations of 90 degrees. Each time we multiply by i, the point will be rotated anticlockwise 90 degrees on this diagram.

Into Three Dimensions

The insight that Hamilton had was that there need not be only one square root of minus one. Since we don’t know what i is, we can have multiple different values, each of which when squared is minus one, but they’re not the same. With three, we can do the trick of rotating 90 degrees at a time in each of three dimensions, without the three coming into conflict.

Hamilton spent a long time trying to develop a form of mathematics using triples, as this would be the obvious way to address rotation in three dimensions, but in fact his insight (at Broome Bridge) was that you need a fourth element. The cryptic function was written as:


Image 9

And you can think of this as a set of values i,j,k which allow you to perform the rotation trick in three dimensions. Take a sphere and rotate it through 90 deg twice in any direction moves a point on the surface to the other side of the sphere, and 90 deg rotations in each of the three different axes also has the same effect.

The actual quaternion is formed from a vector in 3-dimensional space, plus a fourth term which represents the rotation of the space around the origin.


Image 10

Where i, j, k are the roots of -1 described above and a is the angle of rotation around that vector. If you want to try to get to grips with this further, I recommend the YouTube video entitiled “Fantastic Quaternions – Numberphile”.

What Use Are They?

The computation of spatial rotations using Quaternions is very fast, as it uses matrix algebra to add and multiply rotations, and does not require trigonometric functions. It is for this reason that they are commonly used in gaming software where components have to tumble, crash and spin in all directions.

For my purpose, returning to the accident animation, they carry two important qualities. Firstly, they have no problem with rotating through -90 deg pitch. Secondly, we can interpolate rotations easily and get smooth changes in rotation through -90 deg. Both of these are important qualities that we need for animation of a tumbling aircraft.

The animation process was to take the recorded data and remove errors and identifiable nonlinearities. Points close to +/-90 deg were treated with particular care. The attitudes were then converted into their quaternion representation and quaternion interpolation used to provide smooth changes from one position to the next, moving without discontinuity, for example, through the 90 deg nose-up attitude, before converting back to Euler angles for display.





User Rating: 0.0 (0 votes)
  • Al Gom

    Dear Dave.

    Its good to know that you´re well and back again to the business.
    I have trying Polaris Shell during last week, and I have been comparing results with my old readout software and I´d like to know if is there any chance to comment you some issues that I have observed. Any chance to share your email to let you know what I found? Regards and thanks in advance.