Académique Documents
Professionnel Documents
Culture Documents
Bases
Synthèse d’images Points
Vecteurs
Outils mathématiques de base Lignes
Sphères
Alexandre Meyer Matrices et transformations
http://bat710.univ-lyon1.fr/~ameyer/cours
1 Synthèse d’images 2
Right-Handed System Y
(ortho normé)
X X
Z
Synthèse d’images 3 Synthèse d’images 4
Z Points != Vecteurs
Exercice
Point – Point = Vecteur
P(x,y,z) x=?
Vecteur+Vecteur = Vecteur
r y=?
a Point + Vecteur = Point
Y z=?
Point + Point = ?
b
1
Vecteurs, V (x, y, z) Vecteurs V
Longueur (norme) d’un vecteur V (x, y, z)
w |V| =
v
2v v
(-1)v (1/2)V v+w ^
vecteurV V
Addition de vecteurs Vecteur unitaire V = normede V = | V |
multiplication par un scalaire v+w
-> vecteurs restent //
Produit scalaire (Dot Product)
w y
P a · b = |a| |b| cosθ
v-w Le produit scalaire
v v cosθ = a · b/ |a| |b| est un scalaire
w a · b = xa ·xb + ya ·yb + za ·zb
Difference de vecteur O Si les vecteurs sont unitaires?
x
v - w = v + (-w) Si le produit scalaire == 0 ou == 1?
Vecteur OP
Synthèse d’images 7 Synthèse d’images 8
|a x b| = |a||b|sinθ
Exercices Exercices
A(1,0,0), B(0,1,0), C(0,0,1) A(1,0,0), B(0,1,0), C(0,0,1)
Vecteur normal au plan? Vecteur normal au plan?
2
Equation paramétrique d’une ligne Equation d’une sphère
Soit hypotenuse
P0 = (x0, y0, z0) et Théorème de c
a2 + b2 = c2 b
Pythagore
P1 = (x1, y1, z1) a
la ligne P passant par P0 et P1 est Cercle de rayon,
pour tout P sur le
x(t) = x0 + t(x1 - x0) cercle : P
P(t) = P0 + t(P1 - P0) = y(t) = y0 + t(y1 - y0) r yp
z(t) = z0 + t(z1 - z0) x2 + y2 = r2 (0, 0) xp
avec - ∞ < t < ∞
1 0 0 0
Vecteur peut être considéré comme une 0 2 0 0
0 0 −1 0
matrice 1 x M 0 0 0 −4
v = (x y z )
3
Opérations sur les matrices Opérations sur les matrices
Addition Multiplication
Possible seulement si
x1 par y1 et x2 par y2 SSI y1 = x2
Résultat : matrice x1 par y2
BxA != AxB
.
*
__ __ __
Synthèse d’images 21 Synthèse d’images 22
Inverse Transformation 3D
En 3D, un vecteur est transformé par une
Si A x B = I et B x A = I alors matrice 3 par 3
A = B-1 et B = A-1 a b c x ax + by + cz
d e f y = dx + ey + fz
g h i z gx + hy + iz
a d g
(x y z ) b e h = (xa + yb + zc xd + ye + zf xg + yh + zi)
c f i
4
Changement d’échelle Rotation :exercice ? ? ?
Matrice diagonale Rotation autour de ? ? ?
a 0 0 x ax l’axe des z ? ? ?
0 b 0 y = by
0 0 c z cz Y
P' = ei(α +θ ) P = (x y)
Exemple = (r cos(α ) r sin(α ))
θ
2 0 0 3 6 P = r (cos(α ) + i sin(α ))
α
0 1 0 4 = 4 = reiα
0 0 − 2 5 −10 X
Rotation Y Rotation
P' = ei(α +θ )
Rotation autour de l’axe des z Rotation autour de l’axe des z
θ
P
cos(θ) - sin(θ) 0 Y
P ' = rei (α +θ ) = reiα eiθ α (cos( θ )x - sin( θ )y sin ( θ )x + cos( θ )y)
X sin(θ) cos(θ) 0 θ
= ( x + iy )(cos(θ ) + i sin(θ )) 0
0 1 (x y )
= x cos(θ ) + xi sin(θ ) + iy cos(θ ) + iyi sin(θ ))
cos(θ ) − sin(θ ) x X
=
sin(θ ) cos(θ ) y i2=-1
Car Z ne change pas
5
Translation avec coord homogène Coordonnées homogène
Ajoute 1D, mais on la contraint à être égale à 1
(x,y,z,1)
1 0 0 a x x + a
0 1 0 b y y + b
Homogène veut dire qu’un point de l’espace 3D
0 =
0 1 c z z + c peut être représente par une infinité de point
0 0 0 1 1 1 homogène 4D
(2 3 4 1) = (4 6 8 2) = (3 4.5 6 1.5)
R4 R5 R6 T 2 R=rot(Z,Pi/2)
R7 R8 R9 T 3 = T.R T=trans(2,0,0)
0 0 0 1 Calculer P’=R.T.P et P”=T.R.P
P’ != P”
6
Rotation de l’objet Programmation OpenGL
Pour faire une rotation de l’objet OpengGL
mat[0] mat[1] mat[2] mat[3]
GLfloat mat[16]; mat[4] mat[5] mat[6] mat[7]
mat[8] mat[9] mat[10] mat[11]
mat[12] mat[13] mat[14] mat[15]
glTranslate( x, y, z);
Ouf!!! …
On a la base …
Synthèse d’images 39