30
IFT3730: Infographie 3D Transformations Géométriques Derek Nowrouzezahrai Département d’informatique et de recherche opérationelle Université de Montréal

IFT3730: Infographie 3D Transformations Géométriques

  • Upload
    tracy

  • View
    39

  • Download
    1

Embed Size (px)

DESCRIPTION

IFT3730: Infographie 3D Transformations Géométriques. Derek Nowrouzezahrai Département d’informatique et de recherche opérationelle Universit é de Montréal. Aujourd’hui : Transformations 2D & 3D. Transformation en 2D Translation Changement d’échelle ( scaling ) Rotation - PowerPoint PPT Presentation

Citation preview

Page 1: IFT3730:  Infographie  3D Transformations  Géométriques

IFT3730: Infographie 3DTransformations Géométriques

Derek NowrouzezahraiDépartement d’informatique et de recherche opérationelleUniversité de Montréal

Page 2: IFT3730:  Infographie  3D Transformations  Géométriques

Aujourd’hui: Transformations 2D & 3D1. Transformation en 2D

- Translation- Changement d’échelle (scaling)- Rotation

2. Coordonées homogènes (2D)- Combinaisons des transformations

3. Transformation en 3D

Page 3: IFT3730:  Infographie  3D Transformations  Géométriques

Opérations mathématiques (1)

• Produit scalaire– projection d'un vecteur sur un autre où cosvuvu

u

v

cosv

222|| zyx vvvv

zzyyxx vuvuvuvu

Page 4: IFT3730:  Infographie  3D Transformations  Géométriques

Opérations mathématiques (2)•Produit vectoriel– Calcul d'un vecteur perpendiculaire aux deux autres– Règle de la main droite

xyyx

zxxz

yzzy

vuvuvuvuvuvu

vun

sinvuvu u

v

n

Page 5: IFT3730:  Infographie  3D Transformations  Géométriques

Translation en 2D

),( yxP

),( yyxxP

x

y

PTPyx

yx

yx

T

Page 6: IFT3730:  Infographie  3D Transformations  Géométriques

Changement d’échelle en 2D (scaling)

),( yxP

),( yyxxP

SPPyx

yx

yx

00

Page 7: IFT3730:  Infographie  3D Transformations  Géométriques

Rotation en 2D

RPPyx

yx

cossinsincos

sens anti-horaire

sincos: ryrxP

cossincossinsincos

)sin(sincos

sinsincoscos)cos(

:

yxrr

ryyx

rrrx

Pr

r ),( yxP

),( yxP

Page 8: IFT3730:  Infographie  3D Transformations  Géométriques

Coordonnées homogènes

• Pour Translation: T+P en addition • mais les autres transformations sont des multiplications

• Représentation des transformations sous une forme matricielle unique:+ uniformité+ composition+ opérations des 4x4 peuvent êtres exécutées en parallèle- optimisations possibles...

x

xy

x

tymxmytymxmxy

xtmmtmm

2221

12112221

1211

1100

(9 mult,6 add) vs. (4 mult,4 add)

Page 9: IFT3730:  Infographie  3D Transformations  Géométriques

Coordonnées homogènes• Remplacer les coordonnées euclidiennes du

point p par des coordonnées homogènes.2D:

3D:

p x,y T p' x,y,1 T

xh

, yh

,1

T

x,y,h T

x,y,1 T hx,hy,h T

p x,y,z T p' x,y,z,1 T

xh

, yh

, zh

,1

T

x,y,z,h T

x,y,z,1 T hx,hy,hz,h T

Page 10: IFT3730:  Infographie  3D Transformations  Géométriques

Translation: maintenant avec les matrices(grâce aux coordonnées homogènes)

PP

PyxT

yx

yx

yyxx

P

),(

11001001

1

Page 11: IFT3730:  Infographie  3D Transformations  Géométriques

Combinaison de translations en 2D

PP

P

PyyxxT

yx

yyxx

yx

yx

yx

PyxTyxTPyxTPPyxTP

),(

11001001

11001001

1001001

),(),(),(),(

2121

21

21

1

1

2

2

1122

22

11

Page 12: IFT3730:  Infographie  3D Transformations  Géométriques

Combinaison de changements d’échelle en 2D

PyyxxS

yx

yyxx

yx

yx

yx

PyxSyxSP

),(

11000000

11000000

1000000

),(),(

2121

21

21

1

1

2

2

1122

Page 13: IFT3730:  Infographie  3D Transformations  Géométriques

Combinaison de rotations en 2D

PR

yx

yx

yx

PRRP

)(

11000)cos()sin(0)sin()cos(

11000coscossinsinsincoscossin0cossinsincossinsincoscos

11000cossin0sincos

1000cossin0sincos

)()(

Page 14: IFT3730:  Infographie  3D Transformations  Géométriques

Combinaisons de matrices de transformation• + efficacité– une seule matrice composée est utilisée au lieu

d’une série de matrices• {R,T}– Sont des transformation rigid-body• préserve les longueurs et les angles

• {R,T,S}– transformation affine• préserve le parallélisme des lignes • (mais pas les longueurs ni les angles)

Page 15: IFT3730:  Infographie  3D Transformations  Géométriques

Propriétés des matrices de transformations

• Commutativité

• Associativité

• Inverses

M1(M2M3) (M1M2)M3

T 1(x,y) T( x, y)

S 1(x,y) S 1x ,

1y

R 1() R( ) R t ()

T1T2 T2T1

S1S2 S2S1

R1R2 R2R1

S(x y)RRS(x y)

Page 16: IFT3730:  Infographie  3D Transformations  Géométriques

Exemple d’une série de transformations

• Rotation autour d’un point Q• On sait comment faire une rotation autour de

l’origine, mais pas autour d’un point arbitraire

1. Translation telle que Q est à l’origine:2. Rotation de autour de l’origine:3. Translation de l’origine jusqu’à Q:

M T(x,y)R()T( x, y)P

),( yxT

)(R),( yxT

Page 17: IFT3730:  Infographie  3D Transformations  Géométriques

Exemple de non-commutativité

1000

0

1001001

1000000

1000

0

1000000

1001001

),(),(),(),(

yssxss

yx

ss

ST

ysxs

ss

yx

TS

yxTssSssSyxT

yy

xx

y

x

y

x

y

x

yxyx

Page 18: IFT3730:  Infographie  3D Transformations  Géométriques

Transformation 2D:rectangle à rectangle

),( maxmax yx

),( minmin yx

Y

X

Con

figur

atio

nin

itial

e

U

V

Con

figur

atio

nfin

ale

),( minmin vu

),( maxmax vu

XY UV

?

Page 19: IFT3730:  Infographie  3D Transformations  Géométriques

Transformation 2D:rectangle à rectangle

),( minmaxminmax yyxx

)0,0(

),( minmin yxT

XY UV

),( maxmax yx

),( minmin yx

Y

X

Con

figur

atio

nin

itial

e

U

V

Con

figur

atio

nfin

ale

),( minmin vu

),( maxmax vu

Page 20: IFT3730:  Infographie  3D Transformations  Géométriques

),( minmaxminmax yyxx

)0,0(

S umax uminxmax xmin

, vmax vminymax ymin

),( minmaxminmax vvuu

)0,0(

),( minmaxminmax vvuu

Transformation 2D:rectangle à rectangle XY UV

Page 21: IFT3730:  Infographie  3D Transformations  Géométriques

),( minmaxminmax vvuu

)0,0( minmin ,vuT

),( maxmax vu

),( minmin vu

Transformation 2D:rectangle à rectangle XY UV

Page 22: IFT3730:  Infographie  3D Transformations  Géométriques

Transformation 2D:rectangle à rectangle

),( maxmax yx

),( minmin yx

Y

X

Con

figur

atio

nin

itial

e

U

V

Con

figur

atio

nfin

ale

),( minmin vu

),( maxmax vu

XY UV

),( , ),( minminminmin minmax

minmax

minmax

minmax yxTSvuTM yyvv

xxuu

uvxy

Page 23: IFT3730:  Infographie  3D Transformations  Géométriques

Transformations en 3D

• 2D: matrice 3x3 en coordonnées homogènes• 3D: matrice 4x4 en coordonnées homogènes

),,,(),,( wzyxzyx

X

Y

Z

Système de coordonnées de la main droite rotation positive: sens anti-horaire

Page 24: IFT3730:  Infographie  3D Transformations  Géométriques

Transformations 3D de base

• Translation

• Changement d’échelle

1000100010001

tztytx

T

1000000000000

szsy

sx

S

Page 25: IFT3730:  Infographie  3D Transformations  Géométriques

Translation 3D•Déplace un ensemble de points (ou objets) d'une distance dans une certaine direction

),,( zyx dddT

z

y

x

Page 26: IFT3730:  Infographie  3D Transformations  Géométriques

Changement d’échelle 3D• Modification de la taille d’un ensemble de

points (ou d’objets) par rapport à l’origine

S(1.5,-0.5,1.0)

z

y

x

Page 27: IFT3730:  Infographie  3D Transformations  Géométriques

Transformations 3D de base

• Rotations

)(

10000cossin00sincos00001

xR

)(

10000cos0sin00100sin0cos

yR

)(

1000010000cossin00sincos

zR

Page 28: IFT3730:  Infographie  3D Transformations  Géométriques

Rotation 3D• Fait tourner d’un angle un ensemble de points

(ou objets) autour d’un axe de rotation.• La rotation se fait TOUJOURS par rapport à

l’origine.

Axe de rotation:

Rz()z

y

x

Page 29: IFT3730:  Infographie  3D Transformations  Géométriques

Transformation de normales

• Points, tangentes, vecteurs fonctionnent avec les matrices standards

• Normale à la surface fonctionne différemment

2.0,1SM

nMn T 1

'

Page 30: IFT3730:  Infographie  3D Transformations  Géométriques

En résumé…• Les transformations importantes en infographie 2D et 3D sont :– La rotation;– La translation;– Le changement d’échelle.

• Grâce aux coordonnées homogènes, la translation se représente comme une opération matricielle, tout comme les 2 autres.

• Ces matrices de transformations peuvent être multipliées ensemble et former une seule matrice M.

• L’ordre des transformations est important.