Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

6.2: Orthogonal matrices and orthogonal transformations

In Chapter 6.1, we wrote a matrix with linearly independent columns as A=QRA=QR. The columns of QQ form an orthonormal basis of colsp⁡(A)\operatorname{colsp}(A), and RR records how to recover the original columns from that basis. If AA has shape n×dn\times d, then QQ has shape n×dn\times d and RR has shape d×dd\times d.

For example,

[3−545]=[3/5−4/54/53/5]⏟Q[5107]⏟R.\begin{bmatrix}3&-5\\4&5\end{bmatrix} =\underbrace{\begin{bmatrix}3/5&-4/5\\4/5&3/5\end{bmatrix}}_{Q} \underbrace{\begin{bmatrix}5&1\\0&7\end{bmatrix}}_{R}.

What does having orthonormal columns tell us about QQ as a matrix? We’ll see that it describes a transformation that preserves lengths and angles. To show this, we’ll first introduce the transpose.


The transpose

The transpose of a matrix AA, written ATA^T, is obtained by turning its columns into rows, in the same order. Thus, if AA has shape n×dn\times d, then ATA^T has shape d×nd\times n. For example,

A=[2−14350]⟹AT=[23−1540].A=\begin{bmatrix}2&-1&4\\3&5&0\end{bmatrix} \qquad\Longrightarrow\qquad A^T=\begin{bmatrix}2&3\\-1&5\\4&0\end{bmatrix}.

The entry in position (i,j)(i,j) moves to position (j,i)(j,i). In particular, the transpose of a column vector is a one-row matrix. This lets us write a dot product as a matrix product:

x⃗ Ty⃗=[x1⋯xn][y1⋮yn]=x1y1+⋯+xnyn=x⃗⋅y⃗.\vec x^{\,T}\vec y =\begin{bmatrix}x_1&\cdots&x_n\end{bmatrix} \begin{bmatrix}y_1\\\vdots\\y_n\end{bmatrix} =x_1y_1+\cdots+x_ny_n=\vec x\cdot\vec y.

Strictly speaking, x⃗ Ty⃗\vec x^{\,T}\vec y is a 1×11\times1 matrix, while x⃗⋅y⃗\vec x\cdot\vec y is a scalar. In this equation, we’re identifying a 1×11\times1 matrix with its single entry.

Transposing twice brings us back to the original matrix. Transposing also respects addition and scalar multiplication:

(AT)T=A,(A+B)T=AT+BT,(cA)T=cAT.(A^T)^T=A,\qquad (A+B)^T=A^T+B^T,\qquad (cA)^T=cA^T.

When we transpose a product, the order of the factors reverses.

(AB)T=BTAT.\boxed{(AB)^T=B^TA^T.}

The shapes must allow ABAB to be formed. If AA has shape n×dn\times d and BB has shape d×md\times m, then both sides have shape m×nm\times n.

Why does the order reverse? The (i,j)(i,j) entry of ABAB is the sum of the pairwise products of the entries in row ii of AA with those in column jj of BB. In BTATB^TA^T, that same calculation appears in position (j,i)(j,i): row jj of BTB^T comes from column jj of BB, and column ii of ATA^T comes from row ii of AA.


Orthogonal matrices

Write the columns of an n×dn\times d matrix QQ as u⃗1,…,u⃗d\vec u_1,\ldots,\vec u_d. Then

QTQ=[u⃗1⋅u⃗1⋯u⃗1⋅u⃗d⋮⋱⋮u⃗d⋅u⃗1⋯u⃗d⋅u⃗d].Q^TQ= \begin{bmatrix} \vec u_1\cdot\vec u_1&\cdots&\vec u_1\cdot\vec u_d\\ \vdots&\ddots&\vdots\\ \vec u_d\cdot\vec u_1&\cdots&\vec u_d\cdot\vec u_d \end{bmatrix}.

If the columns are orthonormal, the diagonal entries are 1 and all other entries are 0. Conversely, those entries tell us exactly that the columns are orthonormal. Thus,

Q has orthonormal columns⟺QTQ=Id.Q\text{ has orthonormal columns}\quad\Longleftrightarrow\quad Q^TQ=I_d.

What if QQ is square? The equation QTQ=InQ^TQ=I_n implies that QQ is invertible, with Q−1=QTQ^{-1}=Q^T. We therefore also have QQT=InQQ^T=I_n.

Despite the name, orthogonal columns alone aren’t enough: they must also have length one. For instance, [2003]\begin{bmatrix}2&0\\0&3\end{bmatrix} has perpendicular columns but is not an orthogonal matrix.

For the QQ from our QR example,

Q−1=QT=[3/54/5−4/53/5].Q^{-1}=Q^T=\begin{bmatrix}3/5&4/5\\-4/5&3/5\end{bmatrix}.

So, to find the inverse of an orthogonal matrix, we just transpose it.

The rows are orthonormal too

The equation QQT=InQQ^T=I_n says that the vectors formed from the rows of an orthogonal matrix are orthonormal too. We imposed conditions only on the columns; the conditions on the rows follow automatically.

For example, consider

Q=[2/3−2/31/31/32/32/3−2/3−1/32/3].Q=\begin{bmatrix}2/3&-2/3&1/3\\1/3&2/3&2/3\\-2/3&-1/3&2/3\end{bmatrix}.

Each column has squared length (4+1+4)/9=1(4+1+4)/9=1, with the terms in a different order for the other columns. The dot products between distinct columns are

−4+2+29=0,2+2−49=0,−2+4−29=0.\frac{-4+2+2}{9}=0,\qquad \frac{2+2-4}{9}=0,\qquad \frac{-2+4-2}{9}=0.

So the columns are orthonormal. Without any further calculation, we know that the vectors

[2/3−2/31/3],[1/32/32/3],[−2/3−1/32/3]\begin{bmatrix}2/3\\-2/3\\1/3\end{bmatrix},\qquad \begin{bmatrix}1/3\\2/3\\2/3\end{bmatrix},\qquad \begin{bmatrix}-2/3\\-1/3\\2/3\end{bmatrix}

formed from its rows are also orthonormal. For instance, the dot product of the first two is (2−4+2)/9=0(2-4+2)/9=0, just as predicted.

For another example, consider

Q=[−10/152/1511/1510/15−5/1510/155/1514/152/15].Q=\begin{bmatrix} -10/15&2/15&11/15\\ 10/15&-5/15&10/15\\ 5/15&14/15&2/15 \end{bmatrix}.

The squared lengths of its columns are

100+100+25225=1,4+25+196225=1,121+100+4225=1,\frac{100+100+25}{225}=1,\qquad \frac{4+25+196}{225}=1,\qquad \frac{121+100+4}{225}=1,

and their pairwise dot products are

−20−50+70225=0,−110+100+10225=0,22−50+28225=0.\frac{-20-50+70}{225}=0,\qquad \frac{-110+100+10}{225}=0,\qquad \frac{22-50+28}{225}=0.

So QQ is orthogonal, and the vectors formed from its rows,

115[−10211],115[10−510],115[5142],\frac1{15}\begin{bmatrix}-10\\2\\11\end{bmatrix},\qquad \frac1{15}\begin{bmatrix}10\\-5\\10\end{bmatrix},\qquad \frac1{15}\begin{bmatrix}5\\14\\2\end{bmatrix},

are also orthonormal. For example, the first two have dot product (−100−10+110)/225=0(-100-10+110)/225=0.

Why the square condition matters

A rectangular matrix can have orthonormal columns without having an inverse. For example,

Q=[100100],QTQ=I2,QQT=[100010000]≠I3.Q=\begin{bmatrix}1&0\\0&1\\0&0\end{bmatrix},\qquad Q^TQ=I_2,\qquad QQ^T=\begin{bmatrix}1&0&0\\0&1&0\\0&0&0\end{bmatrix}\ne I_3.

For another example, take the first two columns of the first 3×33\times3 example above:

Q=[2/3−2/31/32/3−2/3−1/3].Q=\begin{bmatrix}2/3&-2/3\\1/3&2/3\\-2/3&-1/3\end{bmatrix}.

Its columns are still orthonormal, so QTQ=I2Q^TQ=I_2. But

QQT=[8/9−2/9−2/9−2/95/9−4/9−2/9−4/95/9]≠I3.QQ^T=\begin{bmatrix}8/9&-2/9&-2/9\\-2/9&5/9&-4/9\\-2/9&-4/9&5/9\end{bmatrix}\ne I_3.

We reserve the term orthogonal matrix for square matrices.


Orthogonal matrices in R2\mathbb R^2

Let’s classify all 2×22\times2 orthogonal matrices. Suppose the first column is

u⃗1=[ab],a2+b2=1.\vec u_1=\begin{bmatrix}a\\b\end{bmatrix},\qquad a^2+b^2=1.

The vectors perpendicular to it lie on the line spanned by [−ba]\begin{bmatrix}-b\\a\end{bmatrix}. There are exactly two unit vectors on that line, so the second column must be either

[−ba]or[b−a].\begin{bmatrix}-b\\a\end{bmatrix}\qquad\text{or}\qquad\begin{bmatrix}b\\-a\end{bmatrix}.

Every point on the unit circle can be written as (cos⁡θ,sin⁡θ)(\cos\theta,\sin\theta). Therefore, every 2×22\times2 orthogonal matrix has one of the following forms:

[cos⁡θ−sin⁡θsin⁡θcos⁡θ]or[cos⁡θsin⁡θsin⁡θ−cos⁡θ].\begin{bmatrix}\cos\theta&-\sin\theta\\\sin\theta&\cos\theta\end{bmatrix} \qquad\text{or}\qquad \begin{bmatrix}\cos\theta&\sin\theta\\\sin\theta&-\cos\theta\end{bmatrix}.

Let’s see what these two possibilities mean geometrically.

The first possibility: a rotation

Recall that the columns of a matrix tell us where the standard basis vectors go. A counterclockwise rotation through angle θ\theta sends

e⃗1=[10] to [cos⁡θsin⁡θ],e⃗2=[01] to [−sin⁡θcos⁡θ].\vec e_1=\begin{bmatrix}1\\0\end{bmatrix}\ \text{to}\ \begin{bmatrix}\cos\theta\\\sin\theta\end{bmatrix},\qquad \vec e_2=\begin{bmatrix}0\\1\end{bmatrix}\ \text{to}\ \begin{bmatrix}-\sin\theta\\\cos\theta\end{bmatrix}.

So its matrix is

Rθ=[cos⁡θ−sin⁡θsin⁡θcos⁡θ].\boxed{R_\theta=\begin{bmatrix}\cos\theta&-\sin\theta\\\sin\theta&\cos\theta\end{bmatrix}.}

We take positive angles counterclockwise and negative angles clockwise. Angles differing by 2π2\pi give the same rotation. For example, a quarter-turn has matrix

Rπ/2=[0−110],Rπ/2[21]=[−12].R_{\pi/2}=\begin{bmatrix}0&-1\\1&0\end{bmatrix},\qquad R_{\pi/2}\begin{bmatrix}2\\1\end{bmatrix}=\begin{bmatrix}-1\\2\end{bmatrix}.

To undo a rotation through θ\theta, rotate through −θ-\theta: Rθ−1=R−θR_\theta^{-1}=R_{-\theta}. This also follows by transposing the rotation matrix. The identity is rotation through angle zero, and −I2-I_2 is rotation through π\pi.

The second possibility: a reflection

A reflection here means reflection across a line through the origin. Let that line make angle ϕ\phi with the positive xx-axis, and write its reflection matrix as HϕH_\phi.

Think about a ray making angle tt with the positive xx-axis. Reflecting it across the line at angle ϕ\phi sends it to the ray at angle 2ϕ−t2\phi-t: the two rays make equal angles with the reflecting line, on opposite sides.

In particular, e⃗1\vec e_1 starts at angle zero and goes to angle 2ϕ2\phi. The vector e⃗2\vec e_2 starts at angle π/2\pi/2 and goes to angle 2ϕ−π/22\phi-\pi/2. Thus,

Hϕe⃗1=[cos⁡(2ϕ)sin⁡(2ϕ)],Hϕe⃗2=[sin⁡(2ϕ)−cos⁡(2ϕ)].H_\phi\vec e_1=\begin{bmatrix}\cos(2\phi)\\\sin(2\phi)\end{bmatrix},\qquad H_\phi\vec e_2=\begin{bmatrix}\sin(2\phi)\\-\cos(2\phi)\end{bmatrix}.

These are the columns of the reflection matrix:

Hϕ=[cos⁡(2ϕ)sin⁡(2ϕ)sin⁡(2ϕ)−cos⁡(2ϕ)].\boxed{H_\phi=\begin{bmatrix}\cos(2\phi)&\sin(2\phi)\\\sin(2\phi)&-\cos(2\phi)\end{bmatrix}.}

This is exactly our second possibility, with θ=2ϕ\theta=2\phi. Notice the factor of two: the reflecting line is at angle ϕ\phi, while the entries involve 2ϕ2\phi. A line at angle ϕ+π\phi+\pi is the same line, so it gives the same reflection.

For example, reflection across the xx-axis and reflection across y=xy=x have matrices

H0=[100−1],Hπ/4=[0110].H_0=\begin{bmatrix}1&0\\0&-1\end{bmatrix},\qquad H_{\pi/4}=\begin{bmatrix}0&1\\1&0\end{bmatrix}.

The first sends [21]\begin{bmatrix}2\\1\end{bmatrix} to [2−1]\begin{bmatrix}2\\-1\end{bmatrix}; the second sends it to [12]\begin{bmatrix}1\\2\end{bmatrix}.

For a less familiar example, reflection across the line at 30∘30^\circ has matrix

Hπ/6=[1/23/23/2−1/2].H_{\pi/6}=\begin{bmatrix}1/2&\sqrt3/2\\\sqrt3/2&-1/2\end{bmatrix}.

It fixes the unit vector [3/21/2]\begin{bmatrix}\sqrt3/2\\1/2\end{bmatrix} along the line and reverses the perpendicular unit vector [−1/23/2]\begin{bmatrix}-1/2\\\sqrt3/2\end{bmatrix}. In general, a reflection leaves the component along the reflecting line unchanged and negates the perpendicular component.

So, every 2×22\times2 orthogonal matrix represents either a rotation or a reflection. Conversely, all these rotation and reflection matrices are orthogonal, since their columns are orthonormal.


Lengths and angles stay the same

Rotations and reflections preserve lengths and angles. Let’s see why the same is true for any matrix with orthonormal columns, even if it isn’t square.

Suppose QQ has shape n×dn\times d and orthonormal columns, so QTQ=IdQ^TQ=I_d. For any x⃗,y⃗∈Rd\vec x,\vec y\in\mathbb R^d,

(Qx⃗)⋅(Qy⃗)=(Qx⃗)T(Qy⃗)=x⃗ TQTQy⃗=x⃗ Ty⃗=x⃗⋅y⃗.\begin{aligned} (Q\vec x)\cdot(Q\vec y)&=(Q\vec x)^T(Q\vec y)\\ &=\vec x^{\,T}Q^TQ\vec y\\ &=\vec x^{\,T}\vec y=\vec x\cdot\vec y. \end{aligned}

In the second equality, we used (Qx⃗)T=x⃗ TQT(Q\vec x)^T=\vec x^{\,T}Q^T. In the third, we used QTQ=IdQ^TQ=I_d. We didn’t need QQ to be square. This shows that any matrix with orthonormal columns preserves dot products, which gives us the following three properties.

Lengths: Set y⃗=x⃗\vec y=\vec x. Then

∥Qx⃗∥2=(Qx⃗)⋅(Qx⃗)=x⃗⋅x⃗=∥x⃗∥2,\|Q\vec x\|^2=(Q\vec x)\cdot(Q\vec x)=\vec x\cdot\vec x=\|\vec x\|^2,

so ∥Qx⃗∥=∥x⃗∥\|Q\vec x\|=\|\vec x\|.

Angles: For nonzero x⃗,y⃗\vec x,\vec y, the cosine of the angle between their images is

(Qx⃗)⋅(Qy⃗)∥Qx⃗∥ ∥Qy⃗∥=x⃗⋅y⃗∥x⃗∥ ∥y⃗∥.\frac{(Q\vec x)\cdot(Q\vec y)}{\|Q\vec x\|\,\|Q\vec y\|} =\frac{\vec x\cdot\vec y}{\|\vec x\|\,\|\vec y\|}.

This is the cosine of the original angle. Since the angle between vectors is taken in [0,π][0,\pi], the angle itself is unchanged. In particular, perpendicular vectors stay perpendicular.

Distances: The distance between two points is preserved too, since

∥Qx⃗−Qy⃗∥=∥Q(x⃗−y⃗)∥=∥x⃗−y⃗∥.\|Q\vec x-Q\vec y\|=\|Q(\vec x-\vec y)\|=\|\vec x-\vec y\|.

The converse is true too. If a linear transformation with domain and codomain Rn\mathbb R^n preserves lengths and angles, then its matrix is orthogonal. In fact, preserving the length of every vector is enough; preserving angles then follows automatically.

When QQ is square, we call the transformation x⃗↦Qx⃗\vec x\mapsto Q\vec x an orthogonal transformation. These may also be viewed as rigid (distance-preserving) transformations of Rn\mathbb{R}^n that fix the origin. In fact, any rigid transformation of Rn\mathbb{R}^n that fixes the origin is automatically linear. As with any linear transformation, Q0⃗=0⃗Q\vec0=\vec0, so an orthogonal matrix cannot represent a nonzero translation.


Composing orthogonal transformations

Suppose PP and QQ are orthogonal matrices of the same shape. Apply QQ first, then PP:

x⃗⟼Qx⃗⟼P(Qx⃗)=(PQ)x⃗.\vec x\longmapsto Q\vec x\longmapsto P(Q\vec x)=(PQ)\vec x.

The matrix on the right acts first. Keeping track of this order matters when we combine rotations and reflections.

Both transformations are linear and preserve lengths and angles. Their composition has these properties too, so it is orthogonal. We can also check directly:

(PQ)T(PQ)=QTPTPQ=QTIQ=QTQ=I.(PQ)^T(PQ)=Q^TP^TPQ=Q^TIQ=Q^TQ=I.

Two rotations: the angles add

Rotate through 90∘90^\circ, then through 180∘180^\circ. The product is

RπRπ/2=[−100−1][0−110]=[01−10]=R3π/2.R_\pi R_{\pi/2} =\begin{bmatrix}-1&0\\0&-1\end{bmatrix}\begin{bmatrix}0&-1\\1&0\end{bmatrix} =\begin{bmatrix}0&1\\-1&0\end{bmatrix}=R_{3\pi/2}.

A quarter-turn followed by a half-turn is a three-quarter-turn. The same geometric reasoning works for any angles:

RβRα=Rα+β.\boxed{R_\beta R_\alpha=R_{\alpha+\beta}.}

For rotations in the plane, the order doesn’t matter: α+β=β+α\alpha+\beta=\beta+\alpha. Thus RβRα=RαRβR_\beta R_\alpha=R_\alpha R_\beta. This is a special feature of planar rotations; two orthogonal matrices need not commute.

Trigonometric identities from matrix multiplication

We know geometrically that RβRα=Rα+βR_\beta R_\alpha=R_{\alpha+\beta}. Multiplying the matrices gives

[cos⁡β−sin⁡βsin⁡βcos⁡β][cos⁡α−sin⁡αsin⁡αcos⁡α]=[cos⁡(α+β)−sin⁡(α+β)sin⁡(α+β)cos⁡(α+β)].\begin{bmatrix}\cos\beta&-\sin\beta\\\sin\beta&\cos\beta\end{bmatrix} \begin{bmatrix}\cos\alpha&-\sin\alpha\\\sin\alpha&\cos\alpha\end{bmatrix} =\begin{bmatrix}\cos(\alpha+\beta)&-\sin(\alpha+\beta)\\\sin(\alpha+\beta)&\cos(\alpha+\beta)\end{bmatrix}.

The top-left and bottom-left entries give the familiar angle-addition formulas:

cos⁡(α+β)=cos⁡αcos⁡β−sin⁡αsin⁡β,\cos(\alpha+\beta)=\cos\alpha\cos\beta-\sin\alpha\sin\beta,
sin⁡(α+β)=sin⁡αcos⁡β+cos⁡αsin⁡β.\sin(\alpha+\beta)=\sin\alpha\cos\beta+\cos\alpha\sin\beta.

They express a simple geometric fact: successive rotations add their angles. For example, take α=π/4\alpha=\pi/4 and β=π/6\beta=\pi/6. Their sum is 5π/125\pi/12, or 75∘75^\circ, and

cos⁡(75∘)=6−24,sin⁡(75∘)=6+24.\cos(75^\circ)=\frac{\sqrt6-\sqrt2}{4},\qquad \sin(75^\circ)=\frac{\sqrt6+\sqrt2}{4}.

Thus,

R5π/12=[(6−2)/4−(6+2)/4(6+2)/4(6−2)/4].R_{5\pi/12}=\begin{bmatrix}(\sqrt6-\sqrt2)/4&-(\sqrt6+\sqrt2)/4\\(\sqrt6+\sqrt2)/4&(\sqrt6-\sqrt2)/4\end{bmatrix}.

Combining rotations and reflections

A product of orthogonal matrices is orthogonal. In R2\mathbb R^2, this means that composing rotations and reflections always gives another rotation or reflection. Let’s determine which one we get and how it depends on the order.

Use the widget below to explore the same transformations. Choose the first transformation QQ and the second transformation PP, then press Play both steps. The original figure is blue, its image after QQ is orange and dashed, and its image after PQPQ is pink. All rotations are about the origin, and all reflecting lines pass through the origin. Angles in the controls are in degrees.

Loading...

A rotation and a reflection give a reflection, in either order. The reflecting line can change when we reverse the order:

  • Reflect across the xx-axis, then rotate 90∘90^\circ counterclockwise: the final figure is the mirror image of the original across y=xy=x.

  • Rotate 90∘90^\circ counterclockwise, then reflect across the xx-axis: the final figure is the mirror image of the original across y=−xy=-x.

Two reflections give a rotation:

  • Reflect across the xx-axis, then across y=xy=x: the final figure is a quarter-turn counterclockwise from the original.

  • Reflect across y=xy=x, then across the xx-axis: the final figure is a quarter-turn clockwise from the original.

In general, two reflections give a rotation through twice the directed angle from the first reflecting line to the second. Reversing the order reverses the rotation. Reflecting twice across the same line gives the identity, a rotation through 0∘0^\circ. We won’t prove these general rules here.


Orthogonal transformations in R3\mathbb R^3

In R2\mathbb R^2, every orthogonal transformation is a rotation or a reflection. In R3\mathbb R^3, we also need to consider a rotation followed by a reflection.

Every orthogonal transformation of R3\mathbb R^3 is one of the following:

  1. A rotation about a line through the origin.

  2. A rotation about a line through the origin, followed by reflection across the plane through the origin perpendicular to that line.

In the second case, the axis and the reflecting plane are perpendicular. The order of these two particular operations does not matter.

Handedness, also called orientation, distinguishes the two kinds. Turn yourself around however you like: your left hand is still a left hand. A rotation preserves handedness. A reflection across a plane acts like a mirror: the reflected shape of your left hand is a right-hand shape. It reverses handedness. Adding a rotation before the reflection does not undo this change.

To picture the two possibilities, imagine that the axis is the zz-axis. In the first case, we rotate the horizontal component of each vector and leave its height unchanged. In the second, we perform the same rotation and then change the sign of its height. The matrices are

[cos⁡θ−sin⁡θ0sin⁡θcos⁡θ0001]and[cos⁡θ−sin⁡θ0sin⁡θcos⁡θ000−1].\begin{bmatrix}\cos\theta&-\sin\theta&0\\\sin\theta&\cos\theta&0\\0&0&1\end{bmatrix} \qquad\text{and}\qquad \begin{bmatrix}\cos\theta&-\sin\theta&0\\\sin\theta&\cos\theta&0\\0&0&-1\end{bmatrix}.

These are the forms when the axis is the zz-axis; the classification allows an axis in any direction. This includes several transformations we have already seen:

  • The identity is a rotation through 0∘0^\circ.

  • Reflection across a plane is the second case with rotation angle 0∘0^\circ.

  • Reflection across a line keeps the component along the line and reverses the perpendicular component. This is a rotation through 180∘180^\circ about that line, so it is included in the first case.

  • Reflection through the origin, x⃗↦−x⃗\vec x\mapsto-\vec x, is the second case with rotation angle 180∘180^\circ. For example, a half-turn about the zz-axis followed by reflection across the xyxy-plane gives

[xyz]⟼[−x−yz]⟼[−x−y−z].\begin{bmatrix}x\\y\\z\end{bmatrix} \longmapsto\begin{bmatrix}-x\\-y\\z\end{bmatrix} \longmapsto\begin{bmatrix}-x\\-y\\-z\end{bmatrix}.

So, in three dimensions, a rotation followed by a reflection across a plane need not be a reflection across a plane.

We won’t prove the classification here. Eigenvalues, which we have not yet studied, help explain why such an axis exists and how to find it.


Two rotations in space give another rotation

The composition of two rotations about axes through the origin is another rotation about an axis through the origin. Its axis need not be either of the original axes.

To see why, recall that the composition is orthogonal. Both rotations preserve handedness, so their composition does too. It therefore belongs to the first case above: a rotation.

For example, first make a quarter-turn about the xx-axis, then a quarter-turn about the yy-axis, with the directions specified by

[xyz]⟼[x−zy]⟼[y−z−x].\begin{bmatrix}x\\y\\z\end{bmatrix} \longmapsto\begin{bmatrix}x\\-z\\y\end{bmatrix} \longmapsto\begin{bmatrix}y\\-z\\-x\end{bmatrix}.

The composition has matrix

Q=[01000−1−100].Q=\begin{bmatrix}0&1&0\\0&0&-1\\-1&0&0\end{bmatrix}.

Notice that

Q[11−1]=[11−1].Q\begin{bmatrix}1\\1\\-1\end{bmatrix}=\begin{bmatrix}1\\1\\-1\end{bmatrix}.

So the resulting rotation is about the line spanned by [11−1]\begin{bmatrix}1\\1\\-1\end{bmatrix}, rather than the xx- or yy-axis. In fact, its angle is 120∘120^\circ, not the 180∘180^\circ we would get by simply adding the two angles.

If two rotations have the same axis, we can add their angles just as in the plane. For different axes, the result is still a single rotation, but finding its axis and angle takes more work. The order generally matters too. As usual, the identity counts as rotation through 0∘0^\circ; any line through the origin can then serve as its axis.


A drone and its camera

A drone describes directions using three perpendicular unit arrows attached to its body: forward, left, and body up. Someone on the ground uses east, north, and vertical up. Each choice gives an orthonormal basis, or a coordinate frame. We will describe velocities and directions first, so the locations of the origins do not matter.

The two frames give different coordinates for the same physical vector. Its length and the angle it makes with another vector are the same in either frame. So, the matrix that converts between these coordinates must preserve lengths and angles.

Suppose the drone faces north with its nose tilted upward through an angle θ\theta, where cos⁡θ=4/5\cos\theta=4/5 and sin⁡θ=3/5\sin\theta=3/5. Its left direction is west, while body up is tilted away from vertical.

<IPython.core.display.Image object>

The forward, left, and body-up unit vectors, expressed in ground coordinates, form the columns of

Q=[0−104/50−3/53/504/5].Q=\begin{bmatrix}0&-1&0\\4/5&0&-3/5\\3/5&0&4/5\end{bmatrix}.

These columns describe perpendicular unit arrows, so they are orthonormal and QTQ=IQ^TQ=I. This is why changing between any two orthonormal coordinate frames gives an orthogonal matrix.

Converting a velocity

Drone coordinates a,b,ca,b,c mean aa times its forward unit vector, plus bb times its left unit vector, plus cc times its body-up unit vector. Matrix multiplication forms exactly this combination of the columns of QQ:

v⃗ground⏟east, north, up=Q[510]⏟forward, left, body up=[−143].\underbrace{\vec v_{\text{ground}}}_{\text{east, north, up}} =Q\underbrace{\begin{bmatrix}5\\1\\0\end{bmatrix}}_{\text{forward, left, body up}} =\begin{bmatrix}-1\\4\\3\end{bmatrix}.

A velocity of 5 m/s forward and 1 m/s left is therefore 1 m/s west, 4 m/s north, and 3 m/s upward. Both descriptions give speed 26\sqrt{26} m/s. We have changed the coordinates, not the physical velocity.

Converting back

Suppose we want a velocity of 5 m/s vertically upward. Since Q−1=QTQ^{-1}=Q^T, its drone coordinates are

v⃗drone=QT[005]=[304].\vec v_{\text{drone}}=Q^T\begin{bmatrix}0\\0\\5\end{bmatrix}=\begin{bmatrix}3\\0\\4\end{bmatrix}.

This velocity has a forward component of 3 m/s and a body-up component of 4 m/s. The horizontal contributions cancel, leaving only vertical motion. The two conversion rules are

v⃗ground=Qv⃗drone,v⃗drone=QTv⃗ground.\boxed{\vec v_{\text{ground}}=Q\vec v_{\text{drone}},\qquad \vec v_{\text{drone}}=Q^T\vec v_{\text{ground}}.}

Adding a camera

A camera mounted on the drone has its own forward, left, and up directions. Let CC have as columns the camera’s three unit directions expressed in drone coordinates. Then CC converts camera coordinates into drone coordinates. It is orthogonal for the same reason as QQ: the camera’s axes are perpendicular unit directions.

To describe a viewing direction in ground coordinates, first convert from camera to drone coordinates, then from drone to ground coordinates:

v⃗drone=Cv⃗camera,v⃗ground=Qv⃗drone=QCv⃗camera.\vec v_{\text{drone}}=C\vec v_{\text{camera}},\qquad \vec v_{\text{ground}}=Q\vec v_{\text{drone}}=QC\vec v_{\text{camera}}.

This explains the order in QCQC: CC acts first. The product is orthogonal because it converts from one orthonormal frame to another.

For example, aim the camera halfway between the drone’s forward and left directions, then tilt its lens 45∘45^\circ downward relative to the drone. Keep the camera’s left axis in the drone’s forward-left plane. Its forward, left, and up unit directions give

C=[1/2−1/21/21/21/21/2−1/201/2].C=\begin{bmatrix} 1/2&-1/\sqrt2&1/2\\ 1/2&1/\sqrt2&1/2\\ -1/\sqrt2&0&1/\sqrt2 \end{bmatrix}.

The first column describes the lens direction: equally forward and left, and downward. Multiplying gives

QC=[−1/2−1/2−1/22/5+3/(52)−4/(52)2/5−3/(52)3/10−4/(52)−3/(52)3/10+4/(52)].QC=\begin{bmatrix} -1/2&-1/\sqrt2&-1/2\\ 2/5+3/(5\sqrt2)&-4/(5\sqrt2)&2/5-3/(5\sqrt2)\\ 3/10-4/(5\sqrt2)&-3/(5\sqrt2)&3/10+4/(5\sqrt2) \end{bmatrix}.

All nine entries are nonzero. Each camera axis now has east-west, north-south, and vertical components in ground coordinates.

The direction straight ahead through the lens has camera coordinates [100]\begin{bmatrix}1\\0\\0\end{bmatrix}, so its ground coordinates are the first column of QCQC. The signs tell us that the lens points west, north, and downward. With the camera fixed to the drone, CC stays the same as the drone turns, while QQ changes. Their product tells us where the camera is looking.


Will the damaged connection be in the picture?

A drone is inspecting a tower. Its camera is at ground coordinates

p⃗=[261425] m,and a damaged connection is att⃗=[203012] m.\vec p=\begin{bmatrix}26\\14\\25\end{bmatrix}\text{ m},\qquad \text{and a damaged connection is at}\qquad \vec t=\begin{bmatrix}20\\30\\12\end{bmatrix}\text{ m}.

The coordinates are east, north, and height. Use the orientation matrices QQ and CC above. Model the camera’s field of view as a cone: an unobstructed point appears in the picture if its direction is within 20∘20^\circ of the direction straight ahead through the lens.

Question: Find the displacement from the camera to the connection in camera coordinates. Will the connection appear in the picture? If not, through what smallest angle must the camera turn to put it at the center of the picture? Assume the drone stays fixed and the camera can turn freely.

Solution: First subtract the positions to get the displacement in ground coordinates:

d⃗ground=t⃗−p⃗=[−616−13].\vec d_{\text{ground}}=\vec t-\vec p=\begin{bmatrix}-6\\16\\-13\end{bmatrix}.

The connection is 6 m west, 16 m north, and 13 m below the camera. To express this displacement in camera coordinates, reverse the two conversions. Apply QTQ^T first, then CTC^T:

d⃗drone=QT[−616−13]=[56−20],\vec d_{\text{drone}}=Q^T\begin{bmatrix}-6\\16\\-13\end{bmatrix}=\begin{bmatrix}5\\6\\-20\end{bmatrix},
d⃗camera=CT[56−20]=[11/2+1021/211/2−102]≈[19.640.71−8.64].\vec d_{\text{camera}}=C^T\begin{bmatrix}5\\6\\-20\end{bmatrix} =\begin{bmatrix}11/2+10\sqrt2\\1/\sqrt2\\11/2-10\sqrt2\end{bmatrix} \approx\begin{bmatrix}19.64\\0.71\\-8.64\end{bmatrix}.

Relative to the camera, the connection is ahead, a little to the left, and below. Being ahead does not by itself mean it will be in the picture: we need the angle from the lens direction.

In camera coordinates, the lens points along e⃗1\vec e_1. The distance to the connection is 461\sqrt{461} m in ground coordinates. Orthogonality tells us that its length is the same in camera coordinates. Thus, the angle α\alpha satisfies

cos⁡α=e⃗1⋅d⃗camera∥d⃗camera∥=11/2+102461,α≈23.82∘.\cos\alpha=\frac{\vec e_1\cdot\vec d_{\text{camera}}}{\|\vec d_{\text{camera}}\|} =\frac{11/2+10\sqrt2}{\sqrt{461}},\qquad \alpha\approx23.82^\circ.

The connection is outside the picture, since 23.82∘>20∘23.82^\circ>20^\circ. To center it, turn the camera through 23.82∘23.82^\circ toward the connection, mostly downward and slightly left. Turning just 3.82∘3.82^\circ toward it would bring it to the edge of the picture.