Rotations and unit quaternions
The rotations of space are the unit quaternions taken up to sign, a cover with no continuous section; the exponential and its Jacobians turn rates into rotations; and of the two global charts, the stereographic chart tells the two quaternions of a rotation apart, while the Cayley chart cannot and so is a chart of the rotations themselves.
The rotations of space, , are a curved manifold of dimension three, and every way of writing one down has a defect: a matrix has nine numbers and six constraints, three angles lose a degree of freedom at some attitude, and a unit quaternion names each rotation twice. This note takes the unit quaternions, which multiply and renormalize cheaply, and works out what the two names cost. It gives the rotations their retractions, the maps a computation needs of them, and the ways in and out through angles, directions and matrices.
Quaternions and rotations#
A quaternion is with and , a vector of . Here and below a tuple of vectors is the column vector with its entries stacked. The product is
the conjugate is , and we write and . The unit quaternions are a group under , with identity and inverse . Each is a rotation,
where is the skew matrix with . It is the rotation by the angle about the unit axis when , and it acts on a vector as . The map is a homomorphism, onto, and two to one: , and no other quaternion gives the same rotation.
So the rotations are the unit quaternions up to sign. The group of two elements acts on by , freely, and is its quotient, with the quotient map. Everything in that note applies: a map written on quaternions is a map of rotations when it is unchanged by the sign of each quaternion it reads, and a map into the rotations when the sign of its result is all that the signs of its arguments change. The composition , the inverse , the relative rotation that carries the frame of to that of , and the action on a vector are all of these kinds, since .
Tangent coordinates of a rotation are, throughout, a rotation vector in the frame of the point: a retraction of this note satisfies
a perturbation on the right, in the body’s own axes. Since for a unit , the same perturbation written on the left, in the outer frame, is .
No continuous choice of quaternion#
One might hope to pick one quaternion for each rotation, once and for all, and so be rid of the sign. It cannot be done continuously.
There is no continuous map with .
Suppose is one. Its image is compact, and so is , since is continuous. They are disjoint, since gives and then , which no unit quaternion is. And they cover , since a with is or . So is the union of two disjoint nonempty closed sets, which contradicts its connectedness.
∎Every formula that reads a quaternion off a rotation is therefore discontinuous somewhere. The usual reading of a quaternion off a rotation matrix is a choice between four,
with the index of the largest of the four entries . At , with , (2) gives , so the result is : the quaternion over whose -th coordinate is positive. Since and the largest of the is at least , the chosen vector has norm at least and the division is safe. Within each choice of the map is smooth, and where the choice changes the result may change sign, as Proposition 4 says it must somewhere.
The exponential and the logarithm#
The exponential takes a rotation vector to the rotation about it by its length:
It is a diffeomorphism of the open ball of radius onto . It is how a rate becomes a rotation: an attitude turning at the constant body rate for a time moves from to , exactly. Its inverse on is the logarithm,
a rotation vector of length . The logarithm is a map of the unit quaternions and not of the rotations: for a rotation by about it gives at and at , two names of one rotation. The rotation’s own logarithm is the rotation vector of the shorter turn,
with and length in . It is discontinuous at the half-turns, , where it jumps from to : two rotation vectors of one rotation, equally short.
The left and right Jacobians of the exponential are the matrices with to first order in . They are
and their inverses, for ,
Each is a polynomial in , so the inverses are checked by multiplying out with , and , since is skew. The coefficients , and , like in (6) and in (7), are smooth functions whose closed forms divide by a quantity that vanishes at the identity. How such a coefficient is computed is the subject of a later note.
The exponential gives a retraction, , the exponential chart. It is the chart most often written down, and it is not global: it is invertible only on the ball of radius , and as a chart of the rotations only on the ball of radius , with the half-turns on its boundary. A random tangent vector with unbounded support pushed through it lands outside the chart with positive probability. The next two sections give the two charts that are defined, and invertible, on all of .
The stereographic chart#
The first is the stereographic projection of the sphere from the point opposite the centre:
For and , with , let
Then is a diffeomorphism of onto , whose inverse is ; is the rotation by the angle about ; and , so that is, to first order, the rotation vector of the perturbation in the frame of .
Write . Its norm is , so is a unit quaternion. With and , is the rotation by about with and , so . As runs over , runs over , so runs over every unit quaternion but , once each; is the inverse of the stereographic projection of from onto the hyperplane , at . Left multiplication by carries to . The inverse follows from and , which cancels from. Last, , and (2) at it is ; is a homomorphism.
∎The chart’s coordinate of a rotation by has the length . These are the modified Rodrigues parameters of attitude estimation, scaled by so that they agree with the rotation vector to first order. The chart is the left translation of the chart at the identity, , and since depends on only through its direction and its length, which preserves,
exactly, not only to first order: the chart written with its perturbation on the left is the same chart, its coordinates rotated by .
It is a chart of , and so it must tell from , which are different points of . Where it puts the two is the whole of what the sign costs.
Let with , and let in the stereographic chart. Then
and exactly when . Of the two points over one rotation, the one on the side of has the coordinate of length , with the angle between the rotations and , and the other the coordinate of length in the opposite direction. The two lengths multiply to .
Write , so that and, since ,
which is below exactly when . Both and are , whose coordinate is , and
For the lengths, the point on the side of is at the angle from by Proposition 12, which is the angle between the rotations, and the other at , whose coordinate has the length .
∎So the map from one sign to the other is the inversion in the sphere of radius , followed by negation. The ball of radius is the chart of the near sides, one point for each rotation within less than a half-turn of , and its complement holds the far sides. A rotation close to , given by the quaternion on the far side, has a coordinate of length , which grows without bound as the rotations approach each other: read in this chart, a rotation given with the other sign is as far from as a point can be, exactly when it is nearest.
The sign is not only a matter of single points. A turn of about an axis is the identity rotation and the quaternion : rotations about one axis by with compose to the identity, while their quaternions, each taken with , multiply to . Angles add modulo on and modulo on the rotations. A chain of relative rotations that closes on itself as rotations may therefore fail to close as quaternions, and quaternions fitted to it link by link must take up the missing turn somewhere along the chain.
The Cayley chart#
A chart of the rotations must not tell from . The second global chart is the familiar first-order update of a quaternion, normalized.
For and , let
Then , and is unchanged when either or is negated. The map is a diffeomorphism of onto the rotations by less than from , with inverse for either over ; is the rotation by about ; ; and .
The norm of is , so , with and ; it is the rotation by about with , so , every such rotation once. Negating negates . Negating or negates , whose and change sign together, so their ratio does not. For , and ; and every rotation by less than from is for a with , which is of . The first-order form and the last identity follow as for the stereographic chart: , and depends on only through its direction and its length.
∎The retraction commutes with the sign and its inverse is unchanged by the sign of either argument, which are the conditions of Proposition 1. So this is a retraction on itself, with its inverse, computed through whichever quaternions the two rotations happen to be given by. On matrices it is the Cayley transform, . Its coordinate of a rotation by has the length
a little farther from the angle than the stereographic chart’s. A rotation has one coordinate at , of length for its angle from , whatever the signs. Nothing in the chart reads which quaternion a rotation was given by, so the missing turn of the last section cannot arise: a chain of relative rotations that closes as rotations is fitted with nothing left over.
What the chart misses, at each , is the rotations a half-turn from : not one point, as the stereographic chart misses , but a surface, the rotations by about every axis, composed with . There and the inverse is undefined, and near it the coordinate is large. The two charts thus put their cuts in different places. The stereographic chart is finite at every half-turn, with a coordinate of length , and is cut at the antipode, the point a mistaken sign lands on. The Cayley chart is cut at the half-turns, which a pair of rotations reaches only by differing as much as two rotations can.
Agreement with the exponential#
Three retractions are now in hand, and a derivative read in tangent charts does not depend on which is used.
In the stereographic chart and in the Cayley chart alike, , and so at every . Hence the derivative in charts of a smooth map between rotations and Euclidean spaces is its Jacobian in exponential coordinates on the right, , and the second derivatives of the map at the centres of the charts are those in exponential coordinates too. In particular the derivative of at is the right Jacobian , and that of at is .
From with , the stereographic chart has . From , the Cayley chart has the same expansion, and so has , from and . All three charts are left translations of their charts at the identity, so they agree at every point to second order, and so do their inverses. The derivative in charts of a map at is the Jacobian at of , and the local representatives of in two charts that agree to second order agree to second order at , with their first and second derivatives there. Last, is the chart coordinate at of , which is ; and is the inverse of .
∎So the Jacobians of the textbooks, derived in exponential coordinates, are the derivatives in either global chart, and a formula that carries an uncertainty through a rate by hand writes into it. The charts differ at third order, in how far a finite step goes, and in where they are cut.
Interpolation and distance#
The geodesic from to , at the parameter , is
which runs at a constant rate along the great circle of through and , reaching at by the arc that avoids . With in place of it is the rotations’ interpolation, along the shorter of the two turns from one attitude to the other, and discontinuous where the relative rotation is a half-turn and the two turns are equally short. The two agree whenever .
The angle between two rotations, the length of the shorter turn from one to the other, is
It is the same at and , and smooth where : at it is a norm, with no derivative, and at a maximum, where turns. Its square is smooth at , and is what a cost on an attitude’s error is written with.
Angles and directions#
Rotations are given and reported as an axis and an angle, as a pair of directions, and as Euler angles. Each is a way in and out, and none is a chart.
Axis and angle. The rotation by about an axis is , smooth in both. The way back is the rotation vector split into its length and its direction, and the direction is undefined at the identity. A computation that differentiates through an axis and an angle is better served by the rotation vector, which has no such point.
From two directions. The rotation of least angle carrying the direction of to that of is the normalization of
since for unit vectors at the angle about the axis this is . It is smooth for except where is opposite to : there the vector vanishes, every half-turn about an axis perpendicular to is a rotation of least angle, and the map is undefined.
Euler angles. A sequence of axes with is proper when and of Tait–Bryan type when the three are distinct, six sequences of each. With the rotation by about the coordinate axis , the rotation by the angles about the three axes, each about the axis as the previous rotations left it (intrinsic), is
smooth in the angles, and the rotation about the fixed axes in the same order (extrinsic) is , the intrinsic rotation of the reversed sequence. Roll, pitch and yaw in the usual aerospace convention are the intrinsic angles . The way back has one form for every sequence.
Let be axes with , let be the axis other than and , and let with . Write .
Proper angles, . If with , then, with and ,
So for the angles are recovered, modulo , from any positive multiple of or of as , and , where and .
Tait–Bryan angles, . If with , then has the proper angles about , and is a positive multiple of , listed as the coordinates .
With and , and , , the product (1) gives , and its product with has
which are the stated forms by the addition formulas. For both and are positive, so and for scaled by , and the s return , and and modulo ; for they return and modulo , which change and by multiples of . For the second claim, let . Since turns about to , , and so , with . Last, is , and .
∎So the Euler angles of a unit quaternion are, for a proper sequence, those of Proposition 21 read off , and for a Tait–Bryan sequence those read off the linear rearrangement of it gives, with lowered by and multiplied by ; for an extrinsic sequence, those of the reversed sequence, in reverse order. They are the same at and at , and so are angles of the rotation. The rotation is smooth in its angles everywhere. The angles are not smooth in the rotation everywhere, and no choice of formula makes them so.
Fix a sequence of axes , and call a rotation at the lock when its is or for a proper sequence, for a Tait–Bryan one.
- Away from the lock, and are smooth maps of the rotation into the circle , but neither is represented by a continuous real-valued map on any set of rotations containing the loop , , for the loop in its own angle, with off the lock.
- At a rotation at the lock, neither nor has a limit, even in the circle. For a proper sequence, has one at and at ; for a Tait–Bryan sequence, has one at and at , with as in the proposition on the Euler angles of a unit quaternion.
For the first claim, let be continuous and real-valued, equal to modulo on the loop. Off the lock the angles are unique modulo by Proposition 21, so the loop’s rotation at has modulo , and is continuous with values in , hence constant. So is larger by at than at , but the loop closes there, since and . The same holds of on its loop. For the second, take a proper sequence. As , tends to for every , and for its angles are and modulo ; so the rotations near take every and every , while on all of them. At the same holds of , which tends to for every , since , a half-turn about reversing ; there . A Tait–Bryan sequence’s angles are, by Proposition 21, the proper angles of , a diffeomorphism of the rotations, and its lock is theirs.
∎The way back therefore has two kinds of singularity.
The wrap. Away from the lock, and are smooth as points of the circle, and a formula returns them as real numbers in . By Proposition 22 a real-valued angle must be cut somewhere, and this convention cuts it where it is : crossing there, it jumps by . The jump is in the value alone. jumps across its half-line , , but its derivatives, , and all of their own, are continuous across it, so the angles’ derivatives of every order are the same on either side of the wrap. What a jump in value breaks is a difference of values. A difference between an angle and an angle it is compared with is taken on the circle,
which moves the cut to a difference of , as far as an angle can be from the one it is compared with, and has the derivatives of everywhere else.
The lock. At gimbal lock one of the two norms of Proposition 21 vanishes, and only or is determined: no convention makes the angles continuous there. Off the lock the angles are smooth, but not uniformly. is the angle of the vector of length , and that of of length , so the first derivatives of and grow like as and as , and their second derivatives like the squares. The same factor amplifies a rounding of ’s coordinates into and near the lock, while , read off the larger norm, stays accurate. Euler angles are a way into and out of a computation; the uncertainty of a rotation is put in a chart.
Built on by
- Rotations and rigid motions The crate skoro-spatial declares the rotations, the rigid motions and the extended poses as embedded types stored as quaternions up to sign, with the Cayley chart, global on each group, and declared volumes, so that they carry the normal in whatever sign their quaternions are given, and writes their maps as composites whose derivatives are the core's.
- Rigid motions The rigid motions and the extended poses are semidirect products of the rotations with translations; their chart translates the identity's on the left, so that its translation coordinates are in the frame of the point, and their exponential couples translation to rotation through the left Jacobian.
- Removable singularities in floating point The coefficients of the rotations' and the rigid motions' maps are smooth at the identity, but their closed forms divide by a power of the angle there; each is computed by a series below a cutoff and its closed form above, and the cutoff is set by how the error of a sine and a cosine, relative or absolute, is amplified by that division.
- Densities in tangent charts A retraction's chart at a point carries the manifold's reference measure to a density on the tangent space, the chart's volume; with it, a random tangent vector pushed through the chart has a density on the manifold, given here for the charts of the rotations, the poses and the sphere.