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
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 vertices. • A fragment is a potential pixel carrying information about its color and location and is used 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
What kind of transformations do we need?
Geometric transformations A geometric transformation is a function f : D points, and which is onto and one-to-one.
! R, whose domain D and range R are
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 be constructed.
ICS Summer school Roscoff - Visualization at the interfaces
28.7-8.8, 2014
5
What kind of transformations do we need?
3D cartesian coordinates The position of any point p in three-dimensional space is specified by three Cartesian coordinates (p1, p2, p3), its signed distances to three mutually perpendicular planes. In other words, we have three orthogonal axes Ox, Oy and Oz, along which we make a perpendicular projection of our point.
Other coordinate systems: polar, spherical... ICS Summer school Roscoff - Visualization at the interfaces
28.7-8.8, 2014
6
What kind of transformations do we need?
Link with linear algebra The point p, of cartesian coordinates (p1, p2, p3) in R3, can be represented by a vector ! op from the o to the point p. We usually define the standard basis {e1, e2, e3} as 0 origin 1 1 B C e1 = @0A along Ox, 0 0 1 0 B C e2 = @1A along Oy 0 0 1 0 B C and e3 = @0A along Oz 1 0
1
p1 B C so that @p2A = p1e1 + p2e2 + p3e3. p3
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 basis
Any other basis {f1, f2, f3} can be chosen; changing the base means for example writing the new basis in the old f1 = p11e1 + p21e2 + p31e3 f2 = p12e1 + p22e2 + p32e3 f3 = p13e1 + p23e2 + p33e3 The new coordinates of v = v1e1 + v2e2 + v3e3 in the basis {f1, f2, f3} are given as v = = + +
v10 f1 + v20 f2 + v30 f3 v10 (p11e1 + p21e2 + p31e3) v20 (p12e1 + p22e2 + p32e3) v30 (p13e1 + p23e2 + p33e3) 0
1
0
1
0
1
v1 p11 p12 p13 v0 B C B C B 1 C This means that we have the matrix equation @v2A = @p21 p22 p23A · @v20 A giving v3 p31 p32 p33 v30 the old coordinates as a function of the newhones, i or inverting the matrix, the new ones as a function of the old ones. The matrix P = pij is the change of basis matrix. Its columns are the coordinates of the new⌘basis vectors fi in the old vector basis ei. In a simplified ⇣ notation: P = f1 f2 f3 . ICS Summer school Roscoff - Visualization at the interfaces
28.7-8.8, 2014
8
What kind of transformations do we need?
Linear maps and matrices Linear 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,
2R
The transformation f : v 7! A · v is linear. Conversely, if f : R30 !1 R3 v1 ⇣ ⌘ B C is linear, we can write the matrix A = f (e1) f (e2) f (e3) so that A · @v2A = v3 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 given basis) 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. Matrices:
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 maps 1. 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 matrix 0
cos(') B @ sin(') 0
1
sin(') 0 C cos(') 0A 0 1
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 for example the translation). It means that we will not be able in general to write a global transformation as a 3 ⇥ 3-matrix.
ICS Summer school Roscoff - Visualization at the interfaces
28.7-8.8, 2014
10
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 2D The 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 the projective plane are the lines (in space) through the origin. The coordinates [x, y, z] of a point in the projective plane are called homogeneous coordinates. Each point in the projective plane can be represented by an infinity of triples: for example, [x, y, z] = [2 x, 2 y, 2 z] .
ICS Summer school Roscoff - Visualization at the interfaces
28.7-8.8, 2014
12
What kind of transformations do we need?
Homogeneous coordinates in 2D, what we need The lines in the plane Oxy correspond to a last coordinate z = 0. Together, all these points of type [x, y, 0] form a line at infinity.
For all other lines, we can consider their intersection with the plane z = 1 and have coordinates [x/z, y/z, 1], as well as [x, y, z].
What is interesting for us here are the inclusions (x, y) (x, y)
! [x, y, 1] ! [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 3D The 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 the origin in R4. Again we can use the inclusions (x, y, z) ! [x, y, z, 1] and (x, y, z) ! [x, y, z, 0] to represent the points of the Euclidean space through coordinates [x, y, z, 1] and 3D-vectors as elements [x, y, z, 0] of RP3.
ICS Summer school Roscoff - Visualization at the interfaces
28.7-8.8, 2014
14
Affine space
What kind of transformations do we need?
Corresponding to this idea of using at the same time points and vectors, there is the mathematical concept of affine space. Given a vector space E, an affine space (E, E, +) is obtained 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-one correspondance 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 an affine space, on which a vector is the difference between a pair of points. It means that there is no canonical choice of where the origin should go in the space, because it can be translated anywhere. On an affine space (E, E, +), choosing an origin on E and a basis {e1, · · · , en} of E, we obtain what we call a frame (o; e1, · · · , en), and can express every point p in it: ! op = Pn i=1 xi ei . An affine space is nothing more than a vector space whose origin we try to forget about, by adding translations to the linear maps.
Marcel Berger ICS 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 a The translation by a vector a corresponds to the affine transformation a : E ! E defined by 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
1 B0 B B @0 0
0
0 1 0 0
1 B0 B B @0 0
1 0
1
0
1
p1 p 1 + a1 0 a1 Bp C Bp + a C 0 a2 C C B 2C B 2C C·B C=B 2 C @p3 + a3A 1 a 3 A @p 3 A 1 1 0 1 0 1 0 0
1 0
1
0
1
0 a1 v1 v1 C B C C B 0 a 2 C Bv 2 C Bv C C · B C = B 2C @v3A 1 a 3 A @v 3 A 0 1 0 0
ICS Summer school Roscoff - Visualization at the interfaces
28.7-8.8, 2014
16
What kind of transformations do we need?
Affine transformations Considering an affine space (E, E, +), the map f : E ! E is affine if it consists of a ! = f (o) + translation and a linear map l: choosing an origin o 2 E, f (x) = f (o + ox) ! 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 (x) giving a f (o) + l(oo0) + l(o0x) = f (o) + l(oo0 + o0x) = f (o) + l(ox) 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 p1, · · · , pn in an affine space (E, E, +), with n weights 1, · · · , n P associated to these points (with the sum n i=1 i 6= 0) the corresponding barycentre is the only point g with n X
!
i gpi = 0.
i=1
P Given an origin, it is defined by ! og = n i=1 ! ! ! using Chasles relation: ac = ab + bc.
!. i op
i Existence and unicity are proven easily
1 for all n), the barycentre is the centroid. In the case of equal weights ( i = n
ICS Summer school Roscoff - Visualization at the interfaces
28.7-8.8, 2014
18
Digression on barycentres
Affine sum Consider the equation n X ! og =
i=1
i ! opi
defining the barycentre. Since every i is divided by the sum , it is equivalent to consider all weights to sum to one. Although the sum of two points of E and the multiplication of a point by a real are not P defined in general, if the i sum to one, we can write the sum n i=1 i pi . It follows from the 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 nonnegative weights summing to one is the convex hull of these points. This corresponds to the idea of including, for each pair of points p and q, all points on the segment between them.
Since every point p in the convex hull of a set of points p1, · · · , pn is 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 p1, · · · , pn.
ICS Summer school Roscoff - Visualization at the interfaces
28.7-8.8, 2014
20
What kind of transformations do we need?
The equivalent definition for affine transformations A transformation f : E ! E is affine iff for every set of points p1, · · · , pn, for every family of weights 1, · · · , n summing to one, f(
n X
i pi ) =
i=1
n X
i f (pi ).
i=1
In other words, f preserves barycentres. In particular it preserves barycentric coordinates. P Remember that we can write the n i=1 i pi 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 transformations 1. 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), 0 1 0 1 v1 b1 B C B C the coordinates of an image f (x) can be written as A · @v2A + @b2A, v3 b3 • where A is the 3 ⇥ 3-matrix of the linear map, the (v1, v2, v3) are the coordinates ! in this basis of ox ! • 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 called augmented matrix to write a matrix formulation for the coordinates of f (x) 0 B B @
Mf = B
1 0
1
a11 a12 a13 b1 v1 C B a21 a22 a23 b2 C Bv2C C C·B C a31 a32 a33 b3 A @v3A 1 0 0 0 1
ICS Summer school Roscoff - Visualization at the interfaces
28.7-8.8, 2014
22
What kind of transformations do we need?
Affine transformations: changing frames
Given (o; e1, e2, e3) and (o0; e01, e02, e03) two frames of R3, p a point of coordinates (x1, x2, x3) in the first0frame, (x01, x02, x03) in the second frame. 1 v1 B C We write @v2A the coordinates of o0 in the first frame (o; e1, e2, e3). v3 • Vector coordinates: we have seen the change of basis matrix P such that: 0
1
0
1
x1 x0 B C B 1 C @x2A = P · @x02A . x3 x03
• For the homogeneous coordinates: 0
1
0
x1 Bx C B P B 2C B B C=B @x 3 A @ 1 0 0 0
v1 v2 v3 1
1 0 01 x1 C Bx 0 C C B 2C C · B 0 C. A @x 3 A
1
• For the augmented matrix: let again f be an affine transformation R3 ! R3, Mf and Mf0 be the matrices of f in these two frames Mf0 = Pa 1 · 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 transformation It is an affine transformation determined by a centre s = (sx, sy , sz ) and a ratio , such that ! f (x) = s + sx. The augmented matrix Mf is: 0
1
0 0 (1 )sx B 0 0 (1 )sy C B C Mf = B C @ 0 0 (1 )sz A 0 0 0 1
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
What kind of transformations do we need?
Example of affine transformation: general rotation By general we mean a rotation for which the origin may not be on the axis. Consider the 3D rotation of angle ' around an axis parallel to Oz and through the point ( x0, y0, 0). We can translate by (x0, y0, 0), then rotate around Oz, then translate again by (x0, y0, 0). The augmented matrix of f is: 0
cos(') B sin(') B Mf B @ 0 0
sin(') cos(') 0 0
0 x0 0 y0 1 0
1
cos(') x0 + sin(') y0 sin(') x0 cos(') y0 C C C A 0 1
ICS Summer school Roscoff - Visualization at the interfaces
28.7-8.8, 2014
25
What kind of transformations do we need?
Composition of affine transformations Let f, g : R3 ! R3 be two affine transformations, say f (x) = Lf · x + bf Then, g
g(x) = Lg · x + bg 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 the linear parts. 2. The translation part is obtained as bg f = Lg · bf + bg . 3. The augmented matrice of the composition g product:
f can also be obtained by a matrix
Mg f = Mg · Mf .
ICS Summer school Roscoff - Visualization at the interfaces
28.7-8.8, 2014
26
What kind of transformations do we need?
Euclidean affine spaces
! If we take on the vector space E a norm k.k and the associated distance d(a, b) = kabk 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 = I3.
ICS Summer school Roscoff - Visualization at the interfaces
28.7-8.8, 2014
27
What kind of transformations do we need?
Projective map A map f : R3 ! R3, (x1, x2, x3) 7! (x01, x02, x03) is said to be projective if there is a linear map Lf : R4 ! R4 with Lf (x, y, z, 1) proportional to (x0, y 0, z 0, 1). Remarks: 1. Sometimes, the map f is not defined on all space, but only on R3 \ ⇡, ⇡ a plane, like the 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 on lines. 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
ICS Summer school Roscoff - Visualization at the interfaces
⌘T
is equal to (x0, y 0, z 0, 1).
28.7-8.8, 2014
28
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 transformation if and only if they are proportional: there is a 2 R with M1 = · M2. It means that we can choose the matrix representant M with m44 = 1 . • For affine transformations R3 mations, you have 15.
! R3 you have 12 parameters; for projective transfor-
• Again, the composition of projective transformations is a projective transformation and the product of the individual matrices is the matrix of the composition: Mf f 0 = Mf · Mf0 .
ICS Summer school Roscoff - Visualization at the interfaces
28.7-8.8, 2014
29
What kind of transformations do we need?
The case of perspective
The rules of perspective are meant to translate in geometrical rules the similarity of a picture with 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), (according to a world frame (o; e1, 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
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 of o + x1e1 + x2e2 + x3e3 on the plane ⇡ expressed in the frame (o; e01, e02). It is not defined 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 of the ray through c and o + x1e1 + x2e2 + x3e3 with the plane ⇡. • If we move the point c away from the plane ⇡ along the line defined by v, the limit case of c at infinity is a parallel projection (with direction v, on ⇡). It corresponds to the view at infinite distance and can be orthogonal or oblique, depending on the 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 plane Computing 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
⌘T
⇣
and v1 = 0 1 0
⌘T
and
• ⇡2 the plane through (0, 0, 0) generated by the vectors ⇣ ⌘T ⇣ ⌘T u2 = 1 0 1 and v2 = 0 1 0 .
The map is defined by f (x1, y1) = ( 1 x1x , 1 y1x ) in the frames (o; u~1, v~1) and (o; u~1, v~1). 1 1 Is it a projective transformation R2 ! R2? Yes, since we can write the augmented matrix equation 0
1 0
1
0
1
1 0 0 x1 x1 B C B C B C @ 0 1 0A · @ y1 A = @ y1 A , 1 0 1 1 1 x1
which is proportional to ( 1 x1x , 1 y1x , 1). The augmented matrix is invertible. 1 1
ICS Summer school Roscoff - Visualization at the interfaces
28.7-8.8, 2014
32
What kind of transformations do we need?
Example computation of the orthogonal parallel projection The orthogonal parallel projection onto the 2 3 plane z = 0 is affine and can be written with 1 0 0 0 6 0 1 0 07 6 7 the augmented matrix: P = 6 7. 4 0 0 0 05 0 0 0 1
In computer graphics, six clipping planes are given and the transformation is written as a composition of a scaling and a translation. The center of the defined box is now at the origin and the box is scaled to the unit cube, which is defined to have a minimum corner at ( 1, 1, 1) and a maximum corner at (1, 1, 1):
2
2 6 right lef t 6 0 6 P =S·T =6 6 0 4
0
0
0
2 top bottom
0
0 0
ICS Summer school Roscoff - Visualization at the interfaces
2 f ar near
0
3 2
0
7 61 0 0 6 07 7 60 1 0 7·6 6 07 5 40 0 1
1
0 0 0 28.7-8.8, 2014
3 lef t+right 2 7 top+bottom 7 7 2 7. f ar+near 7 5 2
1
33
What kind of transformations do we need?
Perspective view of lines Suppose that we have a perspective view like before, given by a camera position c and a screen 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 through c and D with ⇡.
• If D contains c, its perspective view is a point: the intersection of D with ⇡. This point is 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
What kind of transformations do we need?
Perspective and parallelism of lines Suppose that we have two parallel lines D and D 0. Define ⇡D the plane through D and c and ⇡D0 the plane through D 0 and c. The intersection of planes ⇡D and ⇡D0 is a line D 00 containing c.
• If D (and D 0) are not parallel to ⇡, D 00 is projected to its vanishing point in ⇡. The perspective views of D (and D 0) contain this point. In other words, all lines parallel to a line through c contain its vanishing point. • If the lines are parallel to ⇡, and do not contain c, D 0 and D 0 have parallel perspective 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 lines Suppose that we take instead D and D 0 non parallel and contained in a same plane ⇡ 0. The plane parallel to ⇡ 0 through c contains the lines parallel to D, resp. D 0. The intersection of this 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
What kind of transformations do we need?
Perspective view of a sphere Considering all rays issued from the camera and going through the sphere, we obtain a right circular 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 depends 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 origin Every 3D-rotation (say it is of angle ↵ around an axis v) can be written as a sequence of elemental rotations around the coordinate axes. We can see such a decomposition for example 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
Addendum: 3D-rotations
The particular case of 3D rotations through the origin Then, 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
1
B Rx(↵x) = @0
0
0
1
0
cos(↵) sin(↵) 0 cos(↵y ) 0 B C B cos(↵) 0A, Ry (↵y ) = @ 0 1 @ sin(↵) 0 0 1 sin(↵y ) 0 1 0 0 C cos(↵x) sin(↵x)A. sin(↵x) cos(↵x)
1
sin(↵y ) C 0 A and cos(↵y )
Remark: It is also possible to begin with Oz, then Oy, then Ox, for example, changing the order 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 angles Actually, it is even possible to write every rotation matrix R as a product of three elemental rotation 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. For example, 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 axis Ox, the second one is about a new axis Oy 0 = X(↵)e2 and the third about a new axis Oz 00 = Y ( )X(↵)e3.
ICS Summer school Roscoff - Visualization at the interfaces
28.7-8.8, 2014
40
3D-rotations
Limitations to the use of the Euler angles The Euler angles, whatever the convention used, implies that you use three angles to describe a 3D-rotation. It gives birth to a well-known problem called gimbal lock. In a few words, it is a problem due to the difficulty of parametrizing SO(3), the group of 3Drotations. 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
Quaternions Reminder on complex numbers: Complex numbers can be defined as elements of R2 with an 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 distributive over the addition. This algebraic theory of complex numbers was created by Hamilton in 1843. For a long time, he had been looking for an analogeous product for triplets of numbers (product which has now been proved not to exist). He was actually able to define a non-commutative product on quadruplets of numbers: (a1, b1, c1, d1) · (a2, b2, c2, d2) = (a1a2 b1b2 c1c2 d1d2, a 1 b 2 + b 1 a 2 + c 1 d 2 d 1 c2 , a 1 c2 b 1 d 2 + c1 a 2 + d 1 b 2 , a 1 d 2 + b 1 c2 ICS Summer school Roscoff - Visualization at the interfaces
c1b2 + d1a2).
28.7-8.8, 2014
42
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 pure quaternion (0, b, c, d). The norm of a quaternion (a, b, c, d) is equal to
q
a 2 + b 2 + c2 + d 2 =
q
a2 + 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✓) (or ei✓ in the Euler notation).
ICS Summer school Roscoff - Visualization at the interfaces
28.7-8.8, 2014
43
3D-rotations
Quaternions as rotations In 2D, a unit complex number can be used to compute the rotation of a vector (v1, v2) with angle ✓: cos✓ (cos✓, sin✓)·(v1, v2) = (cos✓ v1 sin✓ v2, cos✓ v2+sin✓ v1) = sin✓
!
!
sin✓ v · 1 . cos✓ v2
In R3, quaternions can help to express 3D-rotations, using the “conjugation” , i.e., a product 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 correspond 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 two object object orientations) is more straightforward. ICS Summer school Roscoff - Visualization at the interfaces
28.7-8.8, 2014
44
3D-rotations
The space of rotations SO(3) The unit quaternions form the unit sphere S 3 in R4. The mapping ' : S 3 ! SO(3) defined above is surjective. The preimage of every rotation consists of two antipodal points in S 3. The map ' is a covering in the sense of topology. It is not the case of the map ' : S 1 ⇥ S 1 ⇥ S 1 ! SO(3) defined through the Euler angles and you do not have unique liftings of paths in SO(3). In fact, S 3 is essentially the unique connected covering space of SO(3), different from the identity.
ICS Summer school Roscoff - Visualization at the interfaces
28.7-8.8, 2014
45