6.4 The Geometry of Linear Maps in the Plane
Rotations, reflections, projections, stretches and shears are all $2\times2$ matrices. Composing maps multiplies their matrices (order matters), $|\det A|$ is the area scale factor, the sign of $\det A$ tells you whether the picture is flipped, and $3\times3$ homogeneous matrices bring translations into the same framework.
Every time you rotate a photo on your phone, mirror a selfie, zoom a map or watch an animated character walk across the screen, a computer is applying a $2\times2$ (or $3\times3$) matrix to thousands of points. Graphics designers, robot engineers and game developers do not think of these as "matrices with entries $a,b,c,d$" โ they think of rotate by $30^\circ$, reflect in this line, squash vertically, shear sideways. This section builds a dictionary between the two languages.
The key fact from Section 6.1 is that a linear map $T:\mathbb{R}^2\to\mathbb{R}^2$ is completely determined by where it sends $\mathbf{e}_1=(1,0)$ and $\mathbf{e}_2=(0,1)$: the standard matrix is $A=\begin{bmatrix}T(\mathbf{e}_1)&T(\mathbf{e}_2)\end{bmatrix}$. So to find the matrix of any geometric map, just ask "where do the two unit vectors go?" We will also see how a single number, $\det A$, measures how the map changes area and whether it turns the plane over, and how one extra coordinate lets matrices handle translations โ the move that linear maps cannot make on their own.
Rotations, Reflections and Projections
Rotating $\mathbf{e}_1=(1,0)$ anticlockwise through the angle $\theta$ lands it on $(\cos\theta,\sin\theta)$; rotating $\mathbf{e}_2=(0,1)$ lands it on $(-\sin\theta,\cos\theta)$, a quarter turn further on. Those are the two columns of the rotation matrix. For a line $\ell$ through the origin, the orthogonal projection onto $\ell$ is $\operatorname{proj}_{\mathbf{u}}\mathbf{v}=(\mathbf{v}\cdot\mathbf{u})\,\mathbf{u}$ for a unit vector $\mathbf{u}$ along $\ell$ (Section 4.2), and the reflection in $\ell$ goes from $\mathbf{v}$ to its projection and then the same distance again: $F(\mathbf{v})=2\operatorname{proj}_{\mathbf{u}}\mathbf{v}-\mathbf{v}$.
Let $\theta$ be a real number and let $\ell_\theta$ be the line through the origin making angle $\theta$ with the positive $x$-axis (unit direction $\mathbf{u}=(\cos\theta,\sin\theta)$). The following maps of $\mathbb{R}^2$ are linear, with standard matrices
$$R_\theta=\begin{bmatrix}\cos\theta&-\sin\theta\\\sin\theta&\cos\theta\end{bmatrix}\ \ (\text{rotation by }\theta\text{ anticlockwise about }\mathbf{0}),$$ $$F_\theta=\begin{bmatrix}\cos2\theta&\sin2\theta\\\sin2\theta&-\cos2\theta\end{bmatrix}\ \ (\text{reflection in }\ell_\theta),\qquad P_\theta=\begin{bmatrix}\cos^2\theta&\sin\theta\cos\theta\\\sin\theta\cos\theta&\sin^2\theta\end{bmatrix}\ \ (\text{projection onto }\ell_\theta).$$
If the line is given by a non-zero direction vector $(a,b)$ instead of an angle, $$P=\frac{1}{a^2+b^2}\begin{bmatrix}a^2&ab\\ab&b^2\end{bmatrix},\qquad F=2P-I=\frac{1}{a^2+b^2}\begin{bmatrix}a^2-b^2&2ab\\2ab&b^2-a^2\end{bmatrix}.$$
Special cases worth knowing by heart: reflection in the $x$-axis $\begin{bmatrix}1&0\\0&-1\end{bmatrix}$ ($\theta=0$), in the $y$-axis $\begin{bmatrix}-1&0\\0&1\end{bmatrix}$ ($\theta=90^\circ$), in $y=x$ $\begin{bmatrix}0&1\\1&0\end{bmatrix}$ (swap the coordinates), in $y=-x$ $\begin{bmatrix}0&-1\\-1&0\end{bmatrix}$; projection onto the $x$-axis $\begin{bmatrix}1&0\\0&0\end{bmatrix}$; rotation by $90^\circ$ $\begin{bmatrix}0&-1\\1&0\end{bmatrix}$ and by $180^\circ$, $-I$.
Stretches, Dilations and Shears
- Scaling (stretch or compression along the axes): $\begin{bmatrix}k_1&0\\0&k_2\end{bmatrix}$, $k_1,k_2\gt0$. With $k_2=1$ it stretches ($k_1\gt1$) or compresses ($0\lt k_1\lt1$) horizontally only.
- Dilation ($k\gt1$) or contraction ($0\lt k\lt1$) by the factor $k$: $kI=\begin{bmatrix}k&0\\0&k\end{bmatrix}$ โ every vector is multiplied by $k$.
- Horizontal shear with factor $k$: $\begin{bmatrix}1&k\\0&1\end{bmatrix}$, so $(x,y)\mapsto(x+ky,\,y)$ โ each point slides horizontally by an amount proportional to its height.
- Vertical shear with factor $k$: $\begin{bmatrix}1&0\\k&1\end{bmatrix}$, so $(x,y)\mapsto(x,\,y+kx)$.
A shear turns the unit square into a parallelogram with the same base and the same height โ so it keeps area, even though it changes every angle. Shears appear when a deck of cards is pushed sideways, when italic letters are generated from upright ones, and in the deformation of soil and fluids.
Composing Maps: Order Matters
Doing one map after another is again a linear map, and its matrix is the product of the matrices (Section 6.1). Because we write functions on the left, $S\circ T$ means "first $T$, then $S$", and its matrix is $[S][T]$ โ the first map is on the right.
If $T,S:\mathbb{R}^2\to\mathbb{R}^2$ are linear with standard matrices $A$ and $B$, then $S\circ T$ ("first $T$, then $S$") is linear with standard matrix $BA$. In general $BA\ne AB$. In particular, for all real $\alpha,\beta,\theta,\varphi$: $$R_\alpha R_\beta=R_{\alpha+\beta}\ \ (\text{rotations add, and commute}),\qquad F_\varphi F_\theta=R_{2(\varphi-\theta)}\ \ (\text{two reflections make a rotation}).$$
The first identity is the addition formulas for sine and cosine in disguise; multiply out $R_\alpha R_\beta$ and compare (Exercise III.3). The second explains why two mirrors at an angle produce a rotated image, as in a kaleidoscope.
Area, Orientation and the Determinant
A linear map sends the unit square (spanned by $\mathbf{e}_1$, $\mathbf{e}_2$) to the parallelogram spanned by the columns $A\mathbf{e}_1$, $A\mathbf{e}_2$, whose area is $|\det A|$ (Section 3.3). Every other region can be filled with tiny squares, each of which is scaled in the same way, so the whole region is scaled by the same factor. The sign of $\det A$ records something area cannot: whether the turn from $A\mathbf{e}_1$ to $A\mathbf{e}_2$ is still anticlockwise.
Let $T:\mathbb{R}^2\to\mathbb{R}^2$ be linear with standard matrix $A$, and let $S$ be a region of the plane with finite area (a polygon, a disc, โฆ). Then $$\operatorname{area}\big(T(S)\big)=|\det A|\cdot\operatorname{area}(S).$$ Moreover, if $\det A\gt0$ then $T$ preserves orientation (anticlockwise stays anticlockwise; a letter F still reads as F); if $\det A\lt0$ then $T$ reverses orientation (the F appears mirrored); and if $\det A=0$ then $T$ squashes the plane onto a line or a point, and every region has image of area $0$.
A quick reference: rotations $\det R_\theta=1$; reflections $\det F_\theta=-\cos^22\theta-\sin^22\theta=-1$; projections $\det P_\theta=0$; shears $1$; scalings $k_1k_2$; dilations $k^2$. Since $\det(BA)=\det B\det A$, area factors multiply under composition and two orientation reversals cancel out.
1. Multiplying in the wrong order. "First $A$, then $B$" has matrix $BA$, not $AB$. Read products right to left, like function composition $B(A\mathbf{x})$.
2. Using $\theta$ instead of $2\theta$ in a reflection. The reflection in the line at angle $\theta$ has $\cos2\theta$ and $\sin2\theta$ in its matrix. Test it: the line at $45^\circ$ must give $\begin{bmatrix}0&1\\1&0\end{bmatrix}$.
3. Confusing projection with reflection. A projection is not invertible ($\det=0$, $P^2=P$); a reflection is its own inverse ($\det=-1$, $F^2=I$).
4. Forgetting the absolute value. The area scale factor is $|\det A|$; a negative determinant does not mean "negative area" but "flipped over".
5. Treating translation as linear. $\mathbf{x}\mapsto\mathbf{x}+\mathbf{h}$ sends $\mathbf{0}$ to $\mathbf{h}\ne\mathbf{0}$, so no $2\times2$ matrix can do it โ see the next subsection.
Homogeneous Coordinates: Translations for Computer Graphics
A translation $\mathbf{x}\mapsto\mathbf{x}+\mathbf{h}$ is not linear when $\mathbf{h}\ne\mathbf{0}$, because it moves the origin. Yet graphics software wants every move โ rotate, scale, translate โ to be "multiply by a matrix", so that a whole chain of moves can be stored as one matrix and applied to millions of points. The trick is to add a third coordinate that is always $1$.
The point $(x,y)$ of the plane is represented by the vector $(x,y,1)$ in $\mathbb{R}^3$, its homogeneous coordinates. A $2\times2$ matrix $A$ and a translation by $\mathbf{h}=(h,k)$ are represented by the $3\times3$ matrices $$\begin{bmatrix}A&\mathbf{0}\\\mathbf{0}^{T}&1\end{bmatrix}=\begin{bmatrix}a_{11}&a_{12}&0\\a_{21}&a_{22}&0\\0&0&1\end{bmatrix},\qquad T_{(h,k)}=\begin{bmatrix}1&0&h\\0&1&k\\0&0&1\end{bmatrix}.$$
Indeed $T_{(h,k)}\begin{bmatrix}x\\y\\1\end{bmatrix}=\begin{bmatrix}x+h\\y+k\\1\end{bmatrix}$. A chain of moves is represented by the product of their $3\times3$ matrices, with the first move on the right; the last row stays $(0,0,1)$, so the result always has third coordinate $1$.
- Translate the special point $\mathbf{p}$ (centre of rotation, centre of scaling, a point on the mirror line) to the origin: $T_{-\mathbf{p}}$.
- Apply the linear map about the origin: $\begin{bmatrix}A&\mathbf{0}\\\mathbf{0}^{T}&1\end{bmatrix}$.
- Translate back: $T_{\mathbf{p}}$. The whole map is $M=T_{\mathbf{p}}\begin{bmatrix}A&\mathbf{0}\\\mathbf{0}^{T}&1\end{bmatrix}T_{-\mathbf{p}}$.
- Check that $M$ fixes $\mathbf{p}$ (it must), and test one more point.
Exercises
- 1 Rotation anticlockwise by $30^\circ$.
- 2 Rotation clockwise by $90^\circ$.
- 3 Reflection in the $y$-axis.
- 4 Reflection in the line $y=-x$.
- 5 Reflection in the line $y=\sqrt3\,x$.
- 6 Orthogonal projection onto the line $y=-2x$.
- 7 Horizontal shear with factor $-3$.
- 8 Vertical compression by the factor $\tfrac12$ (horizontal lengths unchanged).
- 1 Find the image of $(3,4)$ under the rotation by $90^\circ$.
- 2 Find the image of $(2,-1)$ under the reflection in $y=x$.
- 3 Project $(5,5)$ onto the line through the origin with direction $(3,4)$.
- 4 Reflect $(5,5)$ in the same line, and check that the length is unchanged.
- 5 Describe the map with matrix $\begin{bmatrix}0&3\\-3&0\end{bmatrix}$.
- 6 Describe the map with matrix $\begin{bmatrix}\tfrac12&\tfrac{\sqrt3}{2}\\\tfrac{\sqrt3}{2}&-\tfrac12\end{bmatrix}$.
- 7 Describe the map with matrix $\begin{bmatrix}\tfrac12&\tfrac12\\\tfrac12&\tfrac12\end{bmatrix}$.
- 1 Find the matrix of "rotate by $90^\circ$, then dilate by $2$".
- 2 Find the matrices of "horizontal shear with $k=1$, then reflect in the $x$-axis" and of the same two maps in the opposite order. Are they equal?
- 3 Show that $R_\alpha R_\beta=R_{\alpha+\beta}$, and explain why rotations of the plane commute.
- 4 Find the matrix of "reflect in the $x$-axis, then reflect in $y=x$" and identify the map. Compare with $F_\varphi F_\theta=R_{2(\varphi-\theta)}$.
- 5 For the line with direction $(3,4)$, verify that $P^2=P$ and $F^2=I$, and explain each geometrically.
- 6 Without multiplying out, find $\left(R_{45^\circ}\right)^3$ and the smallest $n\ge1$ with $\left(R_{45^\circ}\right)^n=I$.
- 7 Let $P$ be the projection onto the $x$-axis and $R$ the rotation by $90^\circ$. Compute $PR$ and $RP$ and describe each.
- 1 The triangle with vertices $(0,0)$, $(2,0)$, $(1,3)$ is mapped by $A=\begin{bmatrix}3&1\\1&2\end{bmatrix}$. Find the area of the image in two ways.
- 2 Which of these preserve orientation: a rotation, a reflection, a shear, a projection, $\begin{bmatrix}2&5\\1&3\end{bmatrix}$?
- 3 A square of area $4$ is mapped by $\begin{bmatrix}1&2\\3&4\end{bmatrix}$. Find the area of the image and say whether it is flipped.
- 4 For which real $k$ does $\begin{bmatrix}k&2\\2&k\end{bmatrix}$ reverse orientation? For which $k$ does it flatten the plane?
- 5 Printing. A logo of area $12$ cmยฒ is printed on a T-shirt after being transformed by $\begin{bmatrix}1.5&0.5\\0&2\end{bmatrix}$ (lengths in cm). What area of fabric does the printed logo cover, and will the lettering read correctly?
- 1 Translation by $(-3,5)$.
- 2 Rotation by $90^\circ$ about the point $(1,1)$.
- 3 Dilation by the factor $2$ centred at the point $(3,2)$.
- 4 Reflection in the line $y=x+1$. (Hint: translate a point of the line to the origin.)
- 5 Game design. A sprite is moved by "translate by $(4,0)$" and "rotate by $90^\circ$ about the origin". Find the combined matrix for each order and the two images of the sprite's corner $(1,1)$.
Research question. How does an industrial robot arm know where its gripper is? Engineers chain $3\times3$ homogeneous matrices โ one rotation and one translation per joint โ and this "forward kinematics" runs thousands of times a second in factories, surgical robots and planetary rovers.
Why it matters. A planar arm with two links of lengths $L_1$, $L_2$ and joint angles $\theta_1$, $\theta_2$ places its gripper at the point given by $M=R_{\theta_1}T_{(L_1,0)}R_{\theta_2}T_{(L_2,0)}$ applied to $(0,0,1)$: rotate at the shoulder, move along the first link, rotate at the elbow, move along the second link. Order matters exactly as in Theorem 6.15.
What to do.
- Sample case: $L_1=0.4$ m, $L_2=0.3$ m, $\theta_1=30^\circ$, $\theta_2=45^\circ$. Write the four $3\times3$ matrices and multiply them (by hand or in a spreadsheet).
- Read off the gripper position from the last column of $M$ and compare with the formula $\left(L_1\cos\theta_1+L_2\cos(\theta_1+\theta_2),\ L_1\sin\theta_1+L_2\sin(\theta_1+\theta_2)\right)$.
- Explain why the top-left $2\times2$ block of $M$ is $R_{\theta_1+\theta_2}$ and what it tells you about the gripper's direction.
- Describe the set of all positions the gripper can reach as $\theta_1$, $\theta_2$ vary (hint: an annulus) and give its inner and outer radii.
Tools: Calculator or spreadsheet; optionally Python with numpy
Hand in: The product matrix, the gripper position to the nearest millimetre, a sketch of the arm, and the reachable region.
Going further. The inverse problem โ which angles put the gripper at a given point? โ needs the cosine rule and usually has two solutions ("elbow up" and "elbow down"). Real robots use $4\times4$ homogeneous matrices for 3-D motion (the DenavitโHartenberg convention); the same idea runs every 3-D game engine and the camera models in self-driving cars.
๐งช Self-check quiz
Q1. The anticlockwise rotation of the plane by $\theta$ has matrix
Q2. The determinant of any reflection of the plane in a line through the origin is
Q3. The orthogonal projection onto the $x$-axis sends the unit square to a figure of area
Q4. With $R=\begin{bmatrix}0&-1\\1&0\end{bmatrix}$ (rotation by $90^\circ$) and $F=\begin{bmatrix}1&0\\0&-1\end{bmatrix}$ (reflection in the $x$-axis), the matrix of "first rotate, then reflect" is
Q5. Why do computer-graphics programs use $3\times3$ matrices for moves of the plane?