You are on page 1of 40

1/1

3CG 2006

B4 Computational Geometry

David Murray
david.murray@eng.ox.ac.uk
www.robots.ox.ac.uk/dwm/Courses/3CG

Michaelmas 2006

2/1

3CG 2006

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

3/1

3CG 2006

Topics
Lecture 1: Euclidean, similarity, affine and projective
transformations. Homogeneous 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.

4/1

3CG 2006

Useful Texts
Bartels, Beatty and Barsky, An introduction to splines for use in computer
graphics and geometric modeling, Morgan Kaufmann, 1987. Everything you
could want to know about splines.
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, Addison Wesley, second edition, 1995. The computer graphics
book. Covers curves and surfaces well.
Hartley and Zisserman Multiple View Geometry in Computer Vision, CUP,
2000. Chapter 1 is a good introduction to projective geometry.
ORourke, Computational geometry in C, CUP, 1998. Very straightforward
to read, many examples. Highly recommended.
Preparata and Shamos, Computational geometry, an introduction,
Springer-Verlag, 1985. Very formal and complete for particular algorithms.

5/1

3CG 2006

Example I: Virtual Reality Models from Images


Input: Four overlapping aerial images of the same urban scene

Objective: Texture mapped 3D models of buildings

3CG 2006

Example II: Video Mosaicing

6/1

3CG 2006

Example II: Video Mosaicing

7/1

3CG 2006

Example II: Video Mosaicing

8/1

9/1

3CG 2006

Lecture 1.
Lecture 1:
Transformations, Homogeneous Coordinates, and Coordinate
Frames

Euclidean, similarity, affine and projective transformations.


Homogeneous coordinates and matrices.
Coordinate frames.

10 / 1

3CG 2006

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

11 / 1

3CG 2006

Class I: Euclidean transformations: translation &


rotation
1. Translation 2 dof in 2D
 
 0  

x
tx
x
=
+
y0
y
ty
2. Rotation 1 dof in 2D
 0  


x
cos sin
x
=
y0
sin
cos
y

t
O

O
In vector notation, a Euclidean transformation is written

x0 = Rx + t
R is the orthogonal rotation matrix, RR > = I, and x0 etc are column
vectors.

12 / 1

3CG 2006

Build transformations in steps ...


Often useful to introduce intermediate coordinate frames. For
example:
Object model described
in body-centered frame
B
Pose (, t) of model
frame given w.r.t. world
frame W
Where is xB in W ?

y
B

Model

y
W

y
B

y
A
x
B

t
x
B

xA
x


cos sin
In an aligned frame xA =
xB .
sin
cos
Check using the point (1, 0). It should be (+ cos , + sin ) in the
A frame.
Then xW = xA + tOrigin of B in W .
Check the above using the origin of A. It should be tOBW in W
frame ...

13 / 1

3CG 2006

In 3D ...
In 3D the transformation X0 = R 33 X + T has 6 dof. Two major ways
of representing 3 rotation
rotation about successive new axes: eg ZYX Euler angles
rotation about old fixed axes: eg ZXY roll-pitch-yaw
In each case the order is important, as rotations do not commute.

XW

X1

X2

cos p sin p 0
cos p 0
= sin p
0
0
1

cos e 0 sin e
1
0
= 0
sin e 0 cos e

1
0
0
= 0 cos c sin c
0 sin c
cos c

X1

y
1

y
W

X2

z2

z1
e

XB

x2
x1

z
B

x
1
p
x

2
y
B
c
y
2

14 / 1

3CG 2006

Rotation about old fixed axes: eg ZXY roll-pitch-yaw


Y

Start

Roll about ORIG Z

Y
X

Pitch about orig X

Yaw about orig Y

15 / 1

3CG 2006

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
youll arrive at a similarity transformation.
A similarity had 4 degrees of freedom in 2D
x0 = sRx + t
A similarity preserves
ratios of lengths
ratios of areas, and
angles.
It is the most general
transformation that
preserves shape.

16 / 1

3CG 2006

Class III: Affine transformations


An affine transformation (6 degrees of freedom in 2D)
is a non-singular linear transformation followed by a
translation:


 

 0 
x
tx
x

A
+
=
y
ty
y0
with A a 2 2 non-singular matrix.
In vector form:
x0 = Ax + t
Angles and length ratios are not preserved.
How many points required to determine an affine transform in
2D?

17 / 1

3CG 2006

Examples of affine transformations


1

Both the previous classes: Euclidean, similarity.

Scalings in the x and y directions




1 0
A=
0 2

This is non-isotropic if 1 =2 .
3

If A is a symmetric matrix.
then A can be decomposed as: (its an eigen-decomposition)




cos sin
1 0
cos
sin
A = R D R> =
sin
cos
0 2
sin cos
where 1 and 2 are its eigenvalues. i.e. scalings in two dirns
rotated by .

18 / 1

3CG 2006

Affine transformations map parallel lines to ...


Always useful to think what is preserved in a transformation ...

xA ()

= a + d

xB ()

x0A ()

x0B ()

b + d

= Ax + t
=

A(a + d) + t

(Aa + t) + (Ad)

a0 + d0

A(b + d) + t

(Ab + t) + (Ad)

=0
b

= b0 + d0
Lines are still parallel they both have direction d0 .
Affine transformations also preserve ...

=0

19 / 1

3CG 2006

Homogeneous notation motivation


If the translation t is zero, then transformations can be
concatenated by simple matrix multiplication:
x1 = A1 x and x2 = A2 x1 THEN x2 = A2 A1 x
However, if the translation is non-zero it becomes a mess
x1

A1 x + t1

x2

A2 x1 + t2

A2 (A1 x + t1 ) + t2

(A2 A1 )x + (A2 t1 + t2 )

x
are represented by a three vector
y

=


If instead 2D points

x
y then the transformation can be represented by a 3 3
1
matrix ...

20 / 1

3CG 2006

Homogeneous notation
The matrix has block form:

..

a
a
.
t
x
11
12



..
a21 a22 . ty
t
x

1
1
. . . . . . ... . . .

..
0 0 . 1

x0
1


=

A
0>

x


y
Ax + t
=
...
1
1

Transformations can now ALWAYS be concatenated by matrix


multiplication




 

A1 t 1
x1
x
A1 x + t1
=
=
1
1
1
0> 1




 



A2 t 2
A2 t2
A1 t1
x2
x1
x
=
=
1
1
1
0> 1
0> 1
0> 1


 

A2 A1 A2 t1 + t2
x
(A2 A1 )x + (A2 t1 + t2 )
=
=
1
1
0>
1

21 / 1

3CG 2006

Homogeneous notation definition


x = (x, y )> is represented in homogeneous coordinates by any
3-vector

x1
x2
x3
such that
x = x1 /x3

y = x2 /x3

So the following homogeneous vectors represent the same point


for any =0.

x1
x1
x2 and x2
x3
x3
For example, the homogeneous vectors (2, 3, 1)> and (4, 6, 2)>
represent the same inhomogeneous point (2, 3)>

22 / 1

3CG 2006

Homogeneous notation rules for use


Then the rules for using homogeneous coordinates for
transformations are
1. Convert the inhomogeneous
point to an homogeneous
vector:



x
x
y
y
1

NB the matrix needs only to be


defined up to scale.
E.g.

1 2 3
2 4
6
4 5 6 and 8 10 12
0 0 1
0 0
2

2. Apply the 3 3 matrix


transformation.
3. Dehomogenise the resulting
vector:



x1
x1 /x3
x2
x2 /x3
x3

represent the SAME 2D affine


transformation
Think about degrees of freedom
...

23 / 1

3CG 2006

Homogeneous notation for R3


A point

X
X= Y
Z
is represented by a homogeneous 4-vector:

X1
X2

X3
X4
such that
X =

X1
X4

Y =

X2
X4

Z =

X3
X4

24 / 1

3CG 2006

Example: The Euclidean transformation in 3D


X0 = RX + T
where R is a 3 3 rotation matrix, and T a translation 3-vector, is
represented as

0
X
X1





Y
X0
R T
R T
X

20 =
=
X3
1
0> 1 44 Z
0> 1
0
X4
1
with

0
X0
X1
1
X0 = Y 0 = 0 X20
X4
Z0
X30

25 / 1

3CG 2006

Application to coordinate frames: Eg - stereo cameras


R

R RW
0>

TRW
1



Then

 
R RW
XR
=
1
0>

TRW
1



XR
1


=

XW
1

R LW
0>

TLW
1

XL
1

1 

R LW
0>

TLW
1



XW
1

44



XL
1

XL
1

26 / 1

3CG 2006

Application to coordinate frames: Eg - Puma robot arm


Link 3
Link 2

Links
4,5,6

Link 1
Base Frame Tool Frame

Kinematic chain:



 

R T6 TT6
R 32 0
R 21
XT
=
...
1
0>
1
0> 1
0>



44
XB
=
1

T21
1



R 1B
0>

T1B
1



X
1

27 / 1

3CG 2006

A note on the inverse ...


It must be the case that

1 
R AB TAB
R BA
=
0>
1
0>

TBA
1

Now, we know that


R BA = R 1
AB
but what is TBA ?
Tempting to say TAB , but no.
XA

= R AB XB + TAB

XB

= R BA (XA TAB )

XB

= R BA XA R BA TAB

BUT XB
TBA

= R BA XA + TBA
= R BA TAB

(TAB is Origin of B in A)

(TBA is Origin of A in B)

28 / 1

3CG 2006

Class IV: Projective transformations


A projective transformation is a linear transformation on
homogeneous n-vectors represented by a non-singular n n
matrix.
In 2D


h11
x10
x20 = h21
x30
h31

h12
h22
h32

h13
x1
h23 x2
h33
x3

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
x0 =

x10
h11 x + h12 y + h13
=
,
x30
h31 x + h32 y + h33

The 3 3 matrix has 8 dof ...

y0 =

x20
h21 x + h22 y + h23
=
x30
h31 x + h32 y + h33

29 / 1

3CG 2006

Class IV: 3D-3D Projective transformations


In 3D

p11
X10
X 0 p21
20 =
X3 p31
X40
p41

p12
p22
p32
p42

The 4 4 matrix has 15 dof ...

p13
p23
p33
p43

p14
X1
X2
p24

p34 X3
p44
X4

3CG 2006

Perspective is a subclass of projective transformation

30 / 1

31 / 1

3CG 2006

Perspective (central) projection 3D to 2D


Y

Mathematical idealized
camera 3D 2D

Image coordinates xy

X
y

Camera frame XYZ (origin


at optical centre)

O
f

Focal length f , image plane


is at Z = f .

image
plane

Use similar triangles


Y

x
X
=
f
Z

Y
y
=
f
Z

X
or x = f
Z

where x and X are 3-vectors, with


x = (x, y , f )> , X = (X , Y , Z )> .

y
f
Z

32 / 1

3CG 2006

Examples
Circle in space, orthogonal to and centred on the Z -axis:
Y
X

a
Z

X()

x()

(x, y )

(a cos , a sin , Z )>


fa
fa
( cos , sin , f )>
Z
Z
fa
(cos , sin )
Z

Image is a circle of radius fa/Z


inverse distance scaling
Now move circle in X direction:
that is, to X1 () = (a cos + X0 , a sin , Z )>
Exercise:
What happens to the image? Is it still a circle? Is it larger or smaller?

33 / 1

3CG 2006

Examples ctd/

Sphere concentric with Z -axis:


Y
X

cone

grazing
rays

Intersection of cone with image plane is a circle.


Exercise:
Now move sphere in the X direction. What happens to the image?

34 / 1

3CG 2006

The Homogeneous 3 4 Projection Matrix


Y

In inhomogeneous coords

X
y

x = f X/Z

O
f

Choose f = 1 from now on.


Homogeneous image coordinates (x1 , x2 , x3 )> represent
x = X/Z if

X


x1
1 0 0 0

x2 = 0 1 0 0 Y = [I | 0] X
Z
1
x3
0 0 1 0
1
Check that

x = x1 /x3 = X /Z

y = x2 /x3 = Y /Z

Then perspective projection is a linear map, represented by


a 3 4 projection matrix, from 3D to 2D.

35 / 1

3CG 2006

Example: a 3D point

X
6
Non-homogeneous Y = 4 is imaged at
Z
2
(x, y ) = (6/2, 4/2) = (3, 2).
In homogeneous notation using 3 4 projection matrix:

6
x
x1
1 0 0 0
6

4
4
y = x2 = 0 1 0 0
2 =

x3
0 0 1 0
2
1
which is the 2D inhomogeneous point (x, y ) = (3, 2).

36 / 1

3CG 2006

Suppose scene is describe in a World coord frame


The Euclidean transformation between the camera and world
coordinate frames is XC = RXW + T:
YC
ZW

XC
1


=

R
0>

T
1



XW
1


OC

R, T
ZC
OW

YW

XC

XW

Concatenating the two matrices ...

x1
1 0 0 0 
x2 = 0 1 0 0 R>
0
x3
0 0 1 0

T
1



XW
1


= [ R | T]

which defines the 3 4 projection matrix P = [R| T] from a


Euclidean World coordinate frame to an image.

XW
1

37 / 1

3CG 2006

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 , To ] relative to World
frame ...
Cameras are placed at [R c , Tc ] relative to world frame ...

xc
1

1
= Kc 0
0

0
1
0

0
0
1

0 
Rc
0
0>
0

Tc
1

1 

Ro
0>

To
1



3 3 matrix K c allows each camera to have a different focal


length etc ...
You can now do 3D computer graphics ...

Xo
1

38 / 1

3CG 2006

Isnt 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
C

B
A

38 / 1

3CG 2006

Isnt 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
.............................

C
A
B

C
C

B
A

38 / 1

3CG 2006

Isnt 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
.............................

C
A
B

C
C

B
A

You might also like