How a screen turns a cube
Tonight's idea
A 3D model is a list of points. Take the cube with corners \((\pm 1, \pm 1, \pm 1)\): eight points. To turn it, multiply every point by a rotation matrix. In Matrices that move the plane a 2 × 2 matrix turned the plane through \(\theta\). Turning space about the \(z\)-axis does the same to \(x\) and \(y\) and leaves \(z\) alone:
\[R_z(\theta) = \begin{pmatrix}\cos\theta & -\sin\theta & 0\\ \sin\theta & \cos\theta & 0\\ 0 & 0 & 1\end{pmatrix}, \qquad R_z(\theta)\begin{pmatrix}x\\y\\z\end{pmatrix} = \begin{pmatrix}x\cos\theta - y\sin\theta\\ x\sin\theta + y\cos\theta\\ z\end{pmatrix}.\]
A screen is flat, so one coordinate has to go. The simplest way is orthographic projection: drop \(z\) and plot \((x, y)\). It is the view from far away along the \(z\)-axis.
Points → multiply by a rotation matrix → drop \(z\) → join the dots.
Turn about \(z\) and look along \(z\), and you see only a turning square: each top corner hides the one below. To see depth, tilt about \(x\) as well, which mixes \(y\) and \(z\):
\[R_x(\theta) = \begin{pmatrix}1 & 0 & 0\\ 0 & \cos\theta & -\sin\theta\\ 0 & \sin\theta & \cos\theta\end{pmatrix}.\]
Watch one: turn the cube 30° about \(z\)
Here \(\cos 30° \approx 0.866\) and \(\sin 30° = 0.5\). The corner \((1, 1, 1)\) goes to
\[(0.866 - 0.5,\; 0.5 + 0.866,\; 1) = (0.37,\; 1.37,\; 1).\]
Drop \(z\): it is drawn at \((0.37, 1.37)\). The corner below it, \((1, 1, -1)\), is drawn at the same place. The other top corners \((-1, 1, 1)\), \((-1, -1, 1)\), \((1, -1, 1)\) land at \((-1.37, 0.37)\), \((-0.37, -1.37)\), \((1.37, -0.37)\). Join them and you have the left-hand picture: a square turned through 30°.
Drag a cube around and watch its matrix change: mathdetours.com/demos/cube3d.html.
Your turn
- Write out \(R_z(90°)\). Apply it to \((1, 1, 1)\) and to \((1, -1, -1)\). Where is each drawn on the screen?
- Apply \(R_z(45°)\) to the four top corners \((1,1,1)\), \((-1,1,1)\), \((-1,-1,1)\), \((1,-1,1)\). Give exact screen coordinates and describe the picture.
- A rotation must not stretch the model. Show that \((x\cos\theta - y\sin\theta)^2 + (x\sin\theta + y\cos\theta)^2 = x^2 + y^2\), and say why this means \(R_z\) keeps every point at the same distance from the origin.
- After \(R_z(45°)\), the corners \((1,1,1)\) and \((1,1,-1)\) are at \((0, \sqrt2, 1)\) and \((0, \sqrt2, -1)\), and are drawn on top of each other. Apply \(R_x(60°)\) to both, then drop \(z\). Where are they drawn now? The edge joining them has length 2. How long does it look on the screen, and why?
Stretch: order matters
Take the point \((1, 0, 0)\). Turn it 90° about \(z\), then 90° about \(x\). Start again and do the \(x\) turn first, then the \(z\) turn. Where does the point finish each time? What does this say about \(R_xR_z\) and \(R_zR_x\)?
Answers
- \(R_z(90°) = \begin{pmatrix}0 & -1 & 0\\ 1 & 0 & 0\\ 0 & 0 & 1\end{pmatrix}\), which sends \((x, y, z)\) to \((-y, x, z)\). So \((1,1,1) \to (-1,1,1)\), drawn at \((-1, 1)\), and \((1,-1,-1) \to (1,1,-1)\), drawn at \((1, 1)\).
- With \(\cos 45° = \sin 45° = \tfrac{\sqrt2}{2}\): \((1,1,1) \to (0, \sqrt2)\), \((-1,1,1) \to (-\sqrt2, 0)\), \((-1,-1,1) \to (0, -\sqrt2)\), \((1,-1,1) \to (\sqrt2, 0)\). A square standing on a corner, with its corners on the axes. Its side is still 2.
- Expanding gives \(x^2\cos^2\theta - 2xy\sin\theta\cos\theta + y^2\sin^2\theta + x^2\sin^2\theta + 2xy\sin\theta\cos\theta + y^2\cos^2\theta\). The middle terms cancel and \(\cos^2\theta + \sin^2\theta = 1\), leaving \(x^2 + y^2\). Since \(z\) is unchanged, \(x^2 + y^2 + z^2\) is unchanged, and that is the squared distance from the origin.
- \(R_x(60°)\) sends \((x, y, z)\) to \((x,\; 0.5y - 0.866z,\; 0.866y + 0.5z)\). So \((0, \sqrt2, 1) \to (0, -0.16, 1.72)\), drawn at \((0, -0.16)\), and \((0, \sqrt2, -1) \to (0, 1.57, 0.72)\), drawn at \((0, 1.57)\). The edge looks \(1.57 + 0.16 = 1.73 = 2\sin 60°\) long. It has tipped 60° out of the line of sight, so you see it foreshortened: only the part of it across your view shows.
Stretch. \(z\) first: \((1,0,0) \to (0,1,0)\), then the \(x\) turn sends it to \((0,0,1)\). \(x\) first: \((1,0,0)\) lies on the \(x\)-axis so it stays put, then the \(z\) turn sends it to \((0,1,0)\). Different finishes, so \(R_xR_z \ne R_zR_x\). Rotations in space do not commute, unlike rotations of the plane.