geometric fundamentals in robotics homogeneous coordinates · homogeneous coordinates are an...

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

Upload: others

Post on 16-Jul-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

Geometric Fundamentals in RoboticsHomogeneous Coordinates

Basilio Bona

DAUIN-Politecnico di Torino

July 2009

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 1 / 32

Page 2: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

Introduction

Homogeneous coordinates are an augmented representation of points andlines in R

n spaces, embedding them in Rn+1, hence using n+1 parameters.

This representation is useful in dealing with perspective and projectivetransformation (computer graphics, etc.) and for rigid displacementrepresentation.

We start introducing the concept on 2D spaces.

Given a point p in R2, represented as P = (p1, p2), i.e., the vector

p =[p1 p2

]Tits homogeneous representation (using homogeneous

coordinates) is

p =[p1 p2 p3

]T; with

[0 0 0

]Tnot allowed

The vector representation is obtained dividing the first n homogeneouscomponents by the (n + 1)-th, that is often called scale.

p1 = p1/p3; p2 = p2/p3

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 2 / 32

Page 3: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

A geometric interpretation of the homogeneous coordinates is given in thefollowing Figure.

Figure: Geometric interpretation of homogeneous coordinates.

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 3 / 32

Page 4: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

We embed the plane π : z = 1 in a 3D space and we consider the planarcoordinates as the intersection of a projection line that goes through theorigin of the RF {i, j, k}.

As z goes to ∞ we can represent the origin, while as z goes to 0, we canrepresents points at infinity, along a well defined direction. The set of allpoints at infinity represents the line at infinity.

Figure: Points at ∞.

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 4 / 32

Page 5: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

The same approach is valid for 3D homogeneous coordinates: given apoint p in R

3, represented as P = (p1, p2, p3), or else by a vector

p =[p1 p2 p3

]T

its homogeneous representation is

p =[p1 p2 p3 p4

]T

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

Page 6: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

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

vp =

[vp

1

]

while in the second case

vab =

[vb

1

]

[va

1

]

=

[vab

0

]

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

vp + vq =

[vp

1

]

+

[vq

1

]

=

[vp + vq

2

]

This sum, once transformed back in 3D space, becomes not the usualparallelogram sum of segments, but the midpoint of the parallelogram (seealso Affine Spaces).

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 6 / 32

Page 7: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

Figure: Homogeneous sum of two geometric vectors.

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 7 / 32

Page 8: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

Affine spaces

Briefly, affine spaces are spaces where the origin is not considered to be aspecial point, and homogeneous coordinates are used to characterize theaffine elements (points and planes).

Figure: Linear and affine subspaces.

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 8 / 32

Page 9: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

Rigid displacements and homogeneous coordinates

Using homogeneous representation, the generic displacement (R, t) isgiven by the following homogeneous transformation matrix

H ≡ H(R, t) =

[

R t

0T 1

]

since

Hv =

[

R t

0T 1

] [v1

]

= Rv + t

Hence, the SE (3) group transformation g = (R, t) ∈ SE (3), is representedby the 4 × 4 homogeneous matrix H through the use of homogeneouscoordinates:

pa = gabpb ↔ pa = Hab(Rab, tab)pb

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 9 / 32

Page 10: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

Transformation composition gabgbc is obtained by the homogeneousmatrix product

Hab(Rab, tab)Hbc(Rbc , tbc)

i.e., [

Rab tab

0T 1

][

Rbc tbc

0T 1

]

=

[

RabRbc Rabtbc + tab

0T 1

]

Often it is convenient to write the time derivative of a homogeneousvector as

˙p =

p1

p2

p3

0

This notation will prove useful when dealing with twists.

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 10 / 32

Page 11: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

Introduction to projective/perspective geometry

Homogeneous coordinates p are used for describing point in projectivespaces Pn of dimension n.

Two points a and b are “equal” (a ∼ b) if there exist a real λ 6= 0 suchthat

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 affinesubspace of R

n+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 imageplane are

pi =

xyf

→ pi =

[x/fy/f

]T

=1

f

[xy

]T

where f is the focal distanceBasilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 11 / 32

Page 12: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

Figure: Example of projection through a pinhole camera.

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 12 / 32

Page 13: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

Considering the similar triangles in Figure, we have:

x

f=

X

Z;

y

f=

Y

Z

If we set λ = Z/f , where f is known and the distance Z from π of thepoint p is unknown, we have

X = λx , Y = λy , Z = λf

Hence, if we compute the cartesian coordinates of pi on π fromhomogeneous coordinates, we have

pi =

[x/fy/f

]

↔ pi =

fXfYZ

∼ λ

xy1

xyf

and every 3D point with homogeneous coordinates λ[x y f

]Tis

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 July 2009 13 / 32

Page 14: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

The nonlinear mapping R3 → R

2 can be expressed as a (linear) matrixtransformation between the homogeneous spaces R

4 → R3 as

fXfYZ

∼ λ

xy1

=

f 0 0 00 f 0 00 0 1 0

︸ ︷︷ ︸

P

XYZ1

⇔ λpi = P

[p1

]

Nonsingular (i.e., invertible) mappings between projective spaces aredescribed by products of full rank square matrices T by homogeneouscoordinates, pa = Tabpb

An invertible mapping from Pn onto itself preserves collinearities, i.e., iftwo points belong to a line, also the transformed points will belong to aline.

Affine transformations preserve not only collinearities, but also parallelismbetween lines and ratios of distances.

Similarity transformations preserves also angles, but not scales, whileEuclidean (rigid) transformations preserve also scales

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 14 / 32

Page 15: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

Figure: Examples of different mappings.

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 15 / 32

Page 16: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

Hyperplanes

A hyperplane in Rn 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 linearequation in Pn

ℓTp = 0

where

ℓ =

ℓ1...ℓn

ℓn+1

; p =

p1...

pn

1

The two homogeneous vectors can exchange their roles; we say that theyare dual.

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 16 / 32

Page 17: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

Remember that, given a vector p ∈ V(F), the set of all lineartransformations f (p) : V 7→ R

1 form another vector space V∗, andf ∈ 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))

dt= ∇pφ(p)p(t)

is a dual vector wrt p. Another dual vector is the divergence

∇ · p =

[∂

∂p1· · ·

∂pn

]T

p1...

pn

or the Laplacian (gradient of the divergence)

∇2f = ∇ · ∇f =

[∂

∂p1· · ·

∂pn

]T

∂f

∂p1...

∂f

∂pn

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 17 / 32

Page 18: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

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 andplanes, a symmetrical result holds interchanging the role of planes andpoints.

Example:

two points define a line ↔ two lines define a point

Notice that the projective plane P2 whose point are defined byhomogeneous coordinates, has more point that the usual R

2 plane, since itincludes also points at ∞.

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 18 / 32

Page 19: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

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

pa = Tabpb

A hyperplane ℓTb pb = 0 is transformed as

ℓTb pb = 0 ⇔ ℓ

Ta pa = 0

henceℓTa Tabpb ⇒ ℓ

Tb = ℓ

Ta Tab

yielding

ℓa = T−

abTℓTb

Matrix T−

abT is called the dual of Tab

Comparing this last equation with the first one, we conclude that pointsand lines can be transformed, but using different (dual) collineationmatrices Tab and T−

abT.

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 19 / 32

Page 20: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

Points and lines

We restrict our analysis on the 2D projective space P2; for the sake ofclarity, we drop the ˜ sign on top of the homogeneous vectors, i.e., a isnow 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 theprevious relation holds.

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 20 / 32

Page 21: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

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

p∞

=[p1 p2 0

]T

All ideal points lie on the ideal line, represented by

ℓ∞ =[0 0 1

]T

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 21 / 32

Page 22: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

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 samepoint (they are concurrent) iff

det[ℓ1 ℓ2 ℓ3

]= 0

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 22 / 32

Page 23: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

Parallelism

Two lines

m =

m1

m2

m3

; n =

n1

n2

n3

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

p = m × n =

p1

p2

0

This reduces to the conditions

m1

m2=

n1

n2or det

[m1 n1

m2 n2

]

= 0

The direction k

[p1

p2

]

points toward the point at infinity.

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 23 / 32

Page 24: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

Summary

point p =[p1 p2 p3

]Tline ℓ =

[ℓ1 ℓ2 ℓ3

]T

incidence pTℓ = 0 incidence ℓ

Tp = 0

line ℓ = p1 × p2 point p = ℓ1 × ℓ2

collinearity det[p1 p2 p3

]= 0 collinearity det

[ℓ1 ℓ2 ℓ3

]= 0

∞ point[p1 p2 0

]T∞ line

[0 0 ℓ3

]T

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 24 / 32

Page 25: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

Transformations in P2

The generic projective transformation (also called homographies) in P2 isrepresented by a non singular 3 × 3 matrix (acting on homogeneousvectors), whose elements are

T =

t11 t12 t13t21 t22 t23t31 t32 t33

Since the transformations are equivalent up to a scale factor, the numberof 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 P2

(most general) projective → affine → similarity → Euclidean (rigid)

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 25 / 32

Page 26: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

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

λ

p1

p2

0

= T

p1

p2

0

that implies

T =

t11 t12 t13t21 t22 t230 0 t33

→ dof=6

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 26 / 32

Page 27: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

The similarity transformation must preserve angles and ratios of lengths;that implies

T =

cos θ − sin θ t13sin θ cos θ t230 0 t33

→ dof=3

with t33 6= 1.

The effects of the last column in T is to produce a shear i.e., a scalevariation that is non uniform in all directions.

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 27 / 32

Page 28: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

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

T =

cos θ − sin θ t13sin θ cos θ t230 0 1

→ dof=3

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 28 / 32

Page 29: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

Historical notes

Homogeneous coordinates were introduced in 1827 by Mobius in thecontext of barycentric coordinates. Given a triangle, the barycentriccoordinates of a point P are the weights required at the triangle verticessuch that P become the center of gravity of the triangle.

The point is computed as p =[wax wby wcz

]T, with

wa + wb + wc = 1

Figure: Example of barycentric coordinates.

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 29 / 32

Page 30: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

From homogeneous coordinates to quaternions

There exist a link between homogeneous coordinates and quaternions thatgoes through the Mobius transformation.

Given two complex numbers x = x1 + jx2, y = y1 + jy2 ∈ C, the orderedpair of complex numbers

z =[x y

]T∈ C

2, z 6=[0 0

]T

are the homogeneous coordinates of z = z1 + jz2

z =x

y= z1 + jz2 =

x1 + jx2

y1 + jy2

To every pair of complex numbers (x , y) a unique complex numbers zcorresponds, while for every complex number z there is an infinite numberof complex pairs (projective transformation).

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 30 / 32

Page 31: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

Transformation between homogeneous representations

z =

[xy

]

7→ w =

[uv

]

where

[uv

]

=

[a bc d

] [xy

]

=

[ax + bycx + dy

]

where a, b, c , d are complex numbers.

We can compute the transformed complex number as

w =u

v=

ax + by

cx + dy=

a xy

+ b

c xy

+ d=

az + b

cz + d

This is nothing else that the Mobius transformation.

Mobius transformation

w =az + b

cz + d; a, b, c , d ,w , z ∈ C

Basilio Bona (DAUIN-Politecnico di Torino) Rigid motions July 2009 31 / 32

Page 32: Geometric Fundamentals in Robotics Homogeneous Coordinates · Homogeneous coordinates are an augmented representation of points and lines in Rn spaces, embedding them in Rn+1, hence

If we take a particular form of the Mobius transformation, due to Gauss:

w =az + b

−b∗z + a∗

we know that every rotation of the sphere can be expressed by a complexfunction as the one above, and we notice that it can be represented by thematrix of its coefficients

[a b

−b∗ a∗

]

=

[α + jβ γ + jδ−γ + jβ α − jβ

]

= α

[1 00 1

]

+ β

[j 00 j

]

+ γ

[0 1−1 0

]

+ δ

[0 jj 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