Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni...

23
Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 1 Analytic and projective geometry: Outline 1. MOTIVATION:WHY DO WE NEED TRANSFORMATIONS? The graphics pipeline A scene 2. WHAT KIND OF TRANSFORMATIONS AND COORDINATES DO WE NEED? Cartesian coordinates Geometric transformations Linear maps and matrices Homogeneous coordinates Affine space Affine transformations Digression on barycentres Projective maps and transformations Perspective and parallel viewing 3. APPENDIX: THE ROTATIONS IN 3D Rotations and Euler angles Limitations of the Euler angles Quaternions and rotations The space of rotations SO(3) ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 2

Transcript of Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni...

Page 1: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

Analytic and projective geometry

Chantal Oberson Ausoni

29.7.2014

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 1

Analytic and projective geometry: Outline1. MOTIVATION: WHY DO WE NEED TRANSFORMATIONS?

• The graphics pipeline• A scene

2. WHAT KIND OF TRANSFORMATIONS AND COORDINATES DO WE NEED?• Cartesian coordinates• Geometric transformations• Linear maps and matrices• Homogeneous coordinates• Affine space• Affine transformations

� Digression on barycentres• Projective maps and transformations

� Perspective and parallel viewing

3. APPENDIX: THE ROTATIONS IN 3D• Rotations and Euler angles• Limitations of the Euler angles• Quaternions and rotations• The space of rotations SO(3)

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 2

Page 2: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

Why do we need transformations?

The graphics pipeline

The graphics pipeline is the sequence of steps from the 3D scene to its 2D representation.

• The objects are build from line segments and triangles (the primitives) connecting ver-tices.

• A fragment is a potential pixel carrying information about its color and location and isused to update the corresponding pixel in the frame buffer.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 3

Why do we need transformations?

A scene• We have to deal successively with several coordinate systems: object, world, eye or

camera, clip, window coordinates

• Hierarchy: a scene can consist partially of identic objects.

• The scene can be animated, the objects can be moved.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 4

Page 3: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

What kind of transformations do we need?

Geometric transformationsA geometric transformation is a function f : D �! R, whose domain D and range R arepoints, and which is onto and one-to-one.

Onto: every point in R can be reached by the transformation.

One-to-one: a point in R is image of one point only. The inverse transformation can beconstructed.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 5

What kind of transformations do we need?

3D cartesian coordinatesThe position of any point p in three-dimensional space is specified by three Cartesian coor-dinates (p

1

, p2

, p3

), its signed distances to three mutually perpendicular planes. In otherwords, we have three orthogonal axes Ox, Oy and Oz, along which we make a perpendic-ular projection of our point.

Other coordinate systems: polar, spherical...

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 6

Page 4: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

What kind of transformations do we need?

Link with linear algebraThe point p, of cartesian coordinates (p

1

, p2

, p3

) in R3, can be represented by a vector �!opfrom the origin o to the point p. We usually define the standard basis {e

1

, e2

, e3

} as

e1

=

0

B@1

0

0

1

CA along Ox,

e2

=

0

B@0

1

0

1

CA along Oy

and e3

=

0

B@0

0

1

1

CA along Oz

so that

0

B@p1

p2

p3

1

CA = p1

e1

+ p2

e2

+ p3

e3

.

Reminder: any other basis can be chosen (A basis is a set of linear independant vectors,generating R3.)

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 7

What kind of transformations do we need?

Change of basisAny other basis {f

1

, f2

, f3

} can be chosen; changing the base means for example writingthe new basis in the old

f1

= p11

e1

+ p21

e2

+ p31

e3

f2

= p12

e1

+ p22

e2

+ p32

e3

f3

= p13

e1

+ p23

e2

+ p33

e3

The new coordinates of v = v1

e1

+ v2

e2

+ v3

e3

in the basis {f1

, f2

, f3

} are given as

v = v01

f1

+ v02

f2

+ v03

f3

= v01

(p11

e1

+ p21

e2

+ p31

e3

)

+ v02

(p12

e1

+ p22

e2

+ p32

e3

)

+ v03

(p13

e1

+ p23

e2

+ p33

e3

)

This means that we have the matrix equation

0

B@v1

v2

v3

1

CA =

0

B@p11

p12

p13

p21

p22

p23

p31

p32

p33

1

CA ·

0

B@v01

v02

v03

1

CA giving

the old coordinates as a function of the new ones, or inverting the matrix, the new ones asa function of the old ones. The matrix P =

hpiji

is the change of basis matrix. Its columnsare the coordinates of the new basis vectors fi in the old vector basis ei. In a simplifiednotation: P =

⇣f1

f2

f3

⌘.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 8

Page 5: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

What kind of transformations do we need?

Linear maps and matricesLinear map: A map f : R3 �! R3 is said linear iff

• f(v + w) = f(v) + f(w) for all v, w 2 R3

• f(�v) = �f(v) for all v 2 R3, � 2 R

Matrices: The transformation f : v 7! A · v is linear. Conversely, if f : R3 �! R3

is linear, we can write the matrix A =

⇣f(e

1

) f(e2

) f(e3

)

⌘so that A ·

0

B@v1

v2

v3

1

CA =

v1

f(e1

) + v2

f(e2

) + v3

f(e3

) = f(v1

e1

+ v2

e2

+ v3

e3

) = f(v).REMARK 1. The composition of two linear maps f and g (with matrices F and G in givenbasis) is a linear map. The matrix of the composition f � g is the product of matrices F ·G.This makes composition of linear maps very easy to compute.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 9

What kind of transformations do we need?

Examples of (non-)linear maps1. A 3D-rotation is a linear map: it is given by an axis of rotation and an angle;

for example, the 3D rotation of angle ' around Oz is given by the matrix0

B@cos(') � sin(') 0

sin(') cos(') 0

0 0 1

1

CA

2. A 3D-translation f(v) = v + a is no linear map, since linear maps satisfy f(0) = 0.In other words, there is no 3⇥ 3-matrix expressing this transformation.

REMARK 2. In computer graphics, we will often need non-linear transformations (like forexample the translation). It means that we will not be able in general to write a globaltransformation as a 3⇥ 3-matrix.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 10

Page 6: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

What kind of transformations do we need?

Why do we use homogeneous coordinates?Using homogeneous coordinates,

• we can express at the same time vectors and points,

• we can describe affine subspaces and not only linear subspaces,

• we can find matrix formulations for translations,

• ... for all affine transformations, ...

• ... for all projective transformations.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 11

What kind of transformations do we need?

Homogeneous coordinates in 2DThe points of the projective plane RP2 are the equivalence classes of the set R3\{(0,0,0)}modulo the equivalence relation v ⇠ �v, for all � 2 R. In other words, the points of theprojective plane are the lines (in space) through the origin.

The coordinates[

x, y, z]

of a point in the projective plane are called homogeneous coor-dinates. Each point in the projective plane can be represented by an infinity of triples: forexample,

[

x, y, z]

=

[

2x,2 y,2 z]

.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 12

Page 7: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

What kind of transformations do we need?

Homogeneous coordinates in 2D, what we needThe lines in the plane Oxy correspond to a last coordinate z = 0. Together, all these pointsof type [x, y,0] form a line at infinity.

For all other lines, we can consider their inter-section with the plane z = 1 and have coor-dinates

[

x/z, y/z,1]

, as well as[

x, y, z]

.

What is interesting for us here are the inclusions

(x, y) �! [x, y,1]

(x, y) �! [x, y,0]

from the Euclidean plane to the projective plane. This way we can choose to represent

• the points of the Euclidean plane through points [x, y,1] of RP2,

• the 2D-vectors as elements [x, y,0] of RP2.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 13

What kind of transformations do we need?

Homogeneous coordinates in 3DThe same construction can be made in any dimension n to give a projective space RPn.So the projective space of dimension 3, RP3, can be defined as the set of lines through theorigin in R4.

Again we can use the inclusions (x, y, z) �! [x, y, z,1] and (x, y, z) �! [x, y, z,0] torepresent the points of the Euclidean space through coordinates [x, y, z,1] and 3D-vectorsas elements [x, y, z,0] of RP3.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 14

Page 8: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

What kind of transformations do we need?Affine space

Corresponding to this idea of using at the same time points and vectors, there is the math-ematical concept of affine space. Given a vector space E, an affine space (E, E,+) isobtained by

• considering a non-empty set of points E• an addition: E ⇥ E �! E satisfying

1. for every p 2 E , the map 'p : E �! E defined by 'p(v) = p+ v is a one-to-onecorrespondance

2. p+ (v + w) = (p+ v) + w pour tout p 2 E , v, w 2 E.

For example, the usual 3D-Euclidean space is not technically a vector space but rather anaffine space, on which a vector is the difference between a pair of points. It means thatthere is no canonical choice of where the origin should go in the space, because it can betranslated anywhere.

On an affine space (E, E,+), choosing an origin on E and a basis {e1

, · · · , en} of E, weobtain what we call a frame (o; e

1

, · · · , en), and can express every point p in it: �!op =

Pni=1

xiei.

An affine space is nothing more than a vector space whose origin we try to forgetabout, by adding translations to the linear maps.

Marcel BergerICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 15

What kind of transformations do we need?

A matrix formulation for the translation by a vector aThe translation by a vector a corresponds to the affine transformation �a : E �! E definedby �a(p) = p+a. It acts on points and not on vectors and using homogeneous coordinates,we can find a 4⇥ 4-matrix for its formulation:

0

BBB@

1 0 0 a1

0 1 0 a2

0 0 1 a3

0 0 0 1

1

CCCA ·

0

BBB@

p1

p2

p3

1

1

CCCA =

0

BBB@

p1

+ a1

p2

+ a2

p3

+ a3

1

1

CCCA

0

BBB@

1 0 0 a1

0 1 0 a2

0 0 1 a3

0 0 0 1

1

CCCA ·

0

BBB@

v1

v2

v3

0

1

CCCA =

0

BBB@

v1

v2

v3

0

1

CCCA

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 16

Page 9: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

What kind of transformations do we need?

Affine transformationsConsidering an affine space (E, E,+), the map f : E �! E is affine if it consists of atranslation and a linear map l: choosing an origin o 2 E , f(x) = f(o +

�!ox) = f(o) +

l(�!ox).

Remarks:

• An affine transformation transforms lines into lines: f(x+�v) = f((o+�!ox)+�v) =

f(o+ (

�!ox+ �v)) = f(o) + l(�!ox+ �v) =

⇥f(o) + l(�!ox)

⇤+ �f(v).

• An affine transformation preserves the parallelism of lines (similar demonstration).

• If we change the origin for o0 2 E , we have f(o0) + l(�!o0x) = f(o+

�!oo0) + l(

�!o0x) =

f(o) + l(�!oo0) + l(

�!o0x) = f(o) + l(

�!oo0 +

�!o0x) = f(o) + l(�!ox) = f(x) giving a

second decomposition with the same linear map and a different translation.

• A transformation f : E �! E is affine iff it preserves barycentres.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 17

Digression on barycentres

What is a barycentre in affine geometry?If we take to n points p

1

, · · · , pn in an affine space (E, E,+), with n weights �1

, · · · ,�nassociated to these points (with the sum

Pni=1

�i 6= 0) the corresponding barycentre is theonly point g with

nX

i=1

�i�!gpi = 0.

Given an origin, it is defined by �!og =

Pni=1

�i��!opi. Existence and unicity are proven easily

using Chasles relation: �!ac =

�!ab +

�!bc.

In the case of equal weights (�i =1

n for all n), the barycentre is the centroid.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 18

Page 10: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

Digression on barycentres

Affine sumConsider the equation

�!og =

nX

i=1

�i��!opi

defining the barycentre.Since every �i is divided by the sum �, it is equivalent to consider all weights to sum toone. Although the sum of two points of E and the multiplication of a point by a real are notdefined in general, if the �i sum to one, we can write the sum

Pni=1

�ipi. It follows fromthe existence and unicity of the barycentre. It is sometimes called affine sum.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 19

Digression on barycentres

Convex hull, barycentric coordinates• Consider two points p and q with non-negative weights summing to one. Varying the

weights gives us a set of points forming the segment between these two points.

• With three points and the same condition on weights, we get a triangle.

• In general, the set of all barycentres of a given set of points p1

, · · · , pn with non-negative weights summing to one is the convex hull of these points. This correspondsto the idea of including, for each pair of points p and q, all points on the segmentbetween them.

Since every point p in the convex hull of a set of points p1

, · · · , pnis the barycentre of these points for some weights �

1

, · · · ,�n, we can define (�1

, · · · ,�n)to be the barycentric coordinates of p relative to the points p

1

, · · · , pn.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 20

Page 11: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

What kind of transformations do we need?

The equivalent definition for affine transformationsA transformation f : E �! E is affine iff for every set of points p

1

, · · · , pn, for every familyof weights �

1

, · · · ,�n summing to one,

f(nX

i=1

�ipi) =

nX

i=1

�if(pi).

In other words, f preserves barycentres. In particular it preserves barycentric coordinates.Remember that we can write the

Pni=1

�ipi only because the coefficients sum to one!

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 21

What kind of transformations do we need?

A matrix formulation for affine transformations1. We have seen that an affine transformation f of R3 is the composition of a linear map

with a translation. As a consequence, if we choose a frame with an origin o and a basis(for example (0,0,0) and the standard basis),

the coordinates of an image f(x) can be written as A ·

0

B@v1

v2

v3

1

CA+

0

B@b1

b2

b3

1

CA,

• where A is the 3⇥ 3-matrix of the linear map, the (v1

, v2

, v3

) are the coordinatesof �!ox in this basis

• b =���!of(o), all relative to this basis and origin

This is not a matrix formulation, because of the translation part.

2. As already done for the translations, we can use a 4 ⇥ 4-matrix, sometimes calledaugmented matrix to write a matrix formulation for the coordinates of f(x)

Mf =

0

BBB@

a11

a12

a13

b1

a21

a22

a23

b2

a31

a32

a33

b3

0 0 0 1

1

CCCA ·

0

BBB@

v1

v2

v3

1

1

CCCA

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 22

Page 12: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

What kind of transformations do we need?

Affine transformations: changing framesGiven (o; e

1

, e2

, e3

) and (o0; e01

, e02

, e03

) two frames of R3, p a point of coordinates (x1

, x2

, x3

)

in the first frame, (x01

, x02

, x03

) in the second frame.

We write

0

B@v1

v2

v3

1

CA the coordinates of o0 in the first frame (o; e1

, e2

, e3

).

• Vector coordinates: we have seen the change of basis matrix P such that:0

B@x1

x2

x3

1

CA = P ·

0

B@x01

x02

x03

1

CA .

• For the homogeneous coordinates:0

BBB@

x1

x2

x3

1

1

CCCA =

0

BBB@P

v1

v2

v3

0 0 0 1

1

CCCA ·

0

BBB@

x01

x02

x03

1

1

CCCA .

• For the augmented matrix: let again f be an affine transformation R3 �! R3, Mf andM 0

f be the matrices of f in these two frames

M 0f = P�1

a ·Mf · Pa.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 23

What kind of transformations do we need?

Example of affine transformation: homothetic transformationIt is an affine transformation determined by acentre s = (sx, sy, sz) and a ratio �, suchthat

f(x) = s+ ��!sx.The augmented matrix Mf is:

Mf =

0

BBB@

� 0 0 (1� �)sx0 � 0 (1� �)sy0 0 � (1� �)sz0 0 0 1

1

CCCA

Placing the origin in the centre s, we have a linear scaling.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 24

Page 13: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

What kind of transformations do we need?

Example of affine transformation: general rotationBy general we mean a rotation for which the origin may not be on the axis. Consider the3D rotation of angle ' around an axis parallel to Oz and through the point (�x

0

,�y0

,0).We can translate by (x

0

, y0

,0), then rotate around Oz, then translate again by (x0

, y0

,0).

The augmented matrix of f is:

Mf

0

BBB@

cos(') � sin(') 0 x0

� cos(')x0

+ sin(') y0

sin(') cos(') 0 y0

� sin(')x0

� cos(') y0

0 0 1 0

0 0 0 1

1

CCCA

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 25

What kind of transformations do we need?

Composition of affine transformationsLet f, g : R3 �! R3 be two affine transformations, say

f(x) = Lf · x+ bf

g(x) = Lg · x+ bg

Then, g � f(x) = (Lg · Lf) · x+ (Lg · bf + bg).

In other words,

1. The 3 ⇥ 3 matrix of the composition g � f is equal to the product of the matrices:Lg�f = Lg ·Lf . In general the linear part of the composition is the composition of thelinear parts.

2. The translation part is obtained as bg�f = Lg · bf + bg.

3. The augmented matrice of the composition g � f can also be obtained by a matrixproduct:

Mg�f = Mg ·Mf.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 26

Page 14: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

What kind of transformations do we need?

Euclidean affine spacesIf we take on the vector space E a norm k.k and the associated distance d(a, b) = k

�!abk on

E , we can consider the isometries of E :A transformation f : E �! E is called isometry

1. if it preserves the distances: d(f(p), f(q)) = d(p, q) for all p, q 2 E ,or equivalently,

2. if it is affine (f = Lf · x+ bf ) and Lf is orthogonal: i.e., Lf · (Lf)T= I

3

.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 27

What kind of transformations do we need?

Projective mapA map f : R3 �! R3, (x

1

, x2

, x3

) 7! (x01

, x02

, x03

) is said to be projective if there is alinear map Lf : R4 �! R4 with Lf(x, y, z,1) proportional to (x0, y0, z0,1).

Remarks:

1. Sometimes, the map f is not defined on all space, but only on R3 \ ⇡, ⇡ a plane, likethe perspective we will see later. It can still be considered to be projective.

2. The word projective refers to the fact that Lf can also be seen in RP3, since it acts onlines.

3. Any affine transformation f : R3 �! R3 is projective, since, if Mf is its augmented

matrix, Lf(x, y, z,1) = Mf ·⇣x y z 1

⌘Tis equal to (x0, y0, z0,1).

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 28

Page 15: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

What kind of transformations do we need?

Matrix formulation of a projective transformation• A projective map f : R3 �! R3 can then given by the 4 ⇥ 4 matrix of its linear

expression Lf . We use the same notation as before for the matrix: Mf .

• We speak of a projective transformation when the matrix Mf is invertible.

• Two inversible 4⇥4 matrices M1

and M2

represent the same projective transformationif and only if they are proportional: there is a � 2 R with M

1

= � ·M2

. It means thatwe can choose the matrix representant M with m

44

= 1 .

• For affine transformations R3 �! R3 you have 12 parameters; for projective transfor-mations, you have 15.

• Again, the composition of projective transformations is a projective transformation andthe product of the individual matrices is the matrix of the composition:

Mf�f 0 = Mf ·M 0f .

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 29

What kind of transformations do we need?

The case of perspectiveThe rules of perspective are meant to translate in geometrical rules the similarity of a picturewith the real world.A 3D-scene is determined by:

1. the position c of the camera (or the eye), having world coordinates (x0

, y0

, z0

), (ac-cording to a world frame (o; e

1

, e2

, e3

))

2. a viewing direction v with coordinates (a, b, c),

3. a screen, mathematically a plane ⇡ orthogonal to ⇡, at distance d from c,

4. a frame (o; e01

, e02

) of ⇡.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 30

Page 16: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

What kind of transformations do we need?

Viewing• A view of the scene is a transformation

w : R3 �! R2

where f(x1

, x2

, x3

) is the projection ofo+ x

1

e1

+ x2

e2

+ x3

e3

on the plane ⇡

expressed in the frame (o; e01

, e02

). It is notdefined for the points on a plane parallel to ⇡

through c.• The perspective view is the view where

w(x1

, x2

, x3

) corresponds to the intersection ofthe ray through c and o+ x

1

e1

+ x2

e2

+ x3

e3

with the plane ⇡.• If we move the point c away from the plane ⇡

along the line defined by v, the limit case of c atinfinity is a parallel projection (with direction v, on⇡). It corresponds to the view at infinite distanceand can be orthogonal or oblique, depending onthe angle between v and ⇡.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 31

What kind of transformations do we need?

Example computation of the persective of a planeComputing the matrix of the perspective view of a plane ⇡

1

on a plane ⇡2

,

• with camera position (0,0,2),

• ⇡1

the plane through (0,0,0) generated by the vectors

u1

=

⇣1 0 1

⌘Tand v

1

=

⇣0 1 0

⌘Tand

• ⇡2

the plane through (0,0,0) generated by the vectors

u2

=

⇣1 0 �1

⌘Tand v

2

=

⇣0 1 0

⌘T.

The map is defined by f(x1

, y1

) = (

x1

1�x1

, y1

1�x1

) in the frames (o; ~u1

, ~v1

) and (o; ~u1

, ~v1

).

Is it a projective transformation R2 �! R2? Yes, since we can write the augmented matrixequation

0

B@1 0 0

0 1 0

�1 0 1

1

CA ·

0

B@x1

y1

1

1

CA =

0

B@x1

y1

1� x1

1

CA ,

which is proportional to (

x1

1�x1

, y1

1�x1

,1). The augmented matrix is invertible.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 32

Page 17: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

What kind of transformations do we need?

Example computation of the orthogonal parallel projectionThe orthogonal parallel projection onto the plane z = 0 is affine and can be written with

the augmented matrix: P =

2

6664

1 0 0 0

0 1 0 0

0 0 0 0

0 0 0 1

3

7775.

In computer graphics, six clipping planes aregiven and the transformation is written as acomposition of a scaling and a translation.The center of the defined box is now at theorigin and the box is scaled to the unit cube,which is defined to have a minimum cornerat (�1,�1,�1) and a maximum corner at(1,1,1):

P = S · T =

2

666664

2

right�left 0 0 0

0

2

top�bottom 0 0

0 0

2

far�near 0

0 0 0 1

3

777775·

2

666664

1 0 0 �left+right2

0 1 0 �top+bottom2

0 0 1

far+near2

0 0 0 1

3

777775.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 33

What kind of transformations do we need?

Perspective view of linesSuppose that we have a perspective view like before, given by a camera position c and ascreen plane ⇡. We consider the perspective view of a line D.

• If D does not contain c, its perspective view is the intersection of the plane ⇡D throughc and D with ⇡.

• If D contains c, its perspective view is a point: the intersection of D with ⇡. This pointis called vanishing point of D. If D contains c and is parallel to ⇡, the line is not seen.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 34

Page 18: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

What kind of transformations do we need?

Perspective and parallelism of linesSuppose that we have two parallel lines D and D0. Define ⇡D the plane through D and c

and ⇡D0 the plane through D0 and c. The intersection of planes ⇡D and ⇡D0 is a line D00

containing c.

• If D (and D0) are not parallel to ⇡, D00 isprojected to its vanishing point in ⇡. Theperspective views of D (and D0) containthis point. In other words, all lines paral-lel to a line through c contain its vanish-ing point.

• If the lines are parallel to ⇡, and do notcontain c, D0 and D0 have parallel per-spective views.

Perspective engraved by Henricus Hondius (1597-1651)

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 35

What kind of transformations do we need?

Perspective view of coplanar linesSuppose that we take instead D and D0 non parallel and contained in a same plane ⇡0. Theplane parallel to ⇡0 through c contains the lines parallel to D, resp. D0. The intersection ofthis plane ⇡00 with ⇡ contains their vanishing points.

In summary, the vanishing points of coplanar lines are aligned.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 36

Page 19: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

What kind of transformations do we need?

Perspective view of a sphereConsidering all rays issued from the camera and going through the sphere, we obtain a rightcircular cone. Its axis contains c and the centre of the sphere.

• If the axis is orthogonal to ⇡, the perspective view of the sphere is a disk.

• Otherwise, the intersection of the cone with ⇡ defines an ellipse. Its elongation de-pends of the distance between the centre of the sphere and the line perpendicular to ⇡

through the point c.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 37

Addendum: 3D-rotations

The particular case of 3D rotations through the originEvery 3D-rotation (say it is of angle ↵ around an axis v) can be written as a sequence ofelemental rotations around the coordinate axes. We can see such a decomposition forexample if we

1. first rotate the axis v around Ox to have it in the plane Oxz,

2. then rotate it around Oy to have it match with Oz,

3. make the wanted rotation around Oz

4. make the inverse rotations (2 and 1) to get back to a rotation around v.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 38

Page 20: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

Addendum: 3D-rotations

The particular case of 3D rotations through the originThen, we can write the matrix R of the rotation as a product of elemental rotation matrices

R = Rx(�↵x) ·Ry(�↵y) ·Rz(↵) ·Ry(↵y) ·Rx(↵x)

with Rz(↵) =

0

B@cos(↵) � sin(↵) 0

sin(↵) cos(↵) 0

0 0 1

1

CA, Ry(↵y) =

0

B@cos(↵y) 0 � sin(↵y)

0 1 0

sin(↵y) 0 cos(↵y)

1

CA and

Rx(↵x) =

0

B@1 0 0

0 cos(↵x) � sin(↵x)

0 sin(↵x) cos(↵x)

1

CA.

Remark: It is also possible to begin with Oz, then Oy, then Ox, for example, changing theorder of the rotations we make, and modifying the values of the angles of course.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 39

Addendum: 3D-rotations

The particular case of 3D rotations: Euler anglesActually, it is even possible to write every rotation matrix R as a product of three elementalrotation matrices. For instance:

R = Z(�)Y (�)X(↵)

is the expression of a rotation matrix R as a product of rotations matrices about axes Ox,then Oy, and finally Oz. The three angles ↵,�, � presented here are called Euler angles.

Pay attention to the fact that there are many different conventions for Euler angles. Forexample, the ones using another succesion of axis (Ox, Oy, Ox would also be possible)or the ones using intrinsic rotations, for example the first elemental rotation is about axisOx, the second one is about a new axis Oy0 = X(↵)e

2

and the third about a new axisOz00 = Y (�)X(↵)e

3

.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 40

Page 21: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

3D-rotations

Limitations to the use of the Euler anglesThe Euler angles, whatever the convention used, implies that you use three angles to de-scribe a 3D-rotation. It gives birth to a well-known problem called gimbal lock. In a fewwords, it is a problem due to the difficulty of parametrizing SO(3), the group of 3D-rotations. In 3D graphics, it causes jumps in animations. It is also an issue in aeronautics.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 41

3D-rotations

QuaternionsReminder on complex numbers: Complex numbers can be defined as elements of R2 withan addition and a product :

(a, b) + (a0, b0) = (a+ a0, b+ b0)

(a, b) · (a0, b0) = (a a0 � b b0, a b0 + a0 b)

with following properties: the product is associative and commutative and it is distributiveover the addition.

This algebraic theory of complex numbers was created by Hamilton in 1843. For a longtime, he had been looking for an analogeous product for triplets of numbers (product whichhas now been proved not to exist). He was actually able to define a non-commutativeproduct on quadruplets of numbers:

(a1

, b1

, c1

, d1

) · (a2

, b2

, c2

, d2

) = (a1

a2

� b1

b2

� c1

c2

� d1

d2

,

a1

b2

+ b1

a2

+ c1

d2

� d1

c2

,

a1

c2

� b1

d2

+ c1

a2

+ d1

b2

,

a1

d2

+ b1

c2

� c1

b2

+ d1

a2

).

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 42

Page 22: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

3D-rotations

Quaternions (2)These numbers are called quaternions and the R-algebra of quaternions is noted H.Often, you consider a quaternion q = (a, b, c, d) as a sum of a real (a,0,0,0) and a purequaternion (0, b, c, d).

The norm of a quaternion (a, b, c, d) is equal toqa2 + b2 + c2 + d2 =

qa2 + k(b, c, d)k2.

A unit quaternion q is a quaternion of norm 1. It can always be written in the form

(cos✓, sin✓ b, sin✓ c, sin✓ d)

for a unit vector v = (b, c, d) 2 R3 and an angle ✓.It is analogeous to the way you write a unit complex number in the form (cos✓, sin✓) (orei✓ in the Euler notation).

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 43

3D-rotations

Quaternions as rotationsIn 2D, a unit complex number can be used to compute the rotation of a vector (v

1

, v2

)

with angle ✓:

(cos✓, sin✓)·(v1

, v2

) = (cos✓ v1

�sin✓ v2

, cos✓ v2

+sin✓ v1

) =

cos✓ �sin✓sin✓ cos✓

!

· v1

v2

!

.

In R3, quaternions can help to express 3D-rotations, using the “conjugation” , i.e., a prod-

uct where we use the unit quaternion q = (cos(✓2

), sin(✓2

) b, sin(✓2

) c, sin(✓2

) d) =

cos(✓2

) + sin(✓2

) (b, c, d) and its inverse:

R(✓, v)(p1

, p2

, p3

) = q (0, p1

, p2

, p3

) q�1,

giving us the rotation of angle ✓ around the axis v = (b, c, d). To a given rotation corre-spond two quaternions q and �q.

Expressing rotations in 3D as unit quaternions instead of matrices has some advantages:

• Concatenating rotations is computationally faster and numerically more stable.

• Extracting the angle and axis of rotation is simpler from a quaternion than from a matrix.

• The rotation interpolation (like needed in computer graphics to animate between twoobject object orientations) is more straightforward.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 44

Page 23: Analytic and projective geometry - UPMC · Analytic and projective geometry Chantal Oberson Ausoni 29.7.2014 ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8,

3D-rotations

The space of rotations SO(3)

The unit quaternions form the unit sphere S3 in R4.The mapping ' : S3 �! SO(3) defined above is surjective. The preimage of everyrotation consists of two antipodal points in S3. The map ' is a covering in the sense oftopology.It is not the case of the map ' : S1⇥S1⇥S1 �! SO(3) defined through the Euler anglesand you do not have unique liftings of paths in SO(3).

In fact, S3 is essentially the unique connected covering space of SO(3), different from theidentity.

ICS Summer school Roscoff - Visualization at the interfaces 28.7-8.8, 2014 45