Computer Graphics transformations

swatihans 691 views 39 slides Jan 31, 2023
Slide 1
Slide 1 of 39
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39

About This Presentation

;;


Slide Content

Computer Graphics 2D transformations

Overview Why transformations? Basic transformations: translation, rotation, scaling Combining transformations homogenous coordinates, transform. Matrices

Why transformation? Model of objects world coordinates: km, mm, etc. Hierarchical models:: human = torso + arm + arm + head + leg + leg arm = upperarm + lowerarm + hand … Viewing zoom in, move drawing, etc. Animation

Translation Translate over vector ( t x , t y ) x’=x+ t x , y’=y+ t y or x y P P+T T

Translation polygon Translate polygon: Apply the same operation on all points. Works always, for all transformations of objects defined as a set of points. x y T

Rotation x y P x y P’ a

Rotation around a point Q x y P x y P’ a Q P  Q

Scale with factor s x and s y : x’= s x x , y’= s y y or Scaling x y P x P’ Q’ Q

Scaling with respect to a point F Scale with factors s x and s y : P x ’= s x P x , P y ’= s y P y With respect to F : P x ’  F x = s x ( P x  F x ), P y ’  F y = s y ( P y  F y ) or P x ’= F x + s x ( P x  F x ), P y ’= F y + s y ( P y  F y ) x y P x P’ Q’ Q F P  F

Transformations Translate with V : T = P + V Scale with factor s x = s y = s : S = s P Rotate over angle a: R’ x = cos a P x  sin a P y R’ y = sin a P x + cos a P y x y P T S R

Transformations… Messy! Transformations with respect to points: even more messy! How to combine transformations?

Homogeneous coordinates 1 Uniform representation of translation, rotation, scaling Uniforme representation of points and vectors Compact representation of sequence of transformations

Homogeneous coordinates 2 Add extra coordinate: P = ( p x , p y , p h ) or x = ( x, y, h ) Cartesian coordinates: divide by h x = ( x/h , y/h ) Points: h = 1 (for the time being…), vectors: h = 0

Translation matrix

Rotation matrix

Scaling matrix

Inverse transformations

Combining transformations 1

Combining transformations 2

Combining transformations 3

Rotation around a point 1 R 1) 2) 3)

Rotation around a point 2 R 1) 2) 3)

Rotation around point 3 R 1) 2) 3)

Rotation around point 4 R 1) 2) 3)

Scaling w.r.t. point 1 F 1) 2) 3)

Scaling w.r.t.point 2 F 1) 2) 3)

Scaling w.r.t.point 3 F 1) 2) 3)

Order of transformations 1 x y x’ y’ x’’ y’’ x y x’ y’ x’’ y’’ Matrix multiplication does not commute. The order of transformations makes a difference! Rotation, translation… Translation, rotation…

Order of transformations 2 Pre-multiplication: P’ = M n M n-1 … M 2 M 1 P Transformation M n in global co o rdinates Post-multiplication: P’ = M 1 M 2 … M n-1 M n P Transformation M n in local co o rdinates: the coordinate system after application of M 1 M 2 … M n-1

Order of transformations 3 OpenGL: glRotate, glScale , etc.: Post-multiplication of current transformation matrix Always transformation in local coordinates Global coordinate version: read in reverse order

Order of transformations 4 glTranslate(…); glRotate(…); x y x’’ y’’ x’ y’ Local trafo interpretation Local transformations : x y x’’ y’’ Global transformations: x’ y’ Global trafo interpretation

Matrices in general rotation and scaling translation

Direct construction of matrix x y v A B T u If you know the target frame: Construct matrix directly. Define shape in nice local u,v coordinates, use matrix transformation to put it in x,y space.

Direct construction of matrix x y v A B T u If you know the target frame: Construct matrix directly.

Other 2D transformations Reflection Shear Can also be combined

Reflection over axis Reflext over x- axis: x’= x , y’=  y or x y

Reflect over origin Reflect over origin: x’=  x , y’=  y or x y

Shear Shear the y -as: x’= x+f , y’=y or x y 

2D transformations summarized Transformations: modelling, viewing, animation; Several kinds of transformations; Homogeneous co ordinates; Combine transformations using matrix multiplication.
Tags