Imagine an autonomous car approaching a busy intersection at night. Its roof-mounted LiDAR catches a cluster of reflections and identifies a pedestrian: 12 meters forward, 1 meter to the left. A moment later, the motion planner must decide whether that person is entering the car’s path. But there is a hidden problem. The LiDAR described the pedestrian relative to the sensor, while the planner reasons relative to the vehicle, and the navigation system tracks both of them on a world map.
At a fixed instant, the pedestrian has not moved; only the coordinate description has changed. To connect what the sensor sees with where the vehicle believes it is, we need to carry the measurement through a chain of coordinate frames. One link comes from calibration, which tells us how the LiDAR is mounted on the car. Another comes from localization, which tells us where the car is in the world. If either link is inverted or composed in the wrong order, a pedestrian on the sidewalk can appear in the road.
The same pedestrian detection must travel from the LiDAR frame, through the vehicle frame, and into the world frame before the motion planner can use it.
This is why poses and transforms sit at the foundation of machine perception. We will build the geometry from first principles: how a pose relates two frames, how a rigid transform rotates and translates coordinates, how transforms compose, and how rotation representations affect interpolation and random sampling.
These notes follow Shenlong Wang’s CS 498, Lecture 2: Poses, Coordinates, Transforms and Rotations.1 We use column vectors, right-handed frames, and radians unless degrees are explicitly marked. The lecture’s diagrams are reproduced selectively below, with slide numbers in their captions.
The one sentence to remember
A pose tells us where one coordinate frame is located and how it is rotated relative to another frame. A transform uses that position and rotation to convert a point’s coordinates from one frame into the other.
0. The Vector Operations We Need
A vector has components, a length, and a direction. A matrix represents a linear transformation of those components. Two operations explain most of the geometry in this note.
The dot product measures alignment:
For nonzero vectors, the dot product is zero when they are perpendicular, positive when they point generally the same way, and negative when they point generally opposite ways.
The cross product in three dimensions gives a vector perpendicular to both inputs:
Its magnitude is the area of the parallelogram spanned by the inputs, and its direction follows the right-hand rule. These formulas answer the prerequisite questions on slide 4:
| Relationship between nonzero vectors | Dot product | Cross product |
|---|---|---|
| Perpendicular | Perpendicular to both; magnitude | |
| Parallel, same direction | ||
| Parallel, opposite directions |
A right-handed orthonormal frame satisfies . Point your right thumb along a positive rotation axis; the curl of your fingers gives the positive rotation direction. Which axis points forward or upward is a separate convention, not something guaranteed by the words “right-handed.”
1. Coordinate Frames and Poses
A coordinate frame consists of an origin and an ordered set of perpendicular axes. The same physical point has different coordinates in different frames. For example, a pedestrian may be at in a LiDAR frame but at in a world frame. Neither vector is the pedestrian’s absolute identity; each is a description relative to a chosen origin and basis.
A rigid body’s pose combines:
- position: where the body-frame origin is located; and
- orientation: how the body-frame axes are aligned.
“Rigid” means the distances between points on the object remain fixed. Its pose locates the object at one instant; a full dynamical state may also include velocity.
It helps to start in two dimensions. A car’s reference point needs two coordinates , and its heading needs one angle :
These are three degrees of freedom, meaning three independently variable quantities. Attaching axes to the car creates its body frame: both the origin and axes move with the car. A point bolted to the car has constant body coordinates even when its world coordinates change.
The car carries a local origin and two axes. Its planar pose needs two translations and one orientation angle. Source: Lecture 2, slide 13.1 The primed axes in this figure are the body axes; our equations use explicit frame labels.
In three dimensions, a free rigid body has six degrees of freedom: three translations and three rotations. A pose is often represented computationally by a rotation matrix and a translation vector .
For intuition, we can collect the six pose parameters into
where locate the body-frame origin and denote roll, pitch, and yaw under a chosen Euler-angle convention.
Figure 1: Translation locates the body-frame origin; roll, pitch, and yaw describe its orientation relative to the fixed world frame.
1.1 A notation that prevents frame bugs
Before writing an equation, we need a way to say which frame a quantity belongs to. A left superscript names the frame in which coordinates are expressed. Thus,
means “the coordinates of physical point measured in frame .” The point itself is not changing; the superscript only identifies the coordinate system used to describe it.
For a transform, we need both a source and a destination:
The superscript is the destination and the subscript is the source, so means “map coordinates from frame into frame .” We will construct this transform below and introduce its homogeneous matrix form in Section 3.
1.2 Building the transformation step by step
Consider a body frame placed somewhere inside the world frame . We know a point through its body-frame coordinates , and we want its world-frame coordinates .
Step 1: locate the body origin. The translation
is the vector from the world origin to the body origin, expressed using world coordinates. At this stage, we have located frame , but not the point.
Step 1: Translation places the body-frame origin relative to the world-frame origin.
Step 2: describe the point relative to the body. The vector runs from the body origin to the point, but its components are measured along the body axes. Because the body axes are rotated relative to the world axes, we cannot add this vector directly to .
Step 2: Body-frame coordinates describe the displacement from the body origin to the point.
Step 3: rotate the local displacement into the world basis. The rotation converts components measured along the body axes into components measured along the world axes:
Here, is the same geometric displacement from the body origin to the point, now written in world coordinates. Rotation changes its coordinate components but not its length.
Step 3: Rotation changes the basis used to describe the displacement; it does not move or resize the vector.
Step 4: add vectors that now share the same basis. Both and are expressed in frame , so they can be added:
Figure 2 completes the construction by drawing the two world-basis component vectors head to tail. The orange vector reaches the body origin, the red vector continues to the point, and the dashed purple vector is their sum.
Figure 2: A body-frame point becomes a world-frame point by rotating its local displacement into the world basis and adding the body origin’s world-frame translation.
Changing coordinates versus moving a point
An active rotation moves a vector while its reference axes stay fixed. A passive change of frame describes the same geometric vector using different axes. Here, the frame-to-frame equations are coordinate conversions. Reversing the conversion requires the inverse rotation. Always identify the input and output frames before choosing a matrix.
2. Rigid Transforms
Suppose is a point expressed in a body frame . If the orientation of relative to world frame is and the body origin is located at , then
The order matters:
- rewrites the point using the world-frame basis.
- adds the body origin’s world position, so the result is measured from the world origin.
Translation is added after rotation because both terms must already be expressed in the same frame before they can be added.
2.1 Deriving the 2D rotation matrix
For a counterclockwise angle , the body unit -axis has world components . The perpendicular body unit -axis has world components . Put these vectors in the columns:
Why columns? A point with body coordinates means steps along the body -axis plus steps along the body -axis. Matrix multiplication forms exactly that linear combination of columns. This also explains the columns of a 3D rotation matrix.
Suppose the body is rotated counterclockwise, its origin is at world position , and a point has body coordinates . Then
The rotation expresses the body-relative displacement in world axes. The translation then locates that displacement relative to the world origin.
2.2 What makes the transform rigid?
A valid 3D rotation satisfies
Orthogonality means that the columns are mutually perpendicular unit vectors. It gives . For the planar matrix above, writing and makes the check explicit:
It also preserves distances. For two points and ,
Translation disappears in the difference, and rotation preserves the remaining norm. Inner products satisfy
Since both lengths and dot products remain unchanged, the cosine of the angle between any two nonzero displacement vectors remains unchanged too.
Orthogonal matrices can have determinant or . The condition rules out reflections, so handedness is preserved. For example, preserves planar distances but reflects across the -axis; it is not a proper rotation.
The square changes position and orientation while corresponding distances, angles, and handedness remain fixed. Source: Lecture 2, slide 19.1
3. Homogeneous Coordinates
The expression is affine rather than linear when . A linear map sends the origin to the origin; a translation sends it to . Homogeneous coordinates absorb the translation into one matrix multiplication by appending an extra coordinate:
Then a rigid transform becomes
In 2D, the same construction uses a matrix:
In 3D, the matrix belongs to the special Euclidean group . Although it stores 12 nontrivial numbers, it has only six degrees of freedom because the nine entries of are constrained.
3.1 Points and directions are different
A point uses a final coordinate of :
A direction uses a final coordinate of :
Consequently,
Translation affects locations, not directions. For a rigid transform this distinction applies to surface normals, ray directions, axis vectors, and the components of a given velocity vector. Relating velocities measured by moving observers requires additional motion terms.
Subtracting two homogeneous points naturally produces a displacement with last coordinate zero:
4. Inverting a Transform
If
then the reverse mapping is
To derive this, start with , subtract , and multiply by :
The translation is not merely . The vector must also be expressed in the inverse frame, which is why it becomes .
We can verify the result directly:
For the 2D example in Section 2.1, reversing the transform recovers the original point:
Although , the full transform generally satisfies .
A reliable mental model
To undo a transform, first undo the translation and then undo the rotation. Matrix multiplication writes those operations in reverse order, producing .
5. Composing Coordinate Frames
An autonomous vehicle may contain a LiDAR frame , a vehicle-body frame , and a world frame . Perception returns a pedestrian in the sensor frame, calibration provides the fixed sensor-to-body relationship, and localization estimates the changing body-to-world relationship.
Figure 3: A sensor measurement reaches the world by following the available frame chain from right to left.
The desired world coordinate is
Read the product from right to left: sensor coordinates become body coordinates, then world coordinates. The adjacent frame labels match, just as units must match in a dimensional calculation:
The lecture uses source-first superscripts: its is our . Thus its is the same body-to-world after sensor-to-body chain. The labels differ; the physical mapping does not.
More explicitly, if the component transforms are and , their composition is
Notice that the inner translation must be rotated before the outer translation is added. Transform multiplication is generally noncommutative:
5.1 A numerical 2D example
Suppose a sensor is mounted one meter ahead of a vehicle’s body origin:
The vehicle is at in the world and rotated counterclockwise:
A pedestrian detected two meters along the sensor’s -axis has . First map sensor to body:
Then map body to world:
The local phrase “three meters ahead” becomes the world location because the vehicle’s forward axis points along world .
Real systems have many frames, but every measurement follows the same composition rule along a connected path. Source: Lecture 2, slide 43.1
For a rigidly mounted sensor, the calibration transform is usually fixed. Localization changes the body-to-world transform over time. On an articulated robot, joint motion also changes the transforms between links.
6. Rotation Matrices and
The set of valid 3D rotation matrices is
The columns of are the source-frame coordinate axes expressed in the destination frame. They are orthonormal and right-handed. “Orthogonal” refers to ; “special” selects determinant .
A rotation acts directly on a vector, . Applying first and second gives . The order generally matters. Starting from :
- Rotate about , then about : the result is .
- Rotate about , then about : the result is .
6.1 What matrices preserve, and why averaging fails
Length preservation follows immediately:
Proper rotations also preserve the cross product:
To prove this, take the dot product with for an arbitrary vector . The scalar triple product on the left is
Dot-product preservation gives the same value for . Since this holds for every , the two vectors are equal.
Matrices make vector rotation and composition easy, but store nine numbers for three degrees of freedom. Arbitrary numerical updates can violate their constraints; a matrix generally needs projection back onto , not just independent normalization of its columns.
Even averaging two valid rotation matrices can fail. Let
Their average is , which collapses the and directions. It is not a rotation. This motivates representations with more convenient interpolation or local updates.
6.2 Euler angles and rotation order
Euler angles describe orientation as three sequential elemental rotations. Under the roll-pitch-yaw convention used here,
where , , and are roll, pitch, and yaw. The elemental matrices are
For active rotations about fixed axes, the product applies first, then , then . These are extrinsic rotations. The same product can also describe intrinsic rotations about moving body axes, in the reverse sequence: first , then the new , then the new .
There are twelve standard three-axis sequences. Six use distinct axes: , , , , , and . Six repeat the first axis: , , , , , and . The distinct-axis cases are more precisely called Tait–Bryan angles, though Euler angles is often used as an umbrella term.
An angle triple is therefore incomplete without axis order, intrinsic/extrinsic interpretation, and angle units.
6.3 Deriving gimbal lock
At pitch , the roll-pitch-yaw product simplifies to
Only the difference remains. Consequently, replacing by leaves the orientation unchanged. Roll and yaw no longer create independent local changes. This is gimbal lock.
At the singular configuration, two gimbal axes align and their rotations become dependent. Source: Lecture 2, slide 50.1 The ring labels in the illustration are specific to that mechanism; the formula above establishes the roll–yaw coupling for our chosen convention.
The statement “increasing roll = decreasing yaw” on slide 51 refers to their effect on : either change increases that difference. To keep the orientation unchanged, increase roll and yaw by the same amount instead.
Gimbal lock is a coordinate singularity
The rigid body still has three rotational degrees of freedom. At this configuration, the Euler-angle chart cannot describe three independent local changes. Recovering angles or computing updates near the singularity can become unstable even though the physical orientation is perfectly valid.
6.4 Axis-angle and the rotation vector
Every proper 3D rotation can be described by a unit axis and an angle . The four stored numbers have three degrees of freedom because . The rotation vector, also called the Euler vector,
combines them into three numbers: its direction gives the axis and its length gives the angle in radians. A rotation vector is not a triple of Euler angles.
The rotation vector points along the rotation axis, with magnitude equal to the angle. Source: Lecture 2, slide 52.1 The figure labels the angle or ; the equations here use .
Define the skew-symmetric cross-product matrix
so that . Rodrigues’ formula converts axis-angle to a matrix:
To derive it, decompose a vector into components parallel and perpendicular to the axis:
The parallel component stays fixed. In the perpendicular plane, ordinary 2D rotation gives
Substitute the components and collect terms:
Thus . The vector triple-product identity gives
which produces Rodrigues’ formula. The vector expression above also rotates a vector without constructing a matrix, so conversion to a matrix is not compulsory as slide 53 suggests.
Axis-angle is not globally unique. and give the same rotation; adding to the angle changes nothing. At zero rotation the axis is arbitrary. At angle , opposite axes give the same rotation. A common canonical rotation-vector range is , with opposite boundary points identified.
This explains the slide’s “edges” example:
Their coordinate difference is , but the shortest rotation between them is only . Averaging the vectors gives zero, which is not the midpoint along that short path. Rotation vectors are useful for local updates, but ordinary global subtraction and averaging can cross a coordinate seam.
6.5 Unit quaternions
A quaternion has four real components:
The imaginary units satisfy . For example, but , so multiplication is noncommutative. We use scalar-first order ; the lecture’s axis-angle tuple uses scalar-last order .
The conjugate and inverse are
A unit quaternion satisfies , so its inverse equals its conjugate. This unit-norm assumption is needed for the inverse shown on slide 54.
An axis-angle rotation maps to
The unit norm follows from . A rotation about , for example, has scalar-first quaternion .
For and , the Hamilton product is
Embed a vector as a pure quaternion . Then
The vector part is the rotated vector. This two-sided operation produces the full angle from the half-angle terms in . Applying first and second uses under this convention.
Quaternions avoid Euler gimbal lock, store only four numbers, and support efficient composition. They still have a unit-norm constraint and a double cover:
The two minus signs cancel in the vector-rotation formula. Consequently, a continuous orientation trajectory may acquire artificial sign flips if each quaternion is chosen independently. Keep successive signs consistent and renormalize when numerical error causes norm drift.
6.6 Interpolating orientations with SLERP
A useful extension to the lecture is spherical linear interpolation, or SLERP. Let and be unit quaternions. If their dot product is negative, negate one to choose the shorter path. Set
For interpolation parameter ,
The curve stays on the unit-quaternion sphere and gives a shortest rotational path at constant angular speed. When is very small, use a stable limiting approximation such as normalized linear interpolation. Clamp a numerically computed dot product to before applying .
6.7 Choosing a representation
| Representation | Stored values | Main advantage | Main caution |
|---|---|---|---|
| Rotation matrix | 9 | Direct action and easy composition | Redundant; must remain orthogonal |
| Euler angles | 3 | Human-readable | Order-dependent; gimbal lock |
| Axis-angle | 4 | Geometrically meaningful | Sign and boundary ambiguities |
| Rotation vector | 3 | Convenient local optimization update | Discontinuous at the angle boundary |
| Unit quaternion | 4 | Stable composition and interpolation | Unit-norm constraint; |
A common engineering pattern is to use quaternions or rotation matrices for stored poses, rotation vectors for optimizer updates, and Euler angles only for display.
7. Uniform Sampling on Curved Spaces
The final slide asks whether uniformly sampled coordinates give uniformly distributed directions or orientations. In both examples the answer is no: equal coordinate intervals need not cover equal amounts of geometric area or volume.
7.1 Uniform directions on the sphere
With azimuth and polar angle , a unit direction is
Here is measured down from the positive -axis. The slide calls it latitude, but its interval corresponds to polar angle, not geographic latitude.
The sphere’s area element is
Near a pole, a fixed angular rectangle covers less area than near the equator. Uniformly sampling both angles therefore produces too many samples near the poles per unit area.
Instead, sample and independently, then set
Why does this work? Since , the area element becomes . Equal-height strips of a sphere have equal area. Another valid method is to normalize a vector of three independent standard normal samples: its rotationally symmetric distribution has no preferred direction.
7.2 Uniform rotations in
A random direction is not a full random orientation: after choosing where one axis points, rotation about that axis is still free. Nor does sampling roll, pitch, and yaw independently and uniformly yield uniform orientations.
For with , the uniform rotation measure is proportional to
One valid sampler draws roll and yaw uniformly over a full turn, samples , and sets .
An especially simple alternative uses unit quaternions:
- Draw four independent standard normal samples .
- Form .
- Normalize: .
- Interpret as a unit quaternion.
The normalized Gaussian is uniform on the three-dimensional unit sphere in four-dimensional space. Its quaternion-to-rotation mapping produces the uniform, or Haar, distribution on . The two-to-one mapping is harmless because every rotation has exactly the pair .
Normalize Gaussian samples, not uniform cube samples
Normalizing four samples from does not give the same distribution. A Gaussian is rotationally symmetric; a cube is not. The same distinction applies when sampling directions on .
8. Implementation Pattern
The following NumPy functions encode the same frame convention used throughout this note:
import numpy as np
def make_transform(R: np.ndarray, t: np.ndarray) -> np.ndarray:
"""Construct destination_T_source from destination_R_source and destination_t_source."""
T = np.eye(4)
T[:3, :3] = R
T[:3, 3] = t
return T
def invert_transform(A_T_B: np.ndarray) -> np.ndarray:
"""Return B_T_A."""
R = A_T_B[:3, :3]
t = A_T_B[:3, 3]
B_T_A = np.eye(4)
B_T_A[:3, :3] = R.T
B_T_A[:3, 3] = -R.T @ t
return B_T_A
def transform_point(A_T_B: np.ndarray, B_p: np.ndarray) -> np.ndarray:
"""Map a 3D point from frame B to frame A."""
B_p_h = np.append(B_p, 1.0)
return (A_T_B @ B_p_h)[:3]
def is_rotation_matrix(R: np.ndarray, atol: float = 1e-7) -> bool:
return (
np.allclose(R.T @ R, np.eye(3), atol=atol, rtol=0.0)
and np.isclose(np.linalg.det(R), 1.0, atol=atol, rtol=0.0)
)For valid rigid-transform inputs, the following example checks composition, inversion, point-versus-direction behavior, and distance preservation:
W_T_B = make_transform(
np.array([[0., -1., 0.], [1., 0., 0.], [0., 0., 1.]]),
np.array([10., 5., 0.]),
)
B_T_S = make_transform(np.eye(3), np.array([1., 0., 0.]))
S_p = np.array([2., 0., 0.])
W_T_S = W_T_B @ B_T_S
W_p = transform_point(W_T_S, S_p)
assert np.allclose(W_p, [10., 8., 0.])
assert np.allclose(W_T_S @ invert_transform(W_T_S), np.eye(4))
assert np.allclose(transform_point(invert_transform(W_T_S), W_p), S_p)
assert is_rotation_matrix(W_T_S[:3, :3])
# The last homogeneous coordinate controls whether translation applies.
assert np.allclose(W_T_B @ [1., 0., 0., 0.], [0., 1., 0., 0.])
assert np.allclose(W_T_B @ [1., 0., 0., 1.], [10., 6., 0., 1.])
S_p2 = np.array([-1., 2., 4.])
assert np.isclose(
np.linalg.norm(transform_point(W_T_S, S_p) - transform_point(W_T_S, S_p2)),
np.linalg.norm(S_p - S_p2),
)The sampling algorithms need only NumPy as well. The returned quaternion order below is scalar-first (w, x, y, z):
rng = np.random.default_rng(42)
def sample_unit_vectors(rng, count: int, dimension: int) -> np.ndarray:
samples = rng.normal(size=(count, dimension))
norms = np.linalg.norm(samples, axis=1, keepdims=True)
# Exact zeros have probability zero in the ideal distribution;
# resample them defensively for finite-precision computation.
zero = norms[:, 0] == 0
while np.any(zero):
samples[zero] = rng.normal(size=(np.count_nonzero(zero), dimension))
norms = np.linalg.norm(samples, axis=1, keepdims=True)
zero = norms[:, 0] == 0
return samples / norms
directions = sample_unit_vectors(rng, count=1000, dimension=3)
quaternions_wxyz = sample_unit_vectors(rng, count=1000, dimension=4)Library conventions differ
Before combining libraries, check axis handedness, quaternion component order (
wxyzversusxyzw), angle units, Euler order, whether vectors are rows or columns, and whether a matrix maps source-to-destination or destination-to-source. Shape compatibility alone does not prove semantic compatibility.
9. Check Your Understanding
Try these before reading the answers:
- A body has no rotation, its origin is at world position , and a point has body coordinates . What are the world coordinates?
- What changes about a direction vector under pure translation?
- If maps to and maps to , what maps to ?
- Why does the inverse translation include ?
- At pitch , what happens if roll and yaw both increase by the same amount?
- Do and encode different orientations?
- Why is uniform sampling of polar angle biased toward the poles?
Answers. (1) . (2) Its components do not change. (3) . (4) The reversed displacement must be expressed in the reversed frame. (5) The orientation stays unchanged because stays constant. (6) No. (7) Equal angular intervals cover less surface area near the poles.
10. Summary
The geometry of machine perception rests on a small set of reusable ideas:
- Coordinates are meaningless without a frame.
- A pose relates two frames through orientation and position.
- A rigid transform maps source-frame coordinates into a destination frame.
- Homogeneous coordinates unify rotation and translation.
- Transform labels determine composition order; matching inner frames should cancel.
- Inversion uses and , not a simple matrix transpose.
- Rotation matrices, Euler angles, axis-angle vectors, and quaternions describe the same geometry with different tradeoffs.
- Interpolation and random sampling must respect rotation geometry; coordinate averages and uniform angle samples can give the wrong result.
Once the notation is disciplined, a complicated multi-sensor system becomes a graph of frames connected by transforms. Perception supplies measurements, calibration connects sensors to the platform, and localization connects the platform to the world.
References
Footnotes
-
Wang, Shenlong (2026). CS 498 Fall 2026, Lecture 2: Poses, Coordinates, Transforms and Rotations. University of Illinois Urbana-Champaign, August 28, 2026. The reproduced figures are cropped from slides 13, 19, 43, 50, and 52 of the supplied lecture PDF. The deck credits borrowed materials to Matthew O’Toole, Kris Kitani, Lana Lazebnik, Derek Hoiem, and Sanja Fidler; original image marks are retained where present. ↩ ↩2 ↩3 ↩4 ↩5 ↩6