Computational Geometry - University of Oxfordian/Teaching/CompGeom/lec1.pdf · Lecture 4: Bezier...

21
Computational Geometry 4 Lectures Michaelmas Term 2003 1 Tutorial Sheet Dr ID Reid Overview Computational geometry is concerned with efficient algorithms and representa- tions for geometric computation. Techniques from computational geometry are used in: Computer Graphics Computer Vision Computer Aided Design Robotics Topics 0.1 Lecture 1: Euclidean, similarity, affine and projective transformations. Homo- geneous coordinates and matrices. Coordinate frames. Perspective projection and its matrix representation. Lecture 2: Perspective projection and its matrix representation. Vanishing points. Applications of projective transformations. Lecture 3: Convexity of point-sets, convex hull and algorithms. Conics and quadrics, implicit and parametric forms, computation of intersections. Lecture 4: Bezier curves, B-splines. Tensor-product surfaces. 1

Transcript of Computational Geometry - University of Oxfordian/Teaching/CompGeom/lec1.pdf · Lecture 4: Bezier...

  • Computational Geometry4 Lectures Michaelmas Term 2003

    1 Tutorial Sheet Dr ID Reid

    Overview

    Computational geometry is concerned with efficient algorithms and representa-tions for geometric computation.

    Techniques from computational geometry are used in:� Computer Graphics� Computer Vision� Computer Aided Design� RoboticsTopics 0.1

    � Lecture 1: Euclidean, similarity, affine and projective transformations. Homo-geneous coordinates and matrices. Coordinate frames. Perspective projectionand its matrix representation.� Lecture 2: Perspective projection and its matrix representation. Vanishing points.Applications of projective transformations.� Lecture 3: Convexity of point-sets, convex hull and algorithms. Conics andquadrics, implicit and parametric forms, computation of intersections.� Lecture 4: Bezier curves, B-splines. Tensor-product surfaces.

    1

  • Useful Texts 0.2� Bartels, Beatty and Barsky, “An introduction to splines for use in computer graphics andgeometric modeling”, Morgan Kaufmann, 1987. Everything you could want to know aboutsplines.� Faux and Pratt, “Computational geometry for design and manufacture”, Ellis Horwood,1979. Good on curves and transformations.� Farin, “Curves and Surfaces for Computer-Aided Geometric Design : A Practical Guide”,Academic Press, 1996.� Foley, van Dam, Feiner and Hughes, “Computer graphics - principles and practice”, Addi-son Wesley, second edition, 1995. The computer graphics book. Covers curves and surfaceswell.� Hartley and Zisserman “Multiple View Geometry in Computer Vision”, CUP, 2000. Chapter1 is a good introduction to projective geometry.� O’Rourke, “Computational geometry in C”, CUP, 1998. Very straightforward to read, manyexamples. Highly recommended.� Preparata and Shamos, “Computational geometry, an introduction”, Springer-Verlag, 1985.Very formal and complete for particular algorithms.

    Example I: Virtual Reality Models from Images 0.3

    Input: Four overlapping aerial images of the same urban scene

    Objective: Texture mapped 3D models of buildings

    2

  • 1: Transformations, HomogeneousCoordinates, and Coordinate Frames

    Topics 1.1

    � Lecture 1: Euclidean, similarity, affine and projective transformations. Ho-mogeneous coordinates and matrices. Coordinate frames.� Lecture 2: Perspective projection and its matrix representation. Vanishingpoints. Applications of projective transformations.� Lecture 3: Convexity of point-sets, convex hull and algorithms. Conics andquadrics, implicit and parametric forms, computation of intersections.� Lecture 4: Bezier curves, B-splines. Tensor-product surfaces.

    3

  • Hierarchy of transformations 1.2

    We will look at linear transformations represented by matricesof increasing generality:� Euclidean � Similarity � Affine � projective.Consider both����� � ��� mappings (“plane to plane”); and���� � �� transformationsas well as���� � ��� mappings (“projections”)Class I: Euclidean transformations: translation & rotation 1.3

    1. Translation — 2 dof in 2D���� ���� ��� ��� ������� �O

    t

    t

    x

    y

    2. Rotation — 1 dof in 2D�� � �� � � �"!$#&% '�#)(+*,%#)(+*-% �.!�#/% 0 ��� �O

    θ

    θ

    x

    y

    In vector notation, a Euclidean transformation is written1 �32 1 �54where 2 is the orthogonal rotation matrix, 262�78� 9 , and 1 etc are column vectors.

    4

  • Build transformations in steps ... 1.4

    Often useful to introduce intermediate coordinate frames.Example: Object model described in body-centered coord frame. Pose ( %;: 4=< ofmodel frame given w.r.t. world coord frame. Where is 1?> in the world?

    By

    Bx

    Model By

    Bx

    x

    y

    W

    W

    x

    yA

    A

    θt

    1A@ � �"!$#&% 'B#)(+*-%#C(D*-% �"!$#/% � 1 >Check the above using the point EGF :IH < . It should be E � �"!$#/%J: � #)(D*-% < in the A frame.1�K � 1A@ �L4NM;O+PRQ�PRSUTWV;XYPRS[ZCheck the above using the origin of A. It should be 4]\ > K in W frame ...

    5

  • In 3D ... 1.5

    In 3D the transformation ^ �326_"`=_ ^ �ba has 6 dof.Two major ways of defining 3D rotation:(i) rotation about successive new axes: eg YXY pan-tilt-verge, or XYZ tilt-pan-cyclorotation(ii) rotation about “old fixed axes”: eg ZXY roll-pitch-yawIn each case the order is important, as rotations do not commute.

    ^ K � cd �.!$#�e '�#)(+*fe H#)(+*[e �.!�#$e HH H Fgh ^ji

    ^ i � cd �.!$#&k H 'B#)(+*lkH F H#)(+*lk H �"!$#&kgh ^nm

    ^8m � cd F H HH �"!$#/o 'B#C(D*-oH #)(+*,o �"!$#/ogh ^ >

    e c

    p x

    y

    W

    1

    y1 W x

    p

    z

    x

    x

    z

    1

    2

    12

    e

    zB

    yB

    2

    2z

    yc

    Rotation about an axis 1.6

    The rotation matrix corresponding to a rotation of an angle % about an axis withunit length p � qsr � : r � : rtGu+v is given by:w � cd �"!$#&% � EGF '5�"!$#&%

  • Rotation example 1.7

    Consider a pan-tilt device:

    7

  • Rotation example: successive new axes 1.8

    1. Tilt: rotate by angle�

    about�

    -axisw > i � cd F H HH �.!$# � 'B#C(D* �H #)(D* � �"!$# �gh

    2. Pan: rotate by angle e about new � -axis� � w � E � < � � q H}:C�.!$# � :C#C(D* � u vw m i � w �G~ � cd �"!$#�e 'B#)(+*Ue�#)(D* � #)(+*[el�.!$# �#C(D*Ue�#)(+* � �.!�#e � EGF '5�.!�#e < �.!$# m � E)F 'y�.!$#�e < �"!$# � #C(D* �'B#C(D*Ue��"!$# � EGF '5�.!�#e < �.!$# � #)(+* � �"!$#�e � EGF '5�"!$#e < #)(+* � mgh

    Hence w m > � w m i w i > � cd �"!$#�e H #)(+*Ue#)(+* � #)(+*[e �"!$# � '�#)(D* � �"!$#�e'��"!$# � #C(D*[e #)(+* � �"!$# � �"!$#�egh

    8

  • Rotation example: fixed axes 1.9

    A little thought suggests an alternative derivation ofw m > .

    Start at the end of the kinematic chain when all axes in their rest positions.

    Now

    1. Rotate pan axis around fixed � -axiscd �"!$#�e H #)(+*[eH F H'B#C(D*[e H �"!$#�egh

    2. Rotate tilt axis around�

    -axis which was unaffected by previous rotationcd F H HH �.!$# � 'B#C(D* �H #)(+* � �"!$# �gh

    Yieldingcd F H HH �"!$# � '�#)(D* �H #)(+* � �"!$# �gh cd �"!$#e H #)(+*[eH F H'B#)(+*Ue H �"!$#e

    gh � cd �"!$#�e H #)(+*[e#)(D* � #)(+*fe �.!$# � 'B#C(D* � �"!$#�e'��"!$# � #C(D*Ue #)(+* � �"!$# � �"!$#�egh

    as before.

    9

  • Class II: Similarity transformations 1.10

    A Euclidean transformation is an isometry — an action that preserves lengthsand angles.

    An Isometry composed with isotropic scaling, is called a similarity transforma-tion.

    A similarity — 4 degrees of freedom in 2D1 � 2 1 �L4A similarity— preserves ratios of lengths, ratios ofareas, and angles.— is the most general transformationthat preserves “shape”.

    Class III: Affine transformations 1.11

    An affine transformation (6 degrees of freedom in 2D)— is a non-singular linear transformation followed by a translation:���� �� � cd gh ��� � � �� �� � �with a ��� non-singular matrix.In vector form: 1 �3 1 �54� Angles and length ratios are not preserved.� How many points required to determine an affine transform in 2D?

    10

  • Examples of affine transformation 1.12

    1. Both the previous classes: Euclidean, similarity.

    2. Scalings in the�

    and � directions� � i HH m 0

    This is non-isotropic if i�� m .3. a symmetric matrix.

    Then can be decomposed as: it’s an eigen-decomposition�322 7 � � �"!$#&% 'B#)(+*-%#C(D*-% �.!$#&% 0 � i HH m 0 � �.!�#|% #)(+*l%'�#)(+*l% �"!$#&% 0where i and m are its eigenvalues. i.e. scalings in two dirns rotated by % .

    Affine transformations map parallel lines to parallel lines 1.13

    It is always useful to think what is preserved in a transformation ...1A E < � p � /1 X E < � � 1 � 1 �541 E < � Ep � �

  • Homogeneous notation — motivation 1.14

    If the translation 4 is zero, then transformations can be concatenated by simplematrix multiplication:1 i � i 1 *� 1 m �3 m 1 i lY 1 m � m i 1However, if the translation is non-zero it becomes a mess1 i � i 1 �54 i1 m � m 1 i �y4 m� m E i 1 �y4 i

  • Homogeneous notation — definition 1.161 � E � : �

  • Homogeneous notation for ¨® 1.18A point ^ � 5¯ ° ± is represented by a homogeneous 4-vector:¦¦ ¯ i¯ m¯ _¯²

    "§§such that ¯ � ¯ i¯ ² ° � ¯ m¯ ² ± � ¯ _¯ ²Example: The Euclidean transformation in 3D 1.19

    ^ �³2 ^ �bawhere 2 is a ��� rotation matrix, and a a translation 3-vector, is represented as¦¦ ¯ i¯ m¯ _¯ ²

    "§§ � � 2 a  7 F 0 ² ` ² ¦¦ ¯ ° ± F"§§ � � 2 a  7 F 0 ^ F �

    with ^ � ¯ ° ± � F¯ ² ¯

    i¯ m¯ _

    14

  • Application to coordinate frames: Example - stereo camera rig 1.20

    W

    R L

    ^n´F � � � 2 ´ Z a ´ Z  7 F 0 ^ ZF � ^¶µF � � � 2 µ Z a µ Z  7 F 0 ^ ZF �Then ^ ´F � � � 2 ´ Z a ´ Z  7 F 0 � 2 µ Z a µ Z  7 F 0¸· i ^ µF � � � ª ª 0 ^ µF �Application to coordinate frames: Example - Puma robot arm 1.21

    Links4,5,6

    Link 1

    Link 2

    Link 3

    Base Frame Tool Frame

    Kinematic chain: ^n¹F � � � 2 ¹º a ¹º  7 F 0 ¢£¢£¢ � 2 _ m    7 F 0 � 2 m i a m i  7 F 0 � 2 i X a i X  7 F 0 ^ XF �� � ª ª 0 ^ XF �15

  • A note on the inverse ... 1.22

    � 2 X a X  7 F 0»· i � � 26X a¼X   7 F 0Now, 2 X �32 · i Xbut what is a½X ¿¾Tempting to say ' a X , but no.^ @ � 2 @ > ^ > �Àa @ > EÂÁYà (DÄ(D*Å!�ÆUÇÈ(D*ÊÉ � 2 > @ E^ @ ' a @ > � 2 > @ ^ @ ' 2 > @ a @ >ÇÍÌ 5^ > � 2 > @ ^ @ �Àa > @ EÂÁYà (DÄ(D*Å!�ÆÎÉ�(D*Ç @ � ' 2 > @ a @ >Class IV: Projective transformations 1.23

    A projective transformation is a linear transformation on homogeneous Ï -vectorsrepresented by a non-singular Ï Ï matrix.2D — plane to plane �/ i� m� _ � cdÑÐ i�i Ð i m Ð i _Ð m i Ð m�m Ð m _Ð _ i Ð _ m Ð _�_

    gh � i� m� _ � Note the difference from an affine transformation is only in the first two ele-ments of the last row.� In inhomogeneous (normal) notation, a projective transformation is a non-linear map� � �� i� _ � Ð i�i � � Ð i m � � Ð i _Ð _ i � � Ð _ m � � Ð _�_ : � � ��m� _ � Ð m i � � Ð m�m � � Ð m _Ð _ i � � Ð _ m � � Ð _�_� The �ÒÓ� matrix has 8 dof ...

    16

  • Class IV: 3D-3D Projective transformations 1.24

    3D

    ¦¦ ¯ i¯ m¯ _¯ ² §§ � c¡¡d e i�i e i m e i _ e i ²e m i e m�m e m _ e m ²e _ i e _ m e _�_ e _ ²e ² i e ² m e ² _ e ²�²

    g ¤¤h ¦¦ ¯ i¯ m¯ _¯ ² §§

    � The ª ª matrix has 15 dof ...Perspective projection is a subclass of projective transformation1.25

    17

  • Perspective (central) projection — 3D to 2D 1.26

    The camera model Mathematical ideal-ized camera 3D � 2D� Image coordinates � �� Camera frame ¯ ° ± (origin at opticalcentre)� Focal length Ô , image plane is at ± �Ô .

    y

    Y

    O

    imageplane

    x

    f

    X

    x

    Z

    X

    Similar triangles� Ô � ¯ ± �Ô � ° ± ! Ã 1 � Ô ^ ±where 1 and ^ are 3-vectors, with1 � E � : � : Ô < 7 , ^ � E ¯ : ° : ± < 7 . f Z

    yY

    Examples 1.27

    1. Circle in space, orthogonal to and centred on the±

    -axis:

    X

    Y

    Z

    a

    ^ÕE % < � E r �.!�#/%J: r #)(+*l%;: ± < 71 E % < � E Ô r± �.!�#|%;: Ô r± #)(+*-%;: Ô < 7Ë E � : � < � Ô r± E �.!$#/%;:I#)(+*,% <Image is a circle of radius Ô r © ±— inverse distance scaling

    2. Now move circle in ¯ direction:^ i E % < � E r �"!$#&% � ¯×Ö : r #)(+*-%;: ± < 7Exercise What happens to the image? Is it still a circle? Is it larger or smaller?18

  • Examples ctd/ 1.28

    3. Sphere concentric with±

    -axis:

    X

    Y

    Z

    conegrazing

    rays

    Intersection of cone with image plane is a circle.

    Exercise Now move sphere in the ¯ direction. What happens to the image?The Homogeneous Ø5Ù¨Ú Projection Matrix 1.29

    1 � Ô ^ ±Choose Ô � F from now on.

    X

    y

    Y

    Z

    O

    x

    X

    x

    f

    Homogeneous image coordinates E � i : � m : � _ < 7 correctly represent 1 � ^Û© ± if � i� m� _ � cd F H H HH F H HH H F H

    gh ¦¦ ¯ ° ± F"§§ � qÜ9Ý   u ^ F �

    because then � � � i� _ � ¯ ± � � � m� _ � ° ±Then perspective projection is a linear map, represented by a �� ª projectionmatrix, from 3D to 2D.

    19

  • Example: a 3D point 1.30

    Non-homogeneous Þ¯ ° ± � «ª � is imaged at E � : � < � E « © � : ª;© �

  • Suppose scene is described as set of Objects and Poses ... 1.32

    � Now each 3D object â is described in it own Object frame ...� Each Object frame is given a Pose qá2Jã : a¼ã�u relative to World frame ...� Cameras are placed at qá2Jä : aÅäåu relative to world frame ... 1 äF � �3æ6äcd F H H HH F H HH H F Hgh � 2;ä aÅä  7 F 0 · i � 2 ã a ã  7 F 0 ^ ãF ����B� matrix æ;ä allows each camera to have a different focal length etc ...� You can now do 3D computer graphics ...

    Isn’t every projective transformation a perspective projection? 1.33

    � A projective trans followed by a projective trans is a ........................................� So a perspective trans followed by a perpspective trans is a ........................................A

    B

    CC

    B

    A

    A BC

    21