Homogeneous Coordinates
Total Page:16
File Type:pdf, Size:1020Kb
Homogeneous Coordinates Basilio Bona DAUIN – Politecnico di Torino Semester 1, 2015-16 B. Bona (DAUIN) Homogeneous Coordinates Semester 1, 2015-16 1 / 32 Introduction Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+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. 2 Given a point p in R , represented as P = (p1, p2), i.e., the vector T p = p1 p2 its homogeneous representation (using homogeneous coordinates) is T T p˜ = p˜1 p˜2 p˜3 ; with 0 0 0 not allowed The vector representation is obtained dividing the first n homogeneous components by the (n + 1)-th, that is often called scale. p1 =p ˜1/p˜3; p2 =p ˜2/p˜3 B. Bona (DAUIN) Homogeneous Coordinates Semester 1, 2015-16 2 / 32 A geometric interpretation of the homogeneous coordinates is given in the following Figure. Figure: Geometric interpretation of homogeneous coordinates. B. Bona (DAUIN) Homogeneous Coordinates Semester 1, 2015-16 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 ∞. B. Bona (DAUIN) Homogeneous Coordinates Semester 1, 2015-16 4 / 32 The same approach is valid for 3D homogeneous coordinates: given a 3 point p in R , represented as P = (p1, p2, p3), or else by a vector T p = p1 p2 p3 its homogeneous representation is T p˜ = p1 p2 p3 p4 Hence p1 =p ˜1/p˜4; p2 =p ˜2/p˜4; p3 =p ˜3/p˜4 In robotics it is common to setp ˜4 = 1. We will adhere to this convention. B. Bona (DAUIN) Homogeneous Coordinates Semester 1, 2015-16 5 / 32 Some author treats differently the homogeneous representation of a point (geometric vector vp) by that of an oriented segment (physical vector vab). In the first case v v˜ = p p 1 while in the second case v v v v˜ = b − a = ab ab 1 1 0 Not all textbooks adhere to this convention, since in this case the sum of two geometric vectors produces v v v + v ˜v + v˜ = p + q = p q p 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). B. Bona (DAUIN) Homogeneous Coordinates Semester 1, 2015-16 6 / 32 Figure: Homogeneous sum of two geometric vectors. B. Bona (DAUIN) Homogeneous Coordinates Semester 1, 2015-16 7 / 32 Affine spaces Briefly, affine spaces are spaces where the origin is not considered to bea special point, and homogeneous coordinates are used to characterize the affine elements (points and planes). Figure: Linear and affine subspaces. B. Bona (DAUIN) Homogeneous Coordinates Semester 1, 2015-16 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)= 0T 1 since R t v H˜v = = Rv + t 0T 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: pa = gabpb ↔ p˜a = Hab(Rab, tab)p˜b B. Bona (DAUIN) Homogeneous Coordinates Semester 1, 2015-16 9 / 32 Transformation composition gabgbc is obtained by the homogeneous matrix product Hab(Rab, tab)Hbc (Rbc , tbc ) i.e., Rab tab Rbc tbc RabRbc Rabtbc + tab = 0T 1 0T 1 0T 1 Often it is convenient to write the time derivative of a homogeneous vector as p˙1 p˙ p˜˙ = 2 p˙3 0 This notation will prove useful when dealing with twists. B. Bona (DAUIN) Homogeneous Coordinates Semester 1, 2015-16 10 / 32 Introduction to projective/perspective geometry Homogeneous coordinates p˜ are used for describing point in projective spaces Pn of dimension n. Two points a˜ and b˜ are “equal” (a˜ ∼ b˜) if there exist a real λ = 0 such that a˜ = λb˜ → b˜ ∼ λb˜ collinear points are equal this also means that vectors are equal up to a scale factor. We say that a˜ and b˜ belong to the same line, i.e., to the same affine subspace of Rn+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 Pi , whose homogeneous coordinates on the image plane are x T T x/f 1 x p˜ = y → p = = i i y/f f y f where f is the focal distance B. Bona (DAUIN) Homogeneous Coordinates Semester 1, 2015-16 11 / 32 Figure: Example of projection through a pinhole camera. B. Bona (DAUIN) Homogeneous Coordinates Semester 1, 2015-16 12 / 32 Considering the similar triangles in Figure, we have: x X y Y = ; = f Z f 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 pi on π from homogeneous coordinates, we have fX x x x/f p = ↔ p˜ = fY ∼ λ y ∼ y i y/f i Z 1 f and every 3D point with homogeneous coordinates λ x y f T is projected onto the same point pi of the image plane π. Notice that the above transformation is a nonlinear one. B. Bona (DAUIN) Homogeneous Coordinates Semester 1, 2015-16 13 / 32 The nonlinear mapping R3 → R2 can be expressed as a (linear) matrix transformation between the homogeneous spaces R4 → R3 as X fX x f 0 0 0 Y p fY ∼ λ y = 0 f 0 0 ⇔ λp˜ = P Z i 1 Z 1 0 0 10 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 = Tabp˜b An invertible mapping from Pn 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 B. Bona (DAUIN) Homogeneous Coordinates Semester 1, 2015-16 14 / 32 Figure: Examples of different mappings. B. Bona (DAUIN) Homogeneous Coordinates Semester 1, 2015-16 15 / 32 Hyperplanes n A hyperplane in R is defined by the equation between a set of points pi and a set of (real) coefficients ℓi ℓ1p1 + ℓ2p2 + · · · + ℓnpn + ℓn+1 = 0 Using the homogeneous coordinates we obtain an homogeneous linear equation in Pn T ˜ℓ p˜ = 0 where ℓ1 p1 . ˜ℓ = . ; p˜ = . ℓn pn ℓ 1 n+1 The two homogeneous vectors can exchange their roles; we say that they are dual. B. Bona (DAUIN) Homogeneous Coordinates Semester 1, 2015-16 16 / 32 Remember that, given a vector p ∈V(F), the set of all linear transformations f (p) : V → R1 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 R3 is df (p(t)) = ∇ φ(p)p˙ (t) dt p is a dual vector wrt p˙ . Another dual vector is the divergence T p1 ∂ ∂ . ∇ · p = · · · . ∂p1 ∂pn pn or the Laplacian (gradient of the divergence) ∂f T ∂p1 ∂ ∂ ∇2f = ∇·∇f = · · · . ∂p ∂p . 1 n ∂f ∂pn B. Bona (DAUIN) Homogeneous Coordinates Semester 1, 2015-16 17 / 32 Duality in projective spaces The space of all hyperplanes in Rn defines another perspective space, called the dual of the original Pn 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 P2 whose point are defined by homogeneous coordinates, has more point that the usual R2 plane, since it includes also points at ∞. B. Bona (DAUIN) Homogeneous Coordinates Semester 1, 2015-16 18 / 32 A collineation given by a full rank matrix T transforms points as p˜a = Tabp˜b ˜ℓT A hyperplane b p˜b = 0 is transformed as ˜ℓT ˜ℓT b p˜b = 0 ⇔ a p˜a = 0 hence ˜ℓT ˜ℓT ˜ℓT a Tabp˜b ⇒ b = a Tab yielding ˜ℓ −T ˜ℓT a = Tab b −T Matrix Tab is called the dual of Tab Comparing this last equation with the first one, we conclude that points and lines can be transformed, but using different (dual) collineation −T matrices Tab and Tab . B. Bona (DAUIN) Homogeneous Coordinates Semester 1, 2015-16 19 / 32 Points and lines We restrict our analysis on the 2D projective space P2; for the sake of clarity, we drop the ˜ sign on top of the homogeneous vectors, i.e., a˜ is now indicated as a. A line ℓ = ℓ1 ℓ2 ℓ3 can be characterized by three parameters: 1 the slope −ℓ1/ℓ2 2 the x-intercept −ℓ3/ℓ1 3 the y-intercept −ℓ3/ℓ2 Points p and lines ℓ are related by ℓTp = 0 in the sense that a point is on a line or a line include a point iff the previous relation holds.