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. This perspective projection does not preserve circles, distances, angles, or ratios of distances. For example, a circle can appear as an ellipse. Straight lines remain straight, while parallel lines can appear to meet. A projective space extends Euclidean space so that every pair of lines intersects. Parallel lines intersect at a point at infinity. Choosing coordinates selects an origin, but any point could serve as the origin. A point expressed in two different coordinate frames. The coordinates of a point in 2D depend on the chosen coordinate system. The solid and dashed axes define two coordinate systems, so the same point has different coordinates in each. Its position in space does not change. The figure shows two frames. Each frame consists of an origin and two linearly independent basis vectors that define the axes of the two-dimensional space. More generally, an origin pop_o and nn linearly independent basis vectors define an n-dimensional affine frame. For any vector v\mathbf v, there is a unique set of scalars sis_i such that v=s1u1+s2u2+...+snun=sT[u1,u2,...,un]T\mathbf v = s_1 \mathbf u_1 + s_2 \mathbf u_2 + ... + s_n \mathbf u_n = \mathbf s^T [\mathbf u_1, \mathbf u_2, ..., \mathbf u_n]^T where s\mathbf s gives the coordinates of v\mathbf v in the frame. Each point also has unique scalars sis_i that express it in terms of the origin pop_o and the basis vectors: p=po+s1u1+s2u2+...+snun=po+sT[u1,u2,...,un]Tp = p_o + s_1 \mathbf u_1 + s_2 \mathbf u_2 + ... + s_n \mathbf u_n = p_o + \mathbf s^T [\mathbf u_1, \mathbf u_2, ..., \mathbf u_n]^T
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)
There is no fixed origin, no preferred coordinate system, and no basis until you choose one.A coordinate frame on an affine space is a chosen origin point p0∈Ap_0 \in \mathcal{A} and a basis {v1,…,vn}\{v_1, \dots, v_n\} for the associated vector space VV.A vector space has a built-in origin, defined by the zero vector. It is closed under addition and scalar multiplication, so it supports linear combinations such as av1+bv2a\mathbf{v}_1 + b\mathbf{v}_2. For this reason, it is also called a linear space. In an affine space, you cannot add two points directly, and there is no zero point.Euclidean space adds an inner product, which defines angles and lengths.
Points and vectors may both have x, y, and z coordinates in 3D, but they are different mathematical objects. A 3D frame defined by (po,u1,u2,u3)(p_o, \mathbf u_1, \mathbf u_2, \mathbf u_3) does not by itself distinguish a point (px,py,pz)(p_x, p_y, p_z) from a vector (vx,vy,vz)(v_x, v_y, v_z) with the same coordinates. Homogeneous coordinates resolve this ambiguity. In this frame, the point is p=[s1s2s31][u1u2u3po]Tp = [s_1 s_2 s_3 1][\mathbf u_1 \mathbf u_2 \mathbf u_3 p_o]^T and the vector is v=[s1′s2′s3′0][u1u2u3po]T\mathbf v = [s_1' s_2' s_3' 0][\mathbf u_1 \mathbf u_2 \mathbf u_3 p_o]^T The point representation [s1s2s31][s_1 s_2 s_3 1] and the vector representation [s1′s2′s3′0][s_1' s_2' s_3' 0] are called homogeneous coordinates. The fourth coordinate ww is called the weight. A point (x,y,z)(x,y,z) in three-dimensional Euclidean space can be represented by the 4-tuple (x,y,z,1)(x,y,z,1). More generally, (x,y,z,1)(x,y,z,1) and (λx,λy,λz,λ)(\lambda x, \lambda y, \lambda z, \lambda) represent the same point for any λ≠0\lambda \neq 0, because dividing every coordinate by λ\lambda gives (x,y,z,1)(x,y,z,1). A point with weight w≠0w \neq 0 therefore stands for the Cartesian point obtained by dividing through by the weight: (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 \neq 0 Homogeneous coordinates represent a family of equivalent points along a ray in projective space. Each member is a scaled version of the same Cartesian point. These coordinates can:
  • Represent points at infinity (when w=0w = 0), as required for parallel lines in perspective projections.
  • Express transformations such as perspective camera models and 3D projections as linear matrix operations.

Transformations in homogeneous coordinates

This section gives homogeneous matrix representations for common 2D transformations.

Rigid transformation

A rigid transformation consists of a rotation and a translation. It preserves lengths and angles and does not include scaling or shearing. Its matrix is: Trigid=[cos⁡θ−sin⁡θtxsin⁡θcos⁡θty001]\mathbf{T}_{\text{rigid}} = \begin{bmatrix} \cos\theta & -\sin\theta & t_x \\ \sin\theta & \cos\theta & t_y \\ 0 & 0 & 1 \end{bmatrix}
  • θ\theta: rotation angle
  • (tx,ty)(t_x, t_y): translation

Similarity transformation

A similarity transformation includes rotation, translation, and uniform scaling. It preserves shape but not necessarily size. Tsim=[scos⁡θ−ssin⁡θtxssin⁡θscos⁡θty001]\mathbf{T}_{\text{sim}} = \begin{bmatrix} s \cos\theta & -s \sin\theta & t_x \\ s \sin\theta & s \cos\theta & t_y \\ 0 & 0 & 1 \end{bmatrix} Here, ss is the scaling factor.

Affine transformation

An affine transformation can combine translation, rotation, scaling, and shearing. It preserves parallel lines, but it need not preserve lengths or angles. Taffine=[a11a12txa21a22ty001]\mathbf{T}_{\text{affine}} = \begin{bmatrix} a_{11} & a_{12} & t_x \\ a_{21} & a_{22} & t_y \\ 0 & 0 & 1 \end{bmatrix} This is the general form of a 2D affine transformation.

Example

The following code applies these transformations to a square:
Output from cell 2 Key references: (Zeng et al., 2016; Chang et al., 2017; Qi et al., 2016; Bronstein et al., 2016; Mur-Artal & Tardos, 2016)

References

  • Bronstein, M., Bruna, J., LeCun, Y., Szlam, A., Vandergheynst, P. (2016). Geometric deep learning: going beyond Euclidean data.
  • Chang, A., Dai, A., Funkhouser, T., Halber, M., Nießner, M., et al. (2017). Matterport3D: Learning from RGB-D Data in Indoor Environments.
  • Mur-Artal, R., Tardos, J. (2016). ORB-SLAM2: an Open-Source SLAM System for Monocular, Stereo and RGB-D Cameras.
  • Qi, C., Su, H., Mo, K., Guibas, L. (2016). PointNet: Deep Learning on Point Sets for 3D Classification and Segmentation.
  • Zeng, A., Song, S., Nießner, M., Fisher, M., Xiao, J., et al. (2016). 3DMatch: Learning Local Geometric Descriptors from RGB-D Reconstructions.