Skip to main content
Open In Colab Railway tracks receding to the horizon. Under perspective projection, the parallel tracks appear to meet at a point on the horizon. A photograph maps points from three-dimensional Euclidean space to a two-dimensional image plane. Perspective projection does not preserve circles, distances, angles or ratios of distances. A circle can appear as an ellipse. Straight lines stay straight, while parallel lines can appear to meet. The camera models in this chapter describe that mapping with matrices that act on homogeneous coordinates. This section introduces them in the plane. Homogeneous coordinates append one entry to each vector. With that entry you can tell points from displacements, write a rotation and a translation as one matrix, and represent the point where two parallel lines meet.

Points and displacements

In the plane, a rotation is linear: p′=Rpp' = Rp. A translation p′=p+tp' = p + t is not linear, because a linear map sends the zero vector to zero. A rotation followed by a translation therefore has the form p′=Rp+t.p' = Rp + t. Append one coordinate. A finite point gets a 1 and a displacement vector gets a 0: p~=[pxpy1],v~=[vxvy0].\tilde p = \begin{bmatrix} p_x \\ p_y \\ 1 \end{bmatrix}, \qquad \tilde v = \begin{bmatrix} v_x \\ v_y \\ 0 \end{bmatrix}. Rotation and translation now fit in one 3×33 \times 3 matrix: T=[Rt01],Tp~=[Rp+t1],Tv~=[Rv0].\begin{aligned} T &= \begin{bmatrix} R & t \\ 0 & 1 \end{bmatrix}, \\ T\tilde p &= \begin{bmatrix} Rp + t \\ 1 \end{bmatrix}, \\ T\tilde v &= \begin{bmatrix} Rv \\ 0 \end{bmatrix}. \end{aligned} The translation column multiplies the last coordinate. It therefore moves points, which have w=1w = 1, and has no effect on displacements, which have w=0w = 0. The last coordinate marks whether a column is a point or a displacement, and it does not measure position along any axis. For example, translating by t=(2,1)Tt = (2, 1)^T sends the point (1,1)(1, 1) to (3,2)(3, 2), while the displacement (1,1)(1, 1) stays (1,1)(1, 1).
The figure below applies a rigid transformation to a point pp and to a displacement vv drawn from it. Use the sliders to change the rotation and the translation. The point is first rotated to RpRp (the hollow circle) and then shifted by tt (the dashed arrow) to TpTp. The displacement is only rotated, so tt changes neither its length nor its direction. The figure still draws it from the moved point, because its tip p+vp + v is a point and moves to Tp+RvTp + Rv. A rigid transformation TT applied to the point p=(1.5,0.5)p = (1.5, 0.5) and the displacement v=(1,0.75)v = (1, 0.75). The readouts give Tp~T\tilde p and Tv~T\tilde v with their last coordinate.

Coordinates depend on the frame

A point expressed in two different coordinate frames. The solid and dashed axes define two coordinate frames, so the same point has different coordinates in each. Its position in space does not change. An affine frame is an origin oo together with a basis B=[u1  u2]B = [u_1 \; u_2] of displacement vectors. A point has frame coordinates qq when pworld=o+Bq,p~world=Tworld←frame q~,Tworld←frame=[Bo01].\begin{aligned} p_{\text{world}} &= o + Bq, \\ \tilde p_{\text{world}} &= T_{\text{world} \leftarrow \text{frame}} \, \tilde q, \\ T_{\text{world} \leftarrow \text{frame}} &= \begin{bmatrix} B & o \\ 0 & 1 \end{bmatrix}. \end{aligned} This is a passive change of coordinates: the physical point does not move, only its description does. An active transformation uses the same kind of matrix but moves the point relative to a fixed frame. Writing the source and destination frames as subscripts on every matrix, as in Tworld←frameT_{\text{world} \leftarrow \text{frame}}, shows which reading is meant. When the basis is orthonormal, B=RB = R is a rotation, and the inverse goes the other way: Tframe←world=Tworld←frame−1=[RT−RTo01].T_{\text{frame} \leftarrow \text{world}} = T_{\text{world} \leftarrow \text{frame}}^{-1} = \begin{bmatrix} R^T & -R^T o \\ 0 & 1 \end{bmatrix}.
An affine space of dimension nn consists of a set of points A\mathcal{A} and an associated vector space VV of dimension nn. It supports two operations:
  • Point subtraction: p−q∈Vp - q \in V gives a vector.
  • Point translation: p+v∈Ap + v \in \mathcal{A} moves a point by a vector.
You cannot add two points, and there is no zero point. An affine space has no fixed origin or basis until you choose a frame. A vector space has a built-in origin, the zero vector, and is closed under linear combinations. Euclidean space adds an inner product, which defines lengths and angles.
The code below expresses the point q=(1,0.5)q = (1, 0.5) of a frame rotated by 35°35° in world coordinates, then converts it back with the inverse matrix.
Output from cell 3 One physical point and two frames. The gray arrows are the world axes, the blue arrows the frame’s basis, and the dashed line runs from the frame origin to the point.

Homogeneous scale and projective points

In projective geometry, a point is a class of nonzero vectors that differ only by scale: [x:y:w]=[λx:λy:λw],λ≠0.[x : y : w] = [\lambda x : \lambda y : \lambda w], \qquad \lambda \ne 0. When w≠0w \ne 0, the Cartesian point is (x/w, y/w)(x/w, \, y/w). The vectors (2,4,2)(2, 4, 2) and (−1,−2,−1)(-1, -2, -1) therefore describe the same finite point (1,2)(1, 2). Each class is a line through the origin of R3\mathbb R^3, and the plane w=1w = 1 cuts it at the Cartesian point. When w=0w = 0, the class [dx:dy:0][d_x : d_y : 0] has no Cartesian point. It is an ideal point, a direction on the line at infinity. Adding these points gives the projective plane, in which every pair of distinct lines meets in exactly one point. Two parallel lines meet at the ideal point of their common direction (Hartley & Zisserman, 2004). The earlier sections used the same vector (dx,dy,0)T(d_x, d_y, 0)^T for a displacement. Under a rigid or affine transformation it behaves as a displacement, and under a projective transformation it is a point at infinity. Three-dimensional space works the same way with four coordinates. A point (x,y,z)(x, y, z) becomes (x,y,z,1)(x, y, z, 1), and (x,y,z,w)≡(x/w,  y/w,  z/w),w≠0.(x, y, z, w) \equiv (x/w, \; y/w, \; z/w), \qquad w \ne 0. A camera maps these 3D homogeneous points to 2D homogeneous image points with a 3×43 \times 4 matrix. The camera divides by the last coordinate after the matrix product. For a camera that coordinate is the depth of the point, so the division makes distant objects appear smaller. The pinhole model builds that matrix.

Which properties a transformation keeps

All of the following act on column vectors p~=(x,y,1)T\tilde p = (x, y, 1)^T. With these conventions the families are nested: rigid ⊂\subset similarity ⊂\subset affine ⊂\subset projective. Each family keeps fewer properties than the one before it. A projective transformation, or homography, keeps lines straight but can make parallel lines converge, which is what the photograph of the tracks shows. Singular matrices collapse the plane and are left out of these groups. To apply a homography, compute z=Hp~z = H\tilde p and divide: (z1/z3, z2/z3)(z_1/z_3, \, z_2/z_3), as long as z3≠0z_3 \ne 0. The first three families have a last row of (0,0,1)(0, 0, 1), so z3=1z_3 = 1 and the division does nothing. For a homography, z3z_3 depends on the point, so the division makes the map nonlinear in Cartesian coordinates. The code below applies one transformation from each family to the unit square and checks which properties each one keeps.
Output from cell 5 The unit square (dashed) under one transformation from each family. The rigid image keeps side length 1, the similarity scales every side by 1.5, the affine image is a parallelogram, and the projective image is a general quadrilateral with no parallel sides.

Composing transformations

If TA←BT_{A \leftarrow B} maps coordinates in frame BB to frame AA, and TB←CT_{B \leftarrow C} maps frame CC to frame BB, then TA←C=TA←B TB←C.T_{A \leftarrow C} = T_{A \leftarrow B} \, T_{B \leftarrow C}. The product is valid because the inner labels match: TA←BT_{A \leftarrow B} takes coordinates in BB, and TB←CT_{B \leftarrow C} produces coordinates in BB. The reversed product TB←CTA←BT_{B \leftarrow C} T_{A \leftarrow B} does not correspond to any chain of frames. It is also a different matrix in general, because matrix multiplication does not commute. For example, rotating and then translating moves a point to a different place than translating and then rotating. In the code below, frame BB is rotated by 90°90° and shifted by one unit in AA, and frame CC is shifted two units along the xx axis of BB. The origin of CC lands at (1,2)(1, 2) in AA. The reversed product gives a different point.
In three dimensions the same construction uses 4×44 \times 4 matrices with R∈SO(3)R \in SO(3) and t∈R3t \in \mathbb R^3. They form the group SE(3)SE(3) of rigid motions (Kevin M. Lynch, 2017). The camera models that follow use it for the camera pose, and the motion representations section uses it for robot links.

Exercises

  1. Why does T(1,0,0)TT(1, 0, 0)^T ignore the translation column, while T(1,0,1)TT(1, 0, 1)^T includes it?
  2. Show numerically that [2:4:2][2 : 4 : 2] and [−1:−2:−1][-1 : -2 : -1] are the same projective point.
  3. A square becomes a parallelogram. Which transformation families could have produced it, and which measurements are unchanged?
  4. Why is TA←BTB←CT_{A \leftarrow B} T_{B \leftarrow C} meaningful, while the reversed product generally is not?
  5. Why can a homography make two parallel lines appear to converge?

References

  • Hartley, R., Zisserman, A. (2004). Multiple View Geometry in Computer Vision.
  • Kevin M. Lynch, F. (2017). Modern Robotics. Link

Found an error on this page? Report an issue.