Homogeneous Coordinates Basilio Bona DAUIN-Politecnico di Torino October 2013 Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 1 / 32
Introduction Homogeneous coordinates are an augmented representation of points and lines in R n spaces, embedding them in R n+1, hence using n+1 parameters. This representation is useful in dealing with perspective and projective transformation (computer graphics, etc.) and for rigid displacement representation. We start introducing the concept on 2D spaces. Given a point p in R 2, represented as P = (p 1,p 2 ), i.e., the vector p = [ p 1 p 2 ] T its homogeneous representation (using homogeneous coordinates) is p = [ p 1 p 2 p 3 ] T; with [ 0 0 0 ] T not allowed The vector representation is obtained dividing the first n homogeneous components by the (n +1)-th, that is often called scale. p 1 = p 1 / p 3 ; p 2 = p 2 / p 3 Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 2 / 32
A geometric interpretation of the homogeneous coordinates is given in the following Figure. Figure: Geometric interpretation of homogeneous coordinates. Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 3 / 32
We embed the plane π : z = 1 in a 3D space and we consider the planar coordinates as the intersection of a projection line that goes through the origin of the RF {i,j,k}. As z goes to we can represent the origin, while as z goes to 0, we can represents points at infinity, along a well defined direction. The set of all points at infinity represents the line at infinity. Figure: Points at. Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 4 / 32
The same approach is valid for 3D homogeneous coordinates: given a point p in R 3, represented as P = (p 1,p 2,p 3 ), or else by a vector its homogeneous representation is p = [ p 1 p 2 p 3 ] T p = [ p 1 p 2 p 3 p 4 ] T Hence p 1 = p 1 / p 4 ; p 2 = p 2 / p 4 ; p 3 = p 3 / p 4 In robotics it is common to set p 4 = 1. We will adhere to this convention. Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 5 / 32
Some author treats differently the homogeneous representation of a point (geometric vector v p ) by that of an oriented segment (physical vector v ab ). In the first case while in the second case ṽ ab = [ vb ṽ p = 1 ] [ vp 1 ] [ ] va = 1 [ ] vab 0 Not all textbooks adhere to this convention, since in this case the sum of two geometric vectors produces [ ] [ ] [ ] vp vq vp +v ṽ p +ṽ q = + = q 1 1 2 This sum, once transformed back in 3D space, becomes not the usual parallelogram sum of segments, but the midpoint of the parallelogram (see also Affine Spaces). Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 6 / 32
Figure: Homogeneous sum of two geometric vectors. Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 7 / 32
Affine spaces Briefly, affine spaces are spaces where the origin is not considered to be a special point, and homogeneous coordinates are used to characterize the affine elements (points and planes). Figure: Linear and affine subspaces. Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 8 / 32
Rigid displacements and homogeneous coordinates Using homogeneous representation, the generic displacement (R, t) is given by the following homogeneous transformation matrix [ ] R t H H(R,t) = 0 T 1 since [ ] [v ] R t Hṽ = 0 T = Rv+t 1 1 Hence, the SE(3) group transformation g = (R,t) SE(3), is represented by the 4 4 homogeneous matrix H through the use of homogeneous coordinates: p a = g ab p b p a = H ab (R ab,t ab ) p b Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 9 / 32
Transformation composition g ab g bc is obtained by the homogeneous matrix product H ab (R ab,t ab )H bc (R bc,t bc ) i.e., [ ][ ] [ ] Rab t ab Rbc t bc Rab R bc R ab t bc +t ab 0 T 1 0 T = 1 0 T 1 Often it is convenient to write the time derivative of a homogeneous vector as p = ṗ 1 ṗ2 This notation will prove useful when dealing with twists. ṗ3 0 Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 10 / 32
Introduction to projective/perspective geometry Homogeneous coordinates p are used for describing point in projective spaces P n of dimension n. Two points ã and b are equal (ã b) if there exist a real λ 0 such that ã = λ b b λ b collinear points are equal this also means that vectors are equal up to a scale factor. We say that ã and b belong to the same line, i.e., to the same affine subspace of R n+1. Consider the planar (2D) projection through a pinhole camera of a 3D point P,p = [ x y z ] T. The ray of light intercepts the image plane in the 2D image point P i, whose homogeneous coordinates on the image plane are p i = x y f where f is the focal distance p i = [ ] T x/f = 1 [ T x y/f f y] Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 11 / 32
Figure: Example of projection through a pinhole camera. Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 12 / 32
Considering the similar triangles in Figure, we have: x f = X Z ; y f = Y Z If we set λ = Z/f, where f is known and the distance Z from π of the point p is unknown, we have X = λx, Y = λy, Z = λf Hence, if we compute the cartesian coordinates of p i on π from homogeneous coordinates, we have [ ] x/f p i = p y/f i = fx fy λ x y x y Z 1 f and every 3D point with homogeneous coordinates λ [ x y f ] T is projected onto the same point p i of the image plane π. Notice that the above transformation is a nonlinear one. Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 13 / 32
The nonlinear mapping R 3 R 2 can be expressed as a (linear) matrix transformation between the homogeneous spaces R 4 R 3 as fx fy λ x y = f 0 0 0 X [ 0 f 0 0 Y p Z λ p i = P 1] Z 1 0 0 1 0 }{{} 1 P Nonsingular (i.e., invertible) mappings between projective spaces are described by products of full rank square matrices T by homogeneous coordinates, p a = T ab p b An invertible mapping from P n onto itself preserves collinearities, i.e., if two points belong to a line, also the transformed points will belong to a line. Affine transformations preserve not only collinearities, but also parallelism between lines and ratios of distances. Similarity transformations preserves also angles, but not scales, while Euclidean (rigid) transformations preserve also scales Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 14 / 32
Figure: Examples of different mappings. Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 15 / 32
Hyperplanes A hyperplane in R n is defined by the equation between a set of points p i and a set of (real) coefficients l i l 1 p 1 +l 2 p 2 + +l n p n +l n+1 = 0 Using the homogeneous coordinates we obtain an homogeneous linear equation in P n l T p = 0 where l = l 1. l n l n+1 ; p = p 1. p n 1 The two homogeneous vectors can exchange their roles; we say that they are dual. Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 16 / 32
Remember that, given a vector p V(F), the set of all linear transformations f(p) : V R 1 form another vector space V, and f V are called dual vectors or 1 forms. For example, the total time derivative of a scalar function f(p) on R 3 is df(p(t)) dt = p φ(p)ṗ(t) is a dual vector wrt ṗ. Another dual vector is the divergence [ ] T p 1 p = p 1 p. n p n or the Laplacian (gradient of the divergence) f [ ] 2 T p 1 f = f = p 1 p n. f p n Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 17 / 32
Duality in projective spaces The space of all hyperplanes in R n defines another perspective space, called the dual of the original P n Duality principle: for all projective results established using points and planes, a symmetrical result holds interchanging the role of planes and points. Example: two points define a line two lines define a point Notice that the projective plane P 2 whose point are defined by homogeneous coordinates, has more point that the usual R 2 plane, since it includes also points at. Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 18 / 32
A collineation given by a full rank matrix T transforms points as p a = T ab p b A hyperplane l T b p b = 0 is transformed as hence yielding lt b p b = 0 l T a p a = 0 lt a T ab p b l T b = l T a T ab la = T T ab l T b Matrix T T ab is called the dual of T ab Comparing this last equation with the first one, we conclude that points and lines can be transformed, but using different (dual) collineation matrices T ab and T T ab. Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 19 / 32
Points and lines We restrict our analysis on the 2D projective space P 2 ; for the sake of clarity, we drop the sign on top of the homogeneous vectors, i.e., ã is now indicated as a. A line l = [ l 1 l 2 l 3 ] can be characterized by three parameters: 1 the slope l 1 /l 2 2 the x-intercept l 3 /l 1 3 the y-intercept l 3 /l 2 Points p and lines l are related by l T p = 0 in the sense that a point is on a line or a line include a point iff the previous relation holds. Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 20 / 32
Duality A line l passing for two points p 1 and p 2 is defined as l = p 1 p 2 = S(p 1 )p 2 A point p belonging to two lines (intercept) l 1 and l 2 is defined as p = l 1 l 2 = S(l 1 )l 2 Points at infinity or ideal points have the following representation p = [ p 1 p 2 0 ] T All ideal points lie on the ideal line, represented by l = [ 0 0 1 ] T Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 21 / 32
Three points p 1,p 2,p 3 lie on the same line (they are collinear) iff det [ p 1 p 2 p 3 ] = 0 Since the duality principle holds, three lines l 1,l 2,l 3 meet at the same point (they are concurrent) iff det [ l 1 l 2 l 3 ] = 0 Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 22 / 32
Parallelism Two lines m = m 1 ; n = n 1 m 2 m 3 n 2 n 3 are parallel when the intersection point is at infinity, i.e., p = m n = p 1 p 2 0 This reduces to the conditions The direction k m 1 m 2 = n 1 n 2 [ ] m1 n or det 1 = 0 m 2 n 2 [ ] p1 points toward the point at infinity. p 2 Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 23 / 32
Summary point p = [ p 1 p 2 p 3 ] T line l = [ l 1 l 2 l 3 ] T incidence p T l = 0 incidence l T p = 0 line l = p 1 p 2 point p = l 1 l 2 collinearity det [ p 1 p 2 p 3 ] = 0 collinearity det [ l1 l 2 l 3 ] = 0 point [ p1 p 2 0 ] T line [ 0 0 l3 ] T Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 24 / 32
Transformations in P 2 The generic projective transformation (also called homographies) in P 2 is represented by a non singular 3 3 matrix (acting on homogeneous vectors), whose elements are T = t 11 t 12 t 13 t 21 t 22 t 23 t 31 t 32 t 33 Since the transformations are equivalent up to a scale factor, the number of dof in T is 8. According to structural constraint, we have a hierarchy of transformations, from the most general to the least one; in particular Transformations in P 2 (most general) projective affine similarity Euclidean (rigid) Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 25 / 32
The affine transformation must preserve the ideal line and the ideal points (as well as parallelism); hence, for any arbitrary scaling factor λ λ p 1 p 2 = T p 1 p 2 0 0 that implies T = t 11 t 12 t 13 t 21 t 22 t 23 dof=6 0 0 t 33 Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 26 / 32
The similarity transformation must preserve angles and ratios of lengths; that implies T = cosθ sinθ t 13 sinθ cosθ t 23 dof=3 0 0 t 33 with t 33 1. The effects of the last column in T is to produce a shear i.e., a scale variation that is non uniform in all directions. Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 27 / 32
The Euclidean (rigid) transformation must preserve also lengths; that implies T = cosθ sinθ t 13 sinθ cosθ t 23 dof=3 0 0 1 Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 28 / 32
Historical notes Homogeneous coordinates were introduced in 1827 by Möbius in the context of barycentric coordinates. Given a triangle, the barycentric coordinates of a point P are the weights required at the triangle vertices such that P become the center of gravity of the triangle. The point is computed as p = [ w a x w b y w c z ] T, with w a +w b +w c = 1 Figure: Example of barycentric coordinates. Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 29 / 32
From homogeneous coordinates to quaternions There exist a link between homogeneous coordinates and quaternions that goes through the Möbius transformation. Given two complex numbers x = x 1 +jx 2, y = y 1 +jy 2 C, the ordered pair of complex numbers z = [ x y ] T C 2, z [ 0 0 ] T are the homogeneous coordinates of z = z 1 +jz 2 z = x y = z 1 +jz 2 = x 1 +jx 2 y 1 +jy 2 To every pair of complex numbers (x,y) a unique complex numbers z corresponds, while for every complex number z there is an infinite number of complex pairs (projective transformation). Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 30 / 32
Transformation between homogeneous representations [ [ [ [ ] x u u a b x z = w = where = = y] v] v] c d][ y where a,b,c,d are complex numbers. We can compute the transformed complex number as [ ] ax +by cx +dy w = u v ax +by = cx +dy = ax y +b az +b = +d cz +d c x y This is nothing else that the Möbius transformation. Möbius transformation w = az +b cz +d ; a,b,c,d,w,z C Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 31 / 32
If we take a particular form of the Möbius transformation, due to Gauss: w = az +b b z +a we know that every rotation of the sphere can be expressed by a complex function as the one above, and we notice that it can be represented by the matrix of its coefficients [ ] a b b a [ ] α+jβ γ +jδ = γ +jβ α jβ [ ] [ 1 0 j 0 = α +β 0 1 0 j = α1+βi+γj+δk = a quaternion ] +γ [ ] 0 1 +δ 1 0 [ ] 0 j j 0 For further details see: T. Needham, Visual Complex Analysis, OUP, 1997. Basilio Bona (DAUIN-Politecnico di Torino) Homogeneous Coordinates October 2013 32 / 32