You are on page 1of 32

Geometric Fundamentals in Robotics

Homogeneous Coordinates
Basilio Bona
DAUIN-Politecnico di Torino

July 2009

Basilio Bona (DAUIN-Politecnico di Torino)

Rigid motions

July 2009

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.
Given a point p in R2 , represented as P = (p1 , p2 ), i.e., the vector

T
p = p1 p2 its homogeneous representation (using homogeneous
coordinates) is

T
= p1 p2 p3 ;
p


T
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 = p1 /
p3 ;
Basilio Bona (DAUIN-Politecnico di Torino)

p2 = p2 /
p3

Rigid motions

July 2009

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)

Rigid motions

July 2009

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)

Rigid motions

July 2009

4 / 32

The same approach is valid for 3D homogeneous coordinates: given a


point p in R3 , represented as P = (p1 , p2 , p3 ), or else by a vector

T
p = p1 p2 p3

its homogeneous representation is


T
= p1 p2 p3 p4
p

Hence

p1 = p1 /
p4 ;

p2 = p2 /
p4 ;

p3 = p3 /
p4

In robotics it is common to set p4 = 1. We will adhere to this convention.

Basilio Bona (DAUIN-Politecnico di Torino)

Rigid motions

July 2009

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
vp = p
1

while in the second case


vab

     
v
v
v
= b a = ab
1
1
0

Not all textbooks adhere to this convention, since in this case the sum of
two geometric vectors produces
    

vp
vq
vp + vq

vp + vq =
+
=
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)

Rigid motions

July 2009

6 / 32

Figure: Homogeneous sum of two geometric vectors.

Basilio Bona (DAUIN-Politecnico di Torino)

Rigid motions

July 2009

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)

Rigid motions

July 2009

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) = T
0 1
since
Hv =

"

0T

# 
v
= Rv + t
1 1
t

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:
a = Hab (Rab , tab )
pa = gab pb p
pb

Basilio Bona (DAUIN-Politecnico di Torino)

Rigid motions

July 2009

9 / 32

Transformation composition gab gbc is obtained by the homogeneous


matrix product
Hab (Rab , tab )Hbc (Rbc , tbc )
i.e.,

"
#"
Rab tab Rbc
0T

0T

tbc
1

"
Rab Rbc
0T

Rab tbc + tab


1

Often it is convenient to write the time derivative of a homogeneous


vector as

p 1
p

= 2
p
p 3
0

This notation will prove useful when dealing with twists.

Basilio Bona (DAUIN-Politecnico di Torino)

Rigid motions

July 2009

10 / 32

Introduction to projective/perspective geometry


are used for describing point in projective
Homogeneous coordinates p
spaces P n of dimension n.
are equal (
if there exist a real 6= 0 such
and b
Two points a
a b)
that
b
b
collinear points are equal
= b
a
this also means that vectors are equal up to a scale factor.
belong to the same line, i.e., to the same affine
and b
We say that a
subspace of Rn+1 .
Consider the planar (2D) projection through a pinhole camera of a 3D

T
point P, p = x y z . The ray of light intercepts the image plane in
the 2D image point Pi , whose homogeneous coordinates on the image
plane are


T
 
x
1 x T
x/f

i = y
p
pi =
=
y /f
f y
f
where f is the focal distance

Basilio Bona (DAUIN-Politecnico di Torino)

Rigid motions

July 2009

11 / 32

Figure: Example of projection through a pinhole camera.


Basilio Bona (DAUIN-Politecnico di Torino)

Rigid motions

July 2009

12 / 32

Considering the similar triangles in Figure, we have:


x
X
= ;
f
Z

y
Y
=
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
i = fY y y
pi =
p
y /f
Z
1
f


and every 3D point with homogeneous coordinates x
projected onto the same point pi of the image plane .

Notice that the above transformation is a nonlinear one.


Basilio Bona (DAUIN-Politecnico di Torino)

Rigid motions

T

is

July 2009

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
p
Y
fY y = 0 f 0 0
Z pi = P 1
Z
1
0 0 1 0
{z
} 1
|
P

Nonsingular (i.e., invertible) mappings between projective spaces are


described by products of full rank square matrices T by homogeneous
a = Tab p
b
coordinates, p

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)

Rigid motions

July 2009

14 / 32

Figure: Examples of different mappings.


Basilio Bona (DAUIN-Politecnico di Torino)

Rigid motions

July 2009

15 / 32

Hyperplanes
A hyperplane in Rn is defined by the equation between a set of points pi
and a set of (real) coefficients i
1 p1 + 2 p2 + + n pn + n+1 = 0
Using the homogeneous coordinates we obtain an homogeneous linear
equation in P n
T p
=0
where

1
.
= .. ;

n
n+1


p1
..
.
=
p
p
n
1

The two homogeneous vectors can exchange their roles; we say that they
are dual.
Basilio Bona (DAUIN-Politecnico di Torino)

Rigid motions

July 2009

16 / 32

Remember that, given a vector p V(F), the set of all linear


transformations f (p) : V 7 R1 form another vector space V , and
f V are called dual vectors or 1forms.
For example, the total time derivative of a scalar function f (p) on R3 is
df (p(t))

= p (p)p(t)
dt
Another dual vector is the divergence
is a dual vector wrt p.


 p1

T .
..
p=

p1
pn
pn

or the Laplacian (gradient of the divergence)

f = f =

p1

f
 p1

T
..
.

pn
f
pn

Basilio Bona (DAUIN-Politecnico di Torino)

Rigid motions

July 2009

17 / 32

Duality in projective spaces

The space of all hyperplanes in Rn 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 R2 plane, since it
includes also points at .

Basilio Bona (DAUIN-Politecnico di Torino)

Rigid motions

July 2009

18 / 32

A collineation given by a full rank matrix T transforms points as


a = Tab p
b
p
T
b = 0 is transformed as
A hyperplane b p
T
T
b = 0 a p
a = 0
bp

hence
yielding

T
T
T
b b = a Tab
a Tab p

a = T T T
b
ab

T
Matrix T
ab 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 T
ab .
Basilio Bona (DAUIN-Politecnico di Torino)

Rigid motions

July 2009

19 / 32

Points and lines


We restrict our analysis on the 2D projective space P 2 ; for the sake of
is
clarity, we drop the sign on top of the homogeneous vectors, i.e., a
now indicated as a.


A line = 1 2 3 can be characterized by three parameters:
1
2
3

the slope 1 /2
the x-intercept 3 /1
the y -intercept 3 /2

Points p and lines are related by


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)

Rigid motions

July 2009

20 / 32

Duality
A line passing for two points p1 and p2 is defined as
= p1 p2 = S(p1 )p2
A point p belonging to two lines (intercept) 1 and 2 is defined as
p = 1 2 = S(1 )2
Points at infinity or ideal points have the following representation

T
p = p1 p2 0

All ideal points lie on the ideal line, represented by



T
= 0 0 1
Basilio Bona (DAUIN-Politecnico di Torino)

Rigid motions

July 2009

21 / 32

Three points p1 , p2 , p3 lie on the same line (they are collinear) iff


det p1 p2 p3 = 0

Since the duality principle holds, three lines 1 , 2 , 3 meet at the same
point (they are concurrent) iff


det 1 2 3 = 0

Basilio Bona (DAUIN-Politecnico di Torino)

Rigid motions

July 2009

22 / 32

Parallelism
Two lines

m1
m = m2 ;
m3


n1
n = n2
n3

are parallel when the intersection point is at infinity, i.e.,



p1
p = m n = p2
0
This reduces to the conditions



m1
n1
m1 n1
=0
=
or det
m2 n2
m2
n2
 
p
The direction k 1 points toward the point at infinity.
p2
Basilio Bona (DAUIN-Politecnico di Torino)

Rigid motions

July 2009

23 / 32

Summary


T
p = p1 p2 p3

line

pT = 0

incidence

line

= p1 p2

point

p = 1 2

collinearity



det p1 p2 p3 = 0

collinearity



det 1 2 3 = 0

point
incidence

point

p1 p2 0

Basilio Bona (DAUIN-Politecnico di Torino)

T

line

Rigid motions


T
= 1 2 3
T p = 0

0 0 3

T

July 2009

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

t11 t12 t13


T = t21 t22 t23
t31 t32 t33

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)

Rigid motions

July 2009

25 / 32

The affine transformation must preserve the ideal line and the ideal points
(as well as parallelism); hence, for any arbitrary scaling factor


p1
p1
p2 = T p2
0
0

that implies

t11 t12 t13


T = t21 t22 t23
0
0 t33

Basilio Bona (DAUIN-Politecnico di Torino)

Rigid motions

dof=6

July 2009

26 / 32

The similarity transformation must preserve angles and ratios of lengths;


that implies

cos sin t13


T = sin cos t23 dof=3
0
0
t33
with t33 6= 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)

Rigid motions

July 2009

27 / 32

The Euclidean (rigid) transformation must preserve also lengths; that


implies

cos sin t13


T = sin cos t23 dof=3
0
0
1

Basilio Bona (DAUIN-Politecnico di Torino)

Rigid motions

July 2009

28 / 32

Historical notes
Homogeneous coordinates were introduced in 1827 by M
obius 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.

T
The point is computed as p = wa x wb y wc z , with
wa + wb + wc = 1

Figure: Example of barycentric coordinates.


Basilio Bona (DAUIN-Politecnico di Torino)

Rigid motions

July 2009

29 / 32

From homogeneous coordinates to quaternions


There exist a link between homogeneous coordinates and quaternions that
goes through the M
obius transformation.
Given two complex numbers x = x1 + jx2 , y = y1 + jy2 C, the ordered
pair of complex numbers

z = x

T

C2 ,


T
z 6= 0 0

are the homogeneous coordinates of z = z1 + jz2


z=

x
x1 + jx2
= z1 + jz2 =
y
y1 + jy2

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)

Rigid motions

July 2009

30 / 32

Transformation between homogeneous representations


 
  
  

 
x
u
u
a b x
ax + by
z =
=
7 w
where
=
=
y
v
v
c d y
cx + dy
where a, b, c, d are complex numbers.
We can compute the transformed complex number as
w=

a xy + b
u
ax + by
az + b
=
= x
=
v
cx + dy
cy +d
cz + d

This is nothing else that the M


obius transformation.

Mobius transformation
w=

Basilio Bona (DAUIN-Politecnico di Torino)

az + b
;
cz + d

a, b, c, d, w , z C

Rigid motions

July 2009

31 / 32

If we take a particular form of the M


obius 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
+ j + j
=
b a
+ j j








1 0
j 0
0 1
0 j
=
+
+
+
0 1
0 j
1 0
j 0
= 1 + i + j + k
= a quaternion
For further details see: T. Needham, Visual Complex Analysis, OUP, 1997.

Basilio Bona (DAUIN-Politecnico di Torino)

Rigid motions

July 2009

32 / 32

You might also like