skoro v0.0.0

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.

Updated 2026-11-25 · 17 min read

The rotations of space, SO(3)SO(3), 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 q=(w,u)q = (w, u) with w∈Rw \in \R and u∈R3u \in \R^3, a vector of R4\R^4. Here and below a tuple of vectors is the column vector with its entries stacked. The product is

(w1,u1)⊗(w2,u2)=(w1w2−u1⋅u2, w1u2+w2u1+u1×u2),(1) (w_1, u_1) \otimes (w_2, u_2) = \bigl(w_1 w_2 - u_1 \cdot u_2,\ w_1 u_2 + w_2 u_1 + u_1 \times u_2\bigr), \tag{1}
(1)

the conjugate is qˉ=(w,−u)\bar q = (w, -u), and we write vec⁡(q)=u\operatorname{vec}(q) = u and w(q)=ww(q) = w. The unit quaternions S3={q:∣q∣=1}S^3 = \{q : \lvert q \rvert = 1\} are a group under ⊗\otimes, with identity 1=(1,0)1 = (1, 0) and inverse qˉ\bar q. Each is a rotation,

π(q)=(w2−∣u∣2) I+2 uu⊤+2w [u]×,(2) \pi(q) = (w^2 - \lvert u \rvert^2)\, I + 2\, u u\transpose + 2 w\, [u]_\times , \tag{2}
(2)

where [u]×[u]_\times is the skew matrix with [u]×x=u×x[u]_\times x = u \times x. It is the rotation by the angle θ\theta about the unit axis aa when q=(cos⁡θ2,sin⁡θ2 a)q = (\cos \tfrac\theta2, \sin \tfrac\theta2\, a), and it acts on a vector as π(q) x=x+2w (u×x)+2 u×(u×x)\pi(q)\, x = x + 2 w\, (u \times x) + 2\, u \times (u \times x). The map π:S3→SO(3)\pi : S^3 \to SO(3) is a homomorphism, onto, and two to one: π(q)=π(−q)\pi(q) = \pi(-q), and no other quaternion gives the same rotation.

So the rotations are the unit quaternions up to sign. The group of two elements {±1}\{\pm 1\} acts on S3S^3 by q↦−qq \mapsto -q, freely, and SO(3)=S3/{±1}SO(3) = S^3 / \{\pm 1\} is its quotient, with π\pi 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 q1⊗q2q_1 \otimes q_2, the inverse qˉ\bar q, the relative rotation qˉ1⊗q2\bar q_1 \otimes q_2 that carries the frame of q1q_1 to that of q2q_2, and the action on a vector are all of these kinds, since (±q1)⊗(±q2)=±(q1⊗q2)(\pm q_1) \otimes (\pm q_2) = \pm (q_1 \otimes q_2).

Tangent coordinates of a rotation are, throughout, a rotation vector in the frame of the point: a retraction of this note satisfies

π(q⊕v)=π(q)(I+[v]×)+O(∣v∣2),(3) \pi(q \oplus \tangent) = \pi(q) \bigl(I + [\tangent]_\times\bigr) + O(\lvert \tangent \rvert^2) , \tag{3}
(3)

a perturbation on the right, in the body’s own axes. Since q⊗(w,u)⊗qˉ=(w,π(q) u)q \otimes (w, u) \otimes \bar q = (w, \pi(q)\, u) for a unit qq, the same perturbation written on the left, in the outer frame, is π(q) v\pi(q)\, \tangent.

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.

Proposition 4(The rotations have no continuous choice of quaternion).

There is no continuous map s:SO(3)→S3s : SO(3) \to S^3 with π∘s=id⁡\pi \circ s = \operatorname{id}.

Proof.

Suppose ss is one. Its image s(SO(3))s(SO(3)) is compact, and so is −s(SO(3))-s(SO(3)), since q↦−qq \mapsto -q is continuous. They are disjoint, since s(R)=−s(R′)s(R) = -s(R') gives R=π(s(R))=π(−s(R′))=R′R = \pi(s(R)) = \pi(-s(R')) = R' and then s(R)=−s(R)s(R) = -s(R), which no unit quaternion is. And they cover S3S^3, since a qq with π(q)=R\pi(q) = R is s(R)s(R) or −s(R)-s(R). So S3S^3 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 XX is a choice between four,

c0(X)=(1+X11+X22+X33, X32−X23, X13−X31, X21−X12),c1(X)=(X32−X23, 1+X11−X22−X33, X12+X21, X13+X31),c2(X)=(X13−X31, X12+X21, 1−X11+X22−X33, X23+X32),c3(X)=(X21−X12, X13+X31, X23+X32, 1−X11−X22+X33),q=cm(X)∣cm(X)∣,(5) \begin{aligned} c_0(X) &= (1 + X_{11} + X_{22} + X_{33},\ X_{32} - X_{23},\ X_{13} - X_{31},\ X_{21} - X_{12}), \\ c_1(X) &= (X_{32} - X_{23},\ 1 + X_{11} - X_{22} - X_{33},\ X_{12} + X_{21},\ X_{13} + X_{31}), \\ c_2(X) &= (X_{13} - X_{31},\ X_{12} + X_{21},\ 1 - X_{11} + X_{22} - X_{33},\ X_{23} + X_{32}), \\ c_3(X) &= (X_{21} - X_{12},\ X_{13} + X_{31},\ X_{23} + X_{32},\ 1 - X_{11} - X_{22} + X_{33}), \end{aligned} \qquad q = \frac{c_m(X)}{\lvert c_m(X) \rvert}, \tag{5}
(5)

with mm the index of the largest of the four entries cm(X)mc_m(X)_m. At X=π(q)X = \pi(q), with q=(q0,q1,q2,q3)q = (q_0, q_1, q_2, q_3), (2) gives cm(X)=4qm qc_m(X) = 4 q_m\, q, so the result is sign⁡(qm) q\operatorname{sign}(q_m)\, q: the quaternion over XX whose mm-th coordinate is positive. Since cm(X)m=4qm2c_m(X)_m = 4 q_m^2 and the largest of the qm2q_m^2 is at least 14\tfrac14, the chosen vector has norm at least 22 and the division is safe. Within each choice of mm 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:

Exp⁡(ω)=(cos⁡θ2, sin⁡(θ/2)θ ω),θ=∣ω∣.(6) \Exp(\omega) = \Bigl(\cos \tfrac\theta2,\ \frac{\sin(\theta/2)}{\theta}\, \omega\Bigr), \qquad \theta = \lvert \omega \rvert . \tag{6}
(6)

It is a diffeomorphism of the open ball of radius 2π2\pi onto S3∖{−1}S^3 \setminus \{-1\}. It is how a rate becomes a rotation: an attitude turning at the constant body rate ω\omega for a time Δt\Delta t moves from qkq_k to qk+1=qk⊗Exp⁡(ω Δt)q_{k+1} = q_k \otimes \Exp(\omega\, \Delta t), exactly. Its inverse on S3∖{−1}S^3 \setminus \{-1\} is the logarithm,

Log⁡(q)=2atan2⁡(n,w)n u,n=∣u∣,(7) \Log(q) = \frac{2 \atantwo(n, w)}{n}\, u, \qquad n = \lvert u \rvert, \tag{7}
(7)

a rotation vector of length 2atan2⁡(n,w)∈[0,2π)2 \atantwo(n, w) \in [0, 2\pi). The logarithm is a map of the unit quaternions and not of the rotations: for a rotation by θ\theta about aa it gives θa\theta a at qq and (2π−θ)(−a)(2\pi - \theta)(-a) at −q-q, two names of one rotation. The rotation’s own logarithm is the rotation vector of the shorter turn,

rv⁡(q)=Log⁡(s(q) q),s(q)={1w≥0,−1w<0,(8) \rv(q) = \Log\bigl(s(q)\, q\bigr), \qquad s(q) = \begin{cases} 1 & w \ge 0, \\ -1 & w < 0, \end{cases} \tag{8}
(8)

with rv⁡(−q)=rv⁡(q)\rv(-q) = \rv(q) and length in [0,π][0, \pi]. It is discontinuous at the half-turns, w=0w = 0, where it jumps from πa\pi a to −πa-\pi a: two rotation vectors of one rotation, equally short.

The left and right Jacobians of the exponential are the matrices with Exp⁡(ω+ε)=Exp⁡(Jl(ω) ε)⊗Exp⁡(ω)=Exp⁡(ω)⊗Exp⁡(Jr(ω) ε)\Exp(\omega + \varepsilon) = \Exp(J_l(\omega)\, \varepsilon) \otimes \Exp(\omega) = \Exp(\omega) \otimes \Exp(J_r(\omega)\, \varepsilon) to first order in ε\varepsilon. They are

Jl(ω)=I+A [ω]×+B [ω]×2,Jr(ω)=Jl(−ω)=I−A [ω]×+B [ω]×2,A=1−cos⁡θθ2,B=θ−sin⁡θθ3,(9) J_l(\omega) = I + A\, [\omega]_\times + B\, [\omega]_\times^2, \quad J_r(\omega) = J_l(-\omega) = I - A\, [\omega]_\times + B\, [\omega]_\times^2, \quad A = \frac{1 - \cos \theta}{\theta^2}, \quad B = \frac{\theta - \sin \theta}{\theta^3}, \tag{9}
(9)

and their inverses, for θ<2π\theta < 2\pi,

Jl(ω)−1=I−12[ω]×+C [ω]×2,Jr(ω)−1=I+12[ω]×+C [ω]×2,C=1θ2(1−θ2cot⁡θ2).(10) J_l(\omega)^{-1} = I - \tfrac12 [\omega]_\times + C\, [\omega]_\times^2, \quad J_r(\omega)^{-1} = I + \tfrac12 [\omega]_\times + C\, [\omega]_\times^2, \quad C = \frac{1}{\theta^2}\Bigl(1 - \frac\theta2 \cot \frac\theta2\Bigr). \tag{10}
(10)

Each is a polynomial in [ω]×[\omega]_\times, so the inverses are checked by multiplying out with [ω]×3=−θ2[ω]×[\omega]_\times^3 = -\theta^2 [\omega]_\times, and Jr(ω)=Jl(ω)⊤J_r(\omega) = J_l(\omega)\transpose, since [ω]×[\omega]_\times is skew. The coefficients AA, BB and CC, like sin⁡(θ/2)/θ\sin(\theta/2)/\theta in (6) and 2atan2⁡(n,w)/n2\atantwo(n, w)/n 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, q⊕v=q⊗Exp⁡(v)q \oplus \tangent = q \otimes \Exp(\tangent), 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 2π2\pi, and as a chart of the rotations only on the ball of radius π\pi, 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 R3\R^3.

The stereographic chart#

The first is the stereographic projection of the sphere S3S^3 from the point opposite the centre:

q⊕v=q⊗(1−s, v/2)1+s,s=116∣v∣2;p⊖q=4 vec⁡(qˉ⊗p)1+w(qˉ⊗p).(11) q \oplus \tangent = q \otimes \frac{\bigl(1 - s,\ \tangent / 2\bigr)}{1 + s}, \quad s = \tfrac1{16} \lvert \tangent \rvert^2; \qquad p \ominus q = \frac{4\, \operatorname{vec}(\bar q \otimes p)}{1 + w(\bar q \otimes p)} . \tag{11}
(11)
Proposition 12(The stereographic chart of the unit quaternions).

For q∈S3q \in S^3 and v∈R3\tangent \in \R^3, with s=∣v∣2/16s = \lvert \tangent \rvert^2 / 16, let

q⊕v=q⊗δ(v),δ(v)=(1−s, v/2)1+s. q \oplus \tangent = q \otimes \delta(\tangent), \qquad \delta(\tangent) = \frac{\bigl(1 - s,\ \tangent / 2\bigr)}{1 + s} .

Then v↦q⊕v\tangent \mapsto q \oplus \tangent is a diffeomorphism of R3\R^3 onto S3∖{−q}S^3 \setminus \{-q\}, whose inverse is p↦4 vec⁡(qˉ⊗p)/(1+w(qˉ⊗p))p \mapsto 4\, \operatorname{vec}(\bar q \otimes p) / (1 + w(\bar q \otimes p)); δ(v)\delta(\tangent) is the rotation by the angle θ=4arctan⁡(∣v∣/4)\theta = 4 \arctan(\lvert \tangent \rvert / 4) about v\tangent; and π(q⊕v)=π(q) (I+[v]×)+O(∣v∣2)\pi(q \oplus \tangent) = \pi(q)\,\bigl(I + [\tangent]_\times\bigr) + O(\lvert \tangent \rvert^2), so that v\tangent is, to first order, the rotation vector of the perturbation in the frame of qq.

Proof.

Write δ=δ(v)\delta = \delta(\tangent). Its norm is ((1−s)2+4s)1/2/(1+s)=1((1 - s)^2 + 4s)^{1/2} / (1 + s) = 1, so q⊗δq \otimes \delta is a unit quaternion. With w(δ)=(1−s)/(1+s)w(\delta) = (1 - s)/(1 + s) and ∣vec⁡(δ)∣=(∣v∣/2)/(1+s)\lvert \operatorname{vec}(\delta) \rvert = (\lvert \tangent \rvert / 2)/(1 + s), δ\delta is the rotation by θ\theta about v\tangent with cos⁡θ2=(1−s)/(1+s)\cos \tfrac\theta2 = (1-s)/(1+s) and sin⁡θ2=(∣v∣/2)/(1+s)\sin \tfrac\theta2 = (\lvert \tangent \rvert / 2)/(1+s), so tan⁡θ4=sin⁡θ2/(1+cos⁡θ2)=∣v∣/4\tan \tfrac\theta4 = \sin \tfrac\theta2 / (1 + \cos \tfrac\theta2) = \lvert \tangent \rvert / 4. As ∣v∣\lvert \tangent \rvert runs over [0,∞)[0, \infty), θ\theta runs over [0,2π)[0, 2\pi), so δ\delta runs over every unit quaternion but −1-1, once each; δ\delta is the inverse of the stereographic projection of S3S^3 from −1-1 onto the hyperplane w=0w = 0, at v/4\tangent / 4. Left multiplication by qq carries S3∖{−1}S^3 \setminus \{-1\} to S3∖{−q}S^3 \setminus \{-q\}. The inverse follows from δ=qˉ⊗p\delta = \bar q \otimes p and vec⁡(δ)/(1+w(δ))=v/4\operatorname{vec}( \delta) / (1 + w(\delta)) = \tangent / 4, which ss cancels from. Last, δ(v)=(1,v/2)+O(∣v∣2)\delta(\tangent) = (1, \tangent / 2) + O(\lvert \tangent \rvert^2), and (2) at it is I+[v]×+O(∣v∣2)I + [\tangent]_\times + O(\lvert \tangent \rvert^2); π\pi is a homomorphism.

∎

The chart’s coordinate of a rotation by θ\theta has the length 4tan⁡(θ/4)=θ+θ3/48+O(θ5)4 \tan(\theta / 4) = \theta + \theta^3 / 48 + O(\theta^5). These are the modified Rodrigues parameters of attitude estimation, scaled by 44 so that they agree with the rotation vector to first order. The chart is the left translation of the chart at the identity, q⊕v=q⊗(1⊕v)q \oplus \tangent = q \otimes (1 \oplus \tangent), and since δ\delta depends on v\tangent only through its direction and its length, which π(q)\pi(q) preserves,

q⊕v=(1⊕π(q) v)⊗q(13) q \oplus \tangent = (1 \oplus \pi(q)\, \tangent) \otimes q \tag{13}
(13)

exactly, not only to first order: the chart written with its perturbation on the left is the same chart, its coordinates rotated by π(q)\pi(q).

It is a chart of S3S^3, and so it must tell qq from −q-q, which are different points of S3S^3. Where it puts the two is the whole of what the sign costs.

Proposition 14(The antipode in the stereographic chart).

Let μ,q∈S3\mu, q \in S^3 with q≠±μq \neq \pm\mu, and let v=q⊖μ\tangent = q \ominus \mu in the stereographic chart. Then

(−q)⊖μ=q⊖(−μ)=−16∣v∣2 v, (-q) \ominus \mu = q \ominus (-\mu) = -\frac{16}{\lvert \tangent \rvert^2}\, \tangent ,

and ∣v∣<4\lvert \tangent \rvert < 4 exactly when ⟨q,μ⟩>0\langle q, \mu \rangle > 0. Of the two points ±q\pm q over one rotation, the one on the side of μ\mu has the coordinate of length 4tan⁡(θ/4)≤44 \tan(\theta / 4) \le 4, with θ∈[0,π]\theta \in [0, \pi] the angle between the rotations π(q)\pi(q) and π(μ)\pi(\mu), and the other the coordinate of length 4cot⁡(θ/4)≥44 \cot(\theta / 4) \ge 4 in the opposite direction. The two lengths multiply to 1616.

Proof.

Write μˉ⊗q=(w,u)\bar\mu \otimes q = (w, u), so that v=4u/(1+w)\tangent = 4u / (1 + w) and, since ∣u∣2=1−w2\lvert u \rvert^2 = 1 - w^2,

∣v∣2=16∣u∣2(1+w)2=16(1−w)1+w, \lvert \tangent \rvert^2 = \frac{16 \lvert u \rvert^2}{(1 + w)^2} = \frac{16 (1 - w)}{1 + w} ,

which is below 1616 exactly when w=⟨q,μ⟩>0w = \langle q, \mu \rangle > 0. Both μˉ⊗(−q)\bar\mu \otimes (-q) and (−μ)‾⊗q\overline{(-\mu)} \otimes q are (−w,−u)(-w, -u), whose coordinate is −4u/(1−w)-4u / (1 - w), and

−16∣v∣2 v=−(1+w)(1−w)⋅4u1+w=−4u1−w. -\frac{16}{\lvert \tangent \rvert^2}\, \tangent = -\frac{(1 + w)}{(1 - w)} \cdot \frac{4u}{1 + w} = -\frac{4u}{1 - w} .

For the lengths, the point on the side of μ\mu is at the angle θ∈[0,π]\theta \in [0, \pi] from μ\mu by Proposition 12, which is the angle between the rotations, and the other at 2π−θ2\pi - \theta, whose coordinate has the length 4tan⁡(π/2−θ/4)=4cot⁡(θ/4)4 \tan(\pi/2 - \theta/4) = 4 \cot(\theta/4).

∎

So the map from one sign to the other is the inversion in the sphere of radius 44, followed by negation. The ball of radius 44 is the chart of the near sides, one point for each rotation within less than a half-turn of π(μ)\pi(\mu), and its complement holds the far sides. A rotation close to π(μ)\pi(\mu), given by the quaternion on the far side, has a coordinate of length 4cot⁡(θ/4)4 \cot(\theta/4), 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 μ\mu as a point can be, exactly when it is nearest.

The sign is not only a matter of single points. A turn of 2π2\pi about an axis is the identity rotation and the quaternion −1-1: rotations about one axis by α1,…,αn\alpha_1, \dots, \alpha_n with ∑kαk=2π\sum_k \alpha_k = 2\pi compose to the identity, while their quaternions, each taken with w>0w > 0, multiply to −1-1. Angles add modulo 4π4\pi on S3S^3 and modulo 2π2\pi 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 qq from −q-q. The second global chart is the familiar first-order update of a quaternion, normalized.

Proposition 15(The Cayley chart of the rotations).

For q∈S3q \in S^3 and v∈R3\tangent \in \R^3, let

q⊕v=q⊗γ(v),γ(v)=(1, v/2)1+∣v∣2/4,p⊖q=2vec⁡(qˉ⊗p)w(qˉ⊗p)(w(qˉ⊗p)≠0). q \oplus \tangent = q \otimes \gamma(\tangent), \qquad \gamma(\tangent) = \frac{(1,\ \tangent / 2)}{\sqrt{1 + \lvert \tangent \rvert^2 / 4}} , \qquad p \ominus q = \frac{2 \operatorname{vec}(\bar q \otimes p)}{w(\bar q \otimes p)} \quad \bigl(w(\bar q \otimes p) \ne 0\bigr) .

Then (−q)⊕v=−(q⊕v)(-q) \oplus \tangent = -(q \oplus \tangent), and p⊖qp \ominus q is unchanged when either pp or qq is negated. The map v↦π(q⊕v)\tangent \mapsto \pi(q \oplus \tangent) is a diffeomorphism of R3\R^3 onto the rotations by less than π\pi from π(q)\pi(q), with inverse R↦p⊖qR \mapsto p \ominus q for either pp over RR; γ(v)\gamma(\tangent) is the rotation by θ=2arctan⁡(∣v∣/2)\theta = 2 \arctan(\lvert \tangent \rvert / 2) about v\tangent; π(q⊕v)=π(q) (I+[v]×)+O(∣v∣2)\pi(q \oplus \tangent) = \pi(q)\, (I + [\tangent]_\times) + O(\lvert \tangent \rvert^2); and q⊕v=(1⊕π(q) v)⊗qq \oplus \tangent = (1 \oplus \pi(q)\, \tangent) \otimes q.

Proof.

The norm of (1,v/2)(1, \tangent / 2) is 1+∣v∣2/4\sqrt{1 + \lvert \tangent \rvert^2 / 4}, so γ(v)∈S3\gamma(\tangent) \in S^3, with w(γ)>0w(\gamma) > 0 and ∣vec⁡(γ)∣/w(γ)=∣v∣/2\lvert \operatorname{vec}(\gamma) \rvert / w(\gamma) = \lvert \tangent \rvert / 2; it is the rotation by θ\theta about v\tangent with tan⁡(θ/2)=∣v∣/2\tan(\theta / 2) = \lvert \tangent \rvert / 2, so θ∈[0,π)\theta \in [0, \pi), every such rotation once. Negating qq negates q⊗γq \otimes \gamma. Negating pp or qq negates qˉ⊗p\bar q \otimes p, whose vec⁡\operatorname{vec} and ww change sign together, so their ratio does not. For p=q⊗γ(v)p = q \otimes \gamma(\tangent), qˉ⊗p=γ(v)\bar q \otimes p = \gamma(\tangent) and 2vec⁡(γ)/w(γ)=v2 \operatorname{vec}(\gamma) / w(\gamma) = \tangent; and every rotation by less than π\pi from π(q)\pi(q) is π(q⊗δ)\pi(q \otimes \delta) for a δ\delta with w(δ)>0w(\delta) > 0, which is γ\gamma of 2vec⁡(δ)/w(δ)2 \operatorname{vec}(\delta) / w(\delta). The first-order form and the last identity follow as for the stereographic chart: γ(v)=(1,v/2)+O(∣v∣2)\gamma(\tangent) = (1, \tangent / 2) + O(\lvert \tangent \rvert^2), and γ\gamma depends on v\tangent 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 SO(3)SO(3) itself, with its inverse, computed through whichever quaternions the two rotations happen to be given by. On matrices it is the Cayley transform, π(q⊕v)=π(q) (I−12[v]×)−1(I+12[v]×)\pi(q \oplus \tangent) = \pi(q)\, (I - \tfrac12 [\tangent]_\times)^{-1} (I + \tfrac12 [\tangent]_\times). Its coordinate of a rotation by θ\theta has the length

2tan⁡(θ/2)=θ+θ3/12+O(θ5), 2 \tan(\theta / 2) = \theta + \theta^3 / 12 + O(\theta^5) ,

a little farther from the angle than the stereographic chart’s. A rotation has one coordinate at μ\mu, of length 2tan⁡(θ/2)2\tan(\theta/2) for θ∈[0,π)\theta \in [0, \pi) its angle from π(μ)\pi(\mu), 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 μ\mu, is the rotations a half-turn from π(μ)\pi(\mu): not one point, as the stereographic chart misses −μ-\mu, but a surface, the rotations by π\pi about every axis, composed with μ\mu. There w(μˉ⊗p)=0w(\bar\mu \otimes p) = 0 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 44, 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.

Proposition 16(The charts agree with the exponential to second order).

In the stereographic chart and in the Cayley chart alike, 1⊕v=Exp⁡(v)+O(∣v∣3)1 \oplus \tangent = \Exp(\tangent) + O(\lvert \tangent \rvert^3), and so q⊕v=q⊗Exp⁡(v)+O(∣v∣3)q \oplus \tangent = q \otimes \Exp(\tangent) + O(\lvert \tangent \rvert^3) at every qq. Hence the derivative in charts of a smooth map between rotations and Euclidean spaces is its Jacobian in exponential coordinates on the right, q⊗Exp⁡(v)q \otimes \Exp(\tangent), and the second derivatives of the map at the centres of the charts are those in exponential coordinates too. In particular the derivative of Exp⁡:R3→S3\Exp : \R^3 \to S^3 at ω\omega is the right Jacobian Jr(ω)J_r(\omega), and that of Log⁡\Log at qq is Jr(Log⁡q)−1J_r(\Log q)^{-1}.

Proof.

From (1−s)/(1+s)=1−2s+O(s2)(1 - s)/(1 + s) = 1 - 2s + O(s^2) with s=∣v∣2/16s = \lvert \tangent \rvert^2 / 16, the stereographic chart has 1⊕v=(1−18∣v∣2, 12v)+O(∣v∣3)1 \oplus \tangent = \bigl(1 - \tfrac18 \lvert \tangent \rvert^2,\ \tfrac12 \tangent\bigr) + O(\lvert \tangent \rvert^3). From (1+∣v∣2/4)−1/2=1−18∣v∣2+O(∣v∣4)(1 + \lvert \tangent \rvert^2 / 4)^{-1/2} = 1 - \tfrac18 \lvert \tangent \rvert^2 + O(\lvert \tangent \rvert^4), the Cayley chart has the same expansion, and so has Exp⁡(v)\Exp(\tangent), from cos⁡θ2=1−18θ2+O(θ4)\cos \tfrac\theta2 = 1 - \tfrac18 \theta^2 + O(\theta^4) and sin⁡(θ/2)/θ=12+O(θ2)\sin(\theta/2)/\theta = \tfrac12 + O(\theta^2). 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 F\map at x\point is the Jacobian at 00 of v↦Ry−1(F(Rx(v)))\tangent \mapsto R_\otherPoint^{-1}(\map(R_\point(\tangent))), and the local representatives of F\map in two charts that agree to second order agree to second order at 00, with their first and second derivatives there. Last, Exp⁡(ω+ε)⊖Exp⁡(ω)\Exp(\omega + \varepsilon) \ominus \Exp(\omega) is the chart coordinate at 11 of Exp⁡(ω)−1⊗Exp⁡(ω+ε)=Exp⁡(Jr(ω) ε)+O(∣ε∣2)\Exp(\omega)^{-1} \otimes \Exp(\omega + \varepsilon) = \Exp(J_r(\omega)\, \varepsilon) + O(\lvert \varepsilon \rvert^2), which is Jr(ω) ε+O(∣ε∣2)J_r(\omega)\, \varepsilon + O(\lvert \varepsilon \rvert^2); and Log⁡\Log is the inverse of Exp⁡\Exp.

∎

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 JrJ_r 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 q1q_1 to q2q_2, at the parameter t∈Rt \in \R, is

q1⊗Exp⁡(tLog⁡(qˉ1⊗q2)),(17) q_1 \otimes \Exp\bigl(t \Log(\bar q_1 \otimes q_2)\bigr), \tag{17}
(17)

which runs at a constant rate along the great circle of S3S^3 through q1q_1 and q2q_2, reaching q2q_2 at t=1t = 1 by the arc that avoids −q1-q_1. With rv⁡\rv in place of Log⁡\Log 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 ⟨q1,q2⟩≥0\langle q_1, q_2 \rangle \ge 0.

The angle between two rotations, the length of the shorter turn from one to the other, is

∠(q1,q2)=∣rv⁡(qˉ1⊗q2)∣=2atan2⁡(∣vec⁡(r)∣, ∣w(r)∣)∈[0,π],r=qˉ1⊗q2.(18) \angle(q_1, q_2) = \lvert \rv(\bar q_1 \otimes q_2) \rvert = 2 \atantwo\bigl(\lvert \operatorname{vec}(r) \rvert,\ \lvert w(r) \rvert\bigr) \in [0, \pi], \qquad r = \bar q_1 \otimes q_2 . \tag{18}
(18)

It is the same at ±q1\pm q_1 and ±q2\pm q_2, and smooth where 0<∠<π0 < \angle < \pi: at 00 it is a norm, with no derivative, and at π\pi a maximum, where ∣w(r)∣\lvert w(r) \rvert turns. Its square is smooth at 00, 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 θ\theta about an axis a≠0a \ne 0 is (cos⁡θ2, sin⁡θ2 a/∣a∣)(\cos \tfrac\theta2,\ \sin \tfrac\theta2\, a / \lvert a \rvert), 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 aa to that of bb is the normalization of

(∣a∣∣b∣+a⋅b, a×b),(19) \bigl(\lvert a \rvert \lvert b \rvert + a \cdot b,\ a \times b\bigr), \tag{19}
(19)

since for unit vectors at the angle θ\theta about the axis nn this is (1+cos⁡θ,sin⁡θ n)=2cos⁡θ2(cos⁡θ2,sin⁡θ2 n)(1 + \cos \theta, \sin \theta\, n) = 2 \cos \tfrac\theta2 \bigl(\cos \tfrac\theta2, \sin \tfrac\theta2\, n\bigr). It is smooth for a,b≠0a, b \ne 0 except where bb is opposite to aa: there the vector vanishes, every half-turn about an axis perpendicular to aa is a rotation of least angle, and the map is undefined.

Euler angles. A sequence of axes (i,j,k)(i, j, k) with i≠j≠ki \ne j \ne k is proper when k=ik = i and of Tait–Bryan type when the three are distinct, six sequences of each. With qe(θ)=(cos⁡θ2,sin⁡θ2 e)q_e(\theta) = (\cos \tfrac\theta2, \sin \tfrac\theta2\, e) the rotation by θ\theta about the coordinate axis ee, the rotation by the angles (α,β,γ)(\alpha, \beta, \gamma) about the three axes, each about the axis as the previous rotations left it (intrinsic), is

q=qi(α)⊗qj(β)⊗qk(γ),(20) q = q_i(\alpha) \otimes q_j(\beta) \otimes q_k(\gamma), \tag{20}
(20)

smooth in the angles, and the rotation about the fixed axes in the same order (extrinsic) is qk(γ)⊗qj(β)⊗qi(α)q_k(\gamma) \otimes q_j(\beta) \otimes q_i(\alpha), the intrinsic rotation of the reversed sequence. Roll, pitch and yaw (ϕ,ϑ,ψ)(\phi, \vartheta, \psi) in the usual aerospace convention are the intrinsic (z,y,x)(z, y, x) angles (ψ,ϑ,ϕ)(\psi, \vartheta, \phi). The way back has one form for every sequence.

Proposition 21(The Euler angles of a unit quaternion).

Let (i,j,k)(i, j, k) be axes with i≠j≠ki \ne j \ne k, let ll be the axis other than ii and jj, and let ϵ=±1\epsilon = \pm 1 with ei×ej=ϵ ele_i \times e_j = \epsilon\, e_l. Write qe(θ)=(cos⁡θ2,sin⁡θ2 e)q_e(\theta) = (\cos \tfrac\theta2, \sin \tfrac\theta2\, e).

  1. Proper angles, k=ik = i. If q=qi(α)⊗qj(β)⊗qi(γ)q = q_i(\alpha) \otimes q_j(\beta) \otimes q_i(\gamma) with β∈[0,π]\beta \in [0, \pi], then, with σ=(α+γ)/2\sigma = (\alpha + \gamma)/2 and δ=(α−γ)/2\delta = (\alpha - \gamma)/2,

    (w, ui)=cos⁡β2 (cos⁡σ, sin⁡σ),(uj, ϵ ul)=sin⁡β2 (cos⁡δ, sin⁡δ). (w,\ u_i) = \cos \tfrac\beta2\, (\cos \sigma,\ \sin \sigma), \qquad (u_j,\ \epsilon\, u_l) = \sin \tfrac\beta2\, (\cos \delta,\ \sin \delta) .

    So for β∈(0,π)\beta \in (0, \pi) the angles are recovered, modulo 2π2\pi, from any positive multiple of qq or of −q-q as β=2atan2⁡(∣(uj,ul)∣, ∣(w,ui)∣)\beta = 2 \operatorname{atan2}\bigl(\lvert (u_j, u_l) \rvert,\ \lvert (w, u_i) \rvert\bigr), α=σ+δ\alpha = \sigma + \delta and γ=σ−δ\gamma = \sigma - \delta, where σ=atan2⁡(ui,w)\sigma = \operatorname{atan2}(u_i, w) and δ=atan2⁡(ϵ ul,uj)\delta = \operatorname{atan2}(\epsilon\, u_l, u_j).

  2. Tait–Bryan angles, k=lk = l. If q=qi(α)⊗qj(β)⊗qk(γ)q = q_i(\alpha) \otimes q_j(\beta) \otimes q_k(\gamma) with β∈[−π2,π2]\beta \in [-\tfrac\pi2, \tfrac\pi2], then q⊗qj(π2)q \otimes q_j(\tfrac\pi2) has the proper angles (α, β+π2, −ϵγ)(\alpha,\ \beta + \tfrac\pi2,\ -\epsilon \gamma) about (i,j,i)(i, j, i), and is a positive multiple of (w−uj, ui−ϵuk, uj+w, uk+ϵui)(w - u_j,\ u_i - \epsilon u_k,\ u_j + w,\ u_k + \epsilon u_i), listed as the coordinates (w,ui,uj,uk)(w, u_i, u_j, u_k).

Proof.

With cθ=cos⁡θ2c_\theta = \cos \tfrac\theta2 and sθ=sin⁡θ2s_\theta = \sin \tfrac\theta2, and ej×ei=−ϵ ele_j \times e_i = -\epsilon\, e_l, el×ei=ϵ eje_l \times e_i = \epsilon\, e_j, the product (1) gives qi(α)⊗qj(β)=(cαcβ, sαcβ ei+cαsβ ej+ϵsαsβ el)q_i(\alpha) \otimes q_j(\beta) = (c_\alpha c_\beta,\ s_\alpha c_\beta\, e_i + c_\alpha s_\beta\, e_j + \epsilon s_\alpha s_\beta\, e_l), and its product with qi(γ)q_i(\gamma) has

w=cβ(cαcγ−sαsγ),ui=cβ(cαsγ+sαcγ),uj=sβ(cαcγ+sαsγ),ul=ϵ sβ(sαcγ−cαsγ), w = c_\beta (c_\alpha c_\gamma - s_\alpha s_\gamma), \quad u_i = c_\beta (c_\alpha s_\gamma + s_\alpha c_\gamma), \quad u_j = s_\beta (c_\alpha c_\gamma + s_\alpha s_\gamma), \quad u_l = \epsilon\, s_\beta (s_\alpha c_\gamma - c_\alpha s_\gamma),

which are the stated forms by the addition formulas. For β∈(0,π)\beta \in (0, \pi) both cβc_\beta and sβs_\beta are positive, so ∣(w,ui)∣=λcβ\lvert (w, u_i) \rvert = \lambda c_\beta and ∣(uj,ul)∣=λsβ\lvert (u_j, u_l) \rvert = \lambda s_\beta for qq scaled by λ>0\lambda > 0, and the atan2⁡\atantwos return β/2\beta / 2, and σ\sigma and δ\delta modulo 2π2\pi; for −q-q they return σ+π\sigma + \pi and δ+π\delta + \pi modulo 2π2\pi, which change α\alpha and γ\gamma by multiples of 2π2\pi. For the second claim, let r=qj(π2)r = q_j(\tfrac\pi2). Since π(r)\pi(r) turns eie_i about eje_j to ej×ei=−ϵeke_j \times e_i = -\epsilon e_k, qk(γ)=r⊗qi(−ϵγ)⊗rˉq_k(\gamma) = r \otimes q_i(-\epsilon \gamma) \otimes \bar r, and so q⊗r=qi(α)⊗qj(β+π2)⊗qi(−ϵγ)q \otimes r = q_i(\alpha) \otimes q_j(\beta + \tfrac\pi2) \otimes q_i(-\epsilon\gamma), with β+π2∈[0,π]\beta + \tfrac\pi2 \in [0, \pi]. Last, q⊗(1,ej)=(w−uj, u+w ej+u×ej)q \otimes (1, e_j) = (w - u_j,\ u + w\, e_j + u \times e_j) is 2 q⊗r\sqrt 2\, q \otimes r, and u×ej=ϵui ek−ϵuk eiu \times e_j = \epsilon u_i\, e_k - \epsilon u_k\, e_i.

∎

So the Euler angles of a unit quaternion are, for a proper sequence, those of Proposition 21 read off qq, and for a Tait–Bryan sequence those read off the linear rearrangement of qq it gives, with β\beta lowered by π2\tfrac\pi2 and γ\gamma multiplied by −ϵ-\epsilon; for an extrinsic sequence, those of the reversed sequence, in reverse order. They are the same at qq and at −q-q, 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.

Proposition 22(No continuous Euler angles).

Fix a sequence of axes (i,j,k)(i, j, k), and call a rotation at the lock when its β\beta is 00 or π\pi for a proper sequence, ±π2\pm\tfrac\pi2 for a Tait–Bryan one.

  1. Away from the lock, α\alpha and γ\gamma are smooth maps of the rotation into the circle R/2πZ\R / 2\pi\mathbb Z, but neither is represented by a continuous real-valued map on any set of rotations containing the loop t↦π(qi(t)⊗qj(β)⊗qk(γ))t \mapsto \pi\bigl(q_i(t) \otimes q_j(\beta) \otimes q_k(\gamma)\bigr), t∈[0,2π]t \in [0, 2\pi], for γ\gamma the loop in its own angle, with β\beta off the lock.
  2. At a rotation at the lock, neither α\alpha nor γ\gamma has a limit, even in the circle. For a proper sequence, α+γ\alpha + \gamma has one at β=0\beta = 0 and α−γ\alpha - \gamma at β=π\beta = \pi; for a Tait–Bryan sequence, α−ϵγ\alpha - \epsilon \gamma has one at β=−π2\beta = -\tfrac\pi2 and α+ϵγ\alpha + \epsilon \gamma at β=π2\beta = \tfrac\pi2, with ϵ\epsilon as in the proposition on the Euler angles of a unit quaternion.
Proof.

For the first claim, let α~\tilde\alpha be continuous and real-valued, equal to α\alpha modulo 2π2\pi on the loop. Off the lock the angles are unique modulo 2π2\pi by Proposition 21, so the loop’s rotation at tt has α=t\alpha = t modulo 2π2\pi, and α~(t)−t\tilde\alpha(t) - t is continuous with values in 2πZ2\pi\mathbb Z, hence constant. So α~\tilde\alpha is larger by 2π2\pi at t=2πt = 2\pi than at t=0t = 0, but the loop closes there, since qi(2π)=−1q_i(2\pi) = -1 and π(−q)=π(q)\pi(-q) = \pi(q). The same holds of γ\gamma on its loop. For the second, take a proper sequence. As β→0\beta \to 0, qi(α)⊗qj(β)⊗qi(θ−α)q_i(\alpha) \otimes q_j(\beta) \otimes q_i(\theta - \alpha) tends to qi(θ)q_i(\theta) for every α\alpha, and for β∈(0,π)\beta \in (0, \pi) its angles are α\alpha and θ−α\theta - \alpha modulo 2π2\pi; so the rotations near π(qi(θ))\pi(q_i(\theta)) take every α\alpha and every γ\gamma, while α+γ=θ\alpha + \gamma = \theta on all of them. At β=π\beta = \pi the same holds of qi(α)⊗qj(β)⊗qi(α−θ)q_i(\alpha) \otimes q_j(\beta) \otimes q_i(\alpha - \theta), which tends to qi(θ)⊗qj(π)q_i(\theta) \otimes q_j(\pi) for every α\alpha, since qj(π)⊗qi(φ)=qi(−φ)⊗qj(π)q_j(\pi) \otimes q_i(\varphi) = q_i(-\varphi) \otimes q_j(\pi), a half-turn about eje_j reversing eie_i; there α−γ=θ\alpha - \gamma = \theta. A Tait–Bryan sequence’s angles are, by Proposition 21, the proper angles (α,β+π2,−ϵγ)(\alpha, \beta + \tfrac\pi2, -\epsilon\gamma) of q⊗qj(π2)q \otimes q_j(\tfrac\pi2), 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, α\alpha and γ\gamma are smooth as points of the circle, and a formula returns them as real numbers in (−π,π](-\pi, \pi]. By Proposition 22 a real-valued angle must be cut somewhere, and this convention cuts it where it is π\pi: crossing there, it jumps by 2π2\pi. The jump is in the value alone. atan2⁡(a,b)\atantwo(a, b) jumps across its half-line a=0a = 0, b<0b < 0, but its derivatives, (b,−a)/(a2+b2)(b, -a) / (a^2 + b^2), 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 aa and an angle bb it is compared with is taken on the circle,

a⊖b=atan2⁡(sin⁡(a−b), cos⁡(a−b)),(23) a \ominus b = \atantwo\bigl(\sin(a - b),\ \cos(a - b)\bigr), \tag{23}
(23)

which moves the cut to a difference of ±π\pm\pi, as far as an angle can be from the one it is compared with, and has the derivatives of a−ba - b everywhere else.

The lock. At gimbal lock one of the two norms of Proposition 21 vanishes, and only α+γ\alpha + \gamma or α−γ\alpha - \gamma is determined: no convention makes the angles continuous there. Off the lock the angles are smooth, but not uniformly. δ\delta is the angle of the vector (uj,ϵul)(u_j, \epsilon u_l) of length sin⁡β2\sin \tfrac\beta2, and σ\sigma that of (w,ui)(w, u_i) of length cos⁡β2\cos \tfrac\beta2, so the first derivatives of α\alpha and γ\gamma grow like 1/sin⁡β21 / \sin \tfrac\beta2 as β→0\beta \to 0 and 1/cos⁡β21 / \cos \tfrac\beta2 as β→π\beta \to \pi, and their second derivatives like the squares. The same factor amplifies a rounding of qq’s coordinates into α\alpha and γ\gamma near the lock, while α±γ\alpha \pm \gamma, 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