3CG 2006 / B4 Computational Geometry David Murray david.murray@eng.o.ac.uk www.robots.o.ac.uk/ dwm/courses/3cg Michaelmas 2006
3CG 2006 2 / Overview Computational geometry is concerned with the derivation of techniques the design of efficient algorithms and the construction of effective representations for geometric computation. Techniques from computational geometry are used in: Computer Graphics Computer Aided Design Computer Vision Robotics
3CG 2006 3 / Topics Lecture : Euclidean, similarity, affine and projective transformations. Homogeneous coordinates and matrices. Coordinate frames. Perspective projection and its matri representation. Lecture 2: Perspective projection and its matri representation. Vanishing points. Applications of projective transformations. Lecture 3: Conveity of point-sets, conve hull and algorithms. Conics and quadrics, implicit and parametric forms, computation of intersections. Lecture 4: Bezier curves, B-splines. Tensor-product surfaces.
3CG 2006 4 / Useful Tets Bartels, Beatty and Barsky, An introduction to splines for use in computer graphics and geometric modeling, Morgan Kaufmann, 987. Everything you could want to know about splines. Fau and Pratt, Computational geometry for design and manufacture, Ellis Horwood, 979. Good on curves and transformations. Farin, Curves and Surfaces for Computer-Aided Geometric Design : A Practical Guide, Academic Press, 996. Foley, van Dam, Feiner and Hughes, Computer graphics - principles and practice, Addison Wesley, second edition, 995. The computer graphics book. Covers curves and surfaces well. Hartley and Zisserman Multiple View Geometry in Computer Vision, CUP, 2000. Chapter is a good introduction to projective geometry. O Rourke, Computational geometry in C, CUP, 998. Very straightforward to read, many eamples. Highly recommended. Preparata and Shamos, Computational geometry, an introduction, Springer-Verlag, 985. Very formal and complete for particular algorithms.
5/ 3CG 2006 Eample I: Virtual Reality Models from Images Input: Four overlapping aerial images of the same urban scene Objective: Teture mapped 3D models of buildings
3CG 2006 6 / Eample II: Video Mosaicing
3CG 2006 7 / Eample II: Video Mosaicing
3CG 2006 8 / Eample II: Video Mosaicing
3CG 2006 9 / Lecture. Lecture : Transformations, Homogeneous Coordinates, and Coordinate Frames Euclidean, similarity, affine and projective transformations. Homogeneous coordinates and matrices. Coordinate frames.
3CG 2006 0 / Hierarchy of transformations We will look at linear transformations represented by matrices of increasing generality: Euclidean Similarity Affine Projective We consider both 2D 2D mappings ( plane to plane mappings); and 3D 3D transformations
3CG 2006 / Class I: Euclidean transformations: translation & rotation. Translation 2 dof in 2D ( ) ( ) ( ) t y = + y t y y t t 2. Rotation dof in 2D ( ) [ cos θ sin θ y = sin θ cos θ ] ( y ) θ O y θ O In vector notation, a Euclidean transformation is written = R + t R is the orthogonal rotation matri, RR = I, and etc are column vectors.
3CG 2006 2 / Build transformations in steps... Often useful to introduce intermediate coordinate frames. For eample: Object model described in body-centered frame B Pose (θ, t) of model frame given w.r.t. world frame W Where is B in W? y B y W y y Model B A B B t W θ A ( ) cos θ sin θ In an aligned frame A = sin θ cos θ B. Check using the point (, 0). It should be (+ cos θ, + sin θ) in the A frame. Then W = A + t Origin of B in W. Check the above using the origin of A. It should be t OBW in W frame...
3CG 2006 3 / In 3D... In 3D the transformation X = R 3 3 X + T has 6 dof. Two major ways of representing 3 rotation rotation about successive new aes: eg ZYX Euler angles rotation about old fied aes : eg ZXY roll-pitch-yaw In each case the order is important, as rotations do not commute. X W = X = X 2 = cos p sin p 0 sin p cos p 0 0 0 cos e 0 sin e 0 0 sin e 0 cos e 0 0 0 cos c sin c 0 sin c cos c X X 2 X B z 2 z 2 e e c p y z B y W z 2 p W y B c y 2
3CG 2006 4 / Rotation about old fied aes : eg ZXY roll-pitch-yaw Y Y X X Start Z Z Roll about ORIG Z Y Y X X Z Pitch about orig X Z Yaw about orig Y
3CG 2006 5 / Class II: Similarity transformations A Euclidean transformation is an isometry an action that preserves lengths and angles. Apply an isotropic scaling s to an isometry isotropic scaling and you ll arrive at a similarity transformation. A similarity had 4 degrees of freedom in 2D = sr + t A similarity preserves ratios of lengths ratios of areas, and angles. It is the most general transformation that preserves shape.
3CG 2006 6 / Class III: Affine transformations An affine transformation (6 degrees of freedom in 2D) is a non-singular linear transformation followed by a translation: ( ) y = with A a 2 2 non-singular matri. In vector form: A ( y = A + t Angles and length ratios are not preserved. ) ( ) t + t y How many points required to determine an affine transform in 2D?
3CG 2006 7 / Eamples of affine transformations Both the previous classes: Euclidean, similarity. 2 Scalings in the and y directions [ ] µ 0 A = 0 µ 2 This is non-isotropic if µ =µ 2. 3 If A is a symmetric matri. then A can be decomposed as: (it s an eigen-decomposition) [ ] [ ] [ ] A = R D R cos θ sin θ λ 0 cos θ sin θ = sin θ cos θ 0 λ 2 sin θ cos θ where λ and λ 2 are its eigenvalues. i.e. scalings in two dirns rotated by θ.
3CG 2006 8 / Affine transformations map parallel lines to... Always useful to think what is preserved in a transformation... A (λ) = a + λd B (λ) = b + µd = A + t A(λ) = A(a + λd) + t = (Aa + t) + λ(ad) = a + λd B(µ) = A(b + µd) + t = (Ab + t) + µ(ad) = b + µd Lines are still parallel they both have direction d. Affine transformations also preserve... λ = 0 a µ = 0 b λ µ d d
3CG 2006 9 / Homogeneous notation motivation If the translation t is zero, then transformations can be concatenated by simple matri multiplication: = A and 2 = A 2 THEN 2 = A 2 A However, if the translation is non-zero it becomes a mess = A + t 2 = A 2 + t 2 = A 2 (A + t ) + t 2 = (A 2 A ) + (A 2 t + t 2 ) ( ) If instead 2D points are represented by a three vector y y then the transformation can be represented by a 3 3 matri...
3CG 2006 20 / Homogeneous notation The matri has block form: ( ) = [ A t 0 ] ( a a 2. t ) = a 2 a 22. t y.......... 0 0. y... = ( A + t Transformations can now ALWAYS be concatenated by matri multiplication ( ) [ ] ( ) ( ) A t A + t = 0 = ( ) [ ] ( ) [ ] [ ] ( ) 2 A2 t 2 A2 t 2 A t = 0 = 0 0 [ ] ( ) ( ) A2 A A 2 t + t 2 (A2 A = 0 = ) + (A 2 t + t 2 ) )
3CG 2006 2 / Homogeneous notation definition = (, y) is represented in homogeneous coordinates by any 3-vector 2 3 such that = / 3 y = 2 / 3 So the following homogeneous vectors represent the same point for any λ=0. λ 2 3 and λ 2 λ 3 For eample, the homogeneous vectors (2, 3, ) and (4, 6, 2) represent the same inhomogeneous point (2, 3)
3CG 2006 22 / Homogeneous notation rules for use Then the rules for using homogeneous coordinates for transformations are. Convert the inhomogeneous point to an homogeneous vector: ( y ) y 2. Apply the 3 3 matri transformation. 3. Dehomogenise the resulting vector: 2 3 ( ) / 3 2 / 3 NB the matri needs only to be defined up to scale. E.g. 2 3 4 5 6 0 0 and 2 4 6 8 0 2 0 0 2 represent the SAME 2D affine transformation Think about degrees of freedom...
3CG 2006 23 / Homogeneous notation for R 3 A point X = X Y Z is represented by a homogeneous 4-vector: X X 2 X 3 X 4 such that X = X X 4 Y = X 2 X 4 Z = X 3 X 4
3CG 2006 24 / Eample: The Euclidean transformation in 3D X = RX + T where R is a 3 3 rotation matri, and T a translation 3-vector, is represented as X [ ] X [ ] ( ) X 2 R T X 3 = Y R T X 0 Z = 0 X 4 4 4 with X = X Y Z = X 4 X X 2 X 3
3CG 2006 25 / Application to coordinate frames: Eg - stereo cameras R L W ( XR ) = [ RRW T RW 0 ] ( XW ) ( XL ) = [ RLW T LW 0 ] ( XW ) Then ( XR ) = [ RRW T RW 0 ] [ RLW T LW 0 ] ( XL ) = [ 4 4 ] ( XL )
3CG 2006 26 / Application to coordinate frames: Eg - Puma robot arm Link 3 Link 2 Links 4,5,6 Link Base Frame Tool Frame Kinematic chain: ( ) [ ] [ XT RT6 T T6 R32 0 = 0... 0 [ ] ( ) 4 4 XB = ] [ R2 T 2 0 ] [ RB T B 0 ] ( X
3CG 2006 27 / A note on the inverse... It must be the case that [ RAB T AB 0 ] = [ RBA T BA 0 ] Now, we know that but what is T BA? Tempting to say T AB, but no. R BA = R AB X A = R AB X B + T AB (T AB is Origin of B in A) X B = R BA (X A T AB ) X B = R BA X A R BA T AB BUT X B = R BA X A + T BA (T BA is Origin of A in B) T BA = R BA T AB
3CG 2006 28 / Class IV: Projective transformations A projective transformation is a linear transformation on homogeneous n-vectors represented by a non-singular n n matri. In 2D 2 3 = h h 2 h 3 h 2 h 22 h 23 h 3 h 32 h 33 Note the difference from an affine transformation is only in the first two elements of the last row. In inhomogeneous (normal) notation, a projective transformation is a non-linear map = 3 = h + h 2 y + h 3, y = 2 h 3 + h 32 y + h 33 3 = h 2 + h 22 y + h 23 h 3 + h 32 y + h 33 The 3 3 matri has 8 dof... 2 3
3CG 2006 29 / Class IV: 3D-3D Projective transformations In 3D X X 2 X 3 X 4 = p p 2 p 3 p 4 p 2 p 22 p 23 p 24 p 3 p 32 p 33 p 34 p 4 p 42 p 43 p 44 X X 2 X 3 X 4 The 4 4 matri has 5 dof...
3CG 2006 30 / Perspective is a subclass of projective transformation
3CG 2006 3 / Perspective (central) projection 3D to 2D Mathematical idealized camera 3D 2D Image coordinates y Camera frame XYZ (origin at optical centre) Focal length f, image plane is at Z = f. Use similar triangles f = X Z y f = Y Z or = f X Z where and X are 3-vectors, with = (, y, f ), X = (X, Y, Z ). O Y f X f y y image plane Z Z X Y
3CG 2006 32 / Eamples Circle in space, orthogonal to and centred on the Z -ais: Y X X(θ) = (a cos θ, a sin θ, Z ) a (θ) = ( fa Z cos θ, fa Z sin θ, f ) Z (, y) = fa (cos θ, sin θ) Z Image is a circle of radius fa/z inverse distance scaling Now move circle in X direction: that is, to X (θ) = (a cos θ + X 0, a sin θ, Z ) Eercise: What happens to the image? Is it still a circle? Is it larger or smaller?
3CG 2006 33 / Eamples ctd/ Sphere concentric with Z -ais: Y X Z grazing cone rays Intersection of cone with image plane is a circle. Eercise: Now move sphere in the X direction. What happens to the image?
3CG 2006 34 / The Homogeneous 3 4 Projection Matri In inhomogeneous coords = f X/Z Choose f = from now on. O Y f X y Z X Homogeneous image coordinates (, 2, 3 ) represent = X/Z if X 0 0 0 ( ) 2 = 0 0 0 Y X Z = [I 0] 3 0 0 0 Check that = / 3 = X/Z y = 2 / 3 = Y /Z Then perspective projection is a linear map, represented by a 3 4 projection matri, from 3D to 2D.
3CG 2006 35 / Eample: a 3D point Non-homogeneous X Y Z (, y) = (6/2, 4/2) = (3, 2). = 6 4 2 is imaged at In homogeneous notation using 3 4 projection matri: 6 λ 0 0 0 λy = 2 = 0 0 0 4 6 2 = 4 λ 3 0 0 0 2 which is the 2D inhomogeneous point (, y) = (3, 2).
3CG 2006 36 / Suppose scene is describe in a World coord frame ( XC The Euclidean transformation between the camera and world coordinate frames is X C = RX W + T: ) = [ R T 0 ] ( XW ) XC OC YC Z C R, T O W ZW Y W Concatenating the two matrices... 2 = 0 0 0 [ 0 0 0 R T 0 3 0 0 0 ] ( XW ) X W ( XW = [ R T] ) which defines the 3 4 projection matri P = [R T] from a Euclidean World coordinate frame to an image.
3CG 2006 37 / Suppose scene described as set of Objects and Poses Now each 3D object O is described in it own Object frame... Each Object frame is given a Pose [R o, T o ] relative to World frame... Cameras are placed at [R c, T c ] relative to world frame... ( c ) = K c 0 0 0 0 0 0 0 0 0 [ Rc T c 0 ] [ Ro T o 0 ] ( Xo ) 3 3 matri K c allows each camera to have a different focal length etc... You can now do 3D computer graphics...
3CG 2006 38 / Isn t every projective transform a perspective projection? A projective trans followed by a projective trans is a... So a perspective trans followed by a perpspective trans is a... A C B B C A
3CG 2006 38 / Isn t every projective transform a perspective projection? A projective trans followed by a projective trans is a... So a perspective trans followed by a perpspective trans is a... A B C A C B B C A
3CG 2006 38 / Isn t every projective transform a perspective projection? A projective trans followed by a projective trans is a... So a perspective trans followed by a perpspective trans is a... A B C A C B B C A