A749 of 56
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

A7 · Lesson 49 · Rotations, reflections and coordinate frames

Orthogonal matrices at work, from a phone's accelerometer to a radio's constellation

A phone's accelerometer measures along the phone's own axes. To know which way is down in the room, the reading has to be turned into the room's coordinates. A robot arm chains a rotation and a shift for every joint, and a radio receiver turns its whole constellation back by the carrier's phase error. All of these are orthogonal matrices (lesson 24): matrices whose columns are perpendicular unit vectors, so they move vectors without stretching them. In three dimensions they also have a habit that 2D rotations don't: the order you apply them in matters.

  • The first arrow is a vector 𝐱; the second is 𝐱 rotated by the angle ;thethirdis\mathbf{x}reflectedinthemirrorlineatangle.
  • All three keep the same length. Turning the rotation through a full circle brings it back; moving the mirror swings the reflection twice as fast, because a reflection doubles the angle between the vector and the mirror.

Predict

Rotate the vector (1,0,0) by 90° about the x axis, then 90° about the z axis. Now do it in the other order. Do you land in the same place?

Name it

Orthogonal matrices

Q is orthogonal when QTQ=I. Then:

  • Q−1=QT, so undoing it costs nothing;
  • |Q𝐱|=|𝐱| and angles are kept;
  • det⁡Q=±1: +1 for a rotation, −1 for a reflection.

Rotations

In the plane, R(θ)=[cos⁡θ−sin⁡θsin⁡θcos⁡θ] turns vectors counterclockwise by θ. In space, the rotations about the coordinate axes are

Rx(θ)=[1000c−s0sc]Ry(θ)=[c0s010−s0c]Rz(θ)=[c−s0sc0001]

with c=cos⁡θ, s=sin⁡θ. A product RzRyRx applies Rx first. Every 3D rotation turns about some axis by some angle θ, and its trace gives the angle: trR=1+2cos⁡θ.

Reflections

The Householder reflection across the plane perpendicular to a unit vector 𝐮 is

H=I−2𝐮𝐮T

It sends 𝐮 to −𝐮 and leaves every vector perpendicular to 𝐮 alone. H is symmetric and orthogonal, so H2=I. Choosing 𝐮 along 𝐱−|𝐱|𝐞1 reflects 𝐱 onto the first axis, the step that QR factorization (lesson 28) repeats column by column in numerical libraries.

Coordinate frames

A sensor mounted on a robot is rotated by R and shifted by 𝐭 from the robot's frame, so a point 𝐩s it measures sits at R𝐩s+𝐭. Stacking both into one 4×4 homogeneous matrix makes the shift a matrix product too:

T=[R𝐭𝟎T1]T[𝐩1]=[R𝐩+𝐭1]T−1=[RT−RT𝐭𝟎T1]

A chain of joints is a product of such matrices, read right to left from the tool back to the base.

Worked example

A phone lies rolled 30° about its own x axis. Its accelerometer reads (0,−4.905,−8.496) m/s² in the phone's axes. What is that in the room's axes, where the phone's frame is Rx(30°) relative to the room?

Show the solution
  1. Multiply by Rx(30°). The first entry stays 0, and the second is 0.866(−4.905)+0.5(8.496)=0
  2. Third entry. 0.5(−4.905)+0.866(−8.496)=−9.81
  3. Read the result. [00−9.81] Straight down at 9.81 m/s²: gravity, as it should be for a phone at rest.
  4. Going the other way. From the room to the phone uses Rx(30°)T, the inverse for free. This is the first step of every orientation filter.

Answer (0,0,−9.81) m/s² in the room's axes: gravity, straight down.

Worked example

Find the Householder reflection that sends 𝐱=(3,4) onto the first axis.

Show the solution
  1. Aim for the axis. |𝐱|=5, so aim for (5,0): 𝐮∝𝐱−(5,0)=(−2,4) which normalizes to (−0.447,0.894).
  2. Build H. H=I−2𝐮𝐮T=[1−0.40.80.81−1.6]=[0.60.80.8−0.6]
  3. Check. H(3,4)=(1.8+3.2,2.4−2.4)=(5,0) det⁡H=−0.36−0.64=−1 a reflection.
  4. The mirror. It's the line through the origin halfway between 𝐱 and (5,0), so 𝐱 lands on the axis with its length unchanged.

Answer H=[0.60.80.8−0.6].

Worked example

A rotation is R=Rz(40°)Rx(25°). By what single angle does it turn space, about its own axis?

Show the solution
  1. Diagonal of R. Multiplying out, the diagonal is cos⁡40°, cos⁡40°cos⁡25° and cos⁡25°: 0.766, 0.694 and 0.906, so trR=2.367
  2. Angle from the trace. 1+2cos⁡θ=2.367 gives cos⁡θ=0.683 and θ=46.9°.
  3. Compare. Two turns of 40° and 25° about different axes add up to one turn of 46.9°, less than their sum because the axes aren't the same.

Answer it turns space by 46.9° about its own axis.

Check

Rotate the vector (2,1) counterclockwise by 120°. What is the new x component?

Check

A 3D rotation matrix has trace 2.5. Through what angle does it rotate?

Check

Write Rx(t), Ry(t) and Rz(t) returning the 3D rotation matrices for an angle in degrees. Set R = Rz(a) @ Ry(b) @ Rx(c) with a = 35, b = 20, c = 60; ortho to the largest entry of |RTR−I|; det to its determinant; v to R @ [1, 2, 3]; and gap to the distance between v and Rx(c) @ Ry(b) @ Rz(a) @ [1, 2, 3].

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Write householder(x) returning the reflection H=I−2𝐮𝐮T with 𝐮 the unit vector along 𝐱−|𝐱|𝐞1, so that H𝐱=|𝐱|𝐞1. Set H = householder(x) for the starter's random 4-vector, Hx = H @ x, and detH to its determinant.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

A lidar is mounted on a robot at t = (0.1, 0, 0.3) m, turned by yaw = 150° about the robot's z axis. Build its 4×4 homogeneous transform T from lidar to robot, set pw to the robot-frame position of the lidar point (2, 0, 0), Tinv to the inverse built from RT and −RT𝐭, and back to Tinv applied to pw.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

A receiver expects a symbol at amplitude 1 and angle 20°, but a carrier phase error of −25° has turned the whole constellation. It received (I,Q)=(1cos⁡(20°+−25°),1sin⁡(20°+−25°)). Rotate it back by −−25°.

(a)

What is the corrected I?

(b)

What is the corrected Q?

Check

Q is a real orthogonal 3×3 matrix with det⁡Q=−1. What does it do?

Check

Show that turning by b and then by a in the plane is a single turn by a+b.

Step 1

What is the top-left entry of R(a)R(b)?

Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.

Explain why

Why is the inverse of a rotation matrix just its transpose? What does that save in practice?

Practice

Keep practicing

8 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.