0% found this document useful (0 votes)
15 views

Modeling Transformation

The document defines and explains different types of geometric transformations, including: 1) Transformations map positions that define an object to new positions and can be used for animation, deformation, projection, and other applications. 2) Simple transformations include translation, rotation, and scaling and can be combined. Most are invertible except scaling by 0. 3) Transformations become increasingly complex, preserving different properties, from rigid/Euclidean to projective. Linear transformations include scaling, reflection, and shear. Homogeneous coordinates allow all transformations to be represented by matrix multiplication in a consistent way.

Uploaded by

Alif hasan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Modeling Transformation

The document defines and explains different types of geometric transformations, including: 1) Transformations map positions that define an object to new positions and can be used for animation, deformation, projection, and other applications. 2) Simple transformations include translation, rotation, and scaling and can be combined. Most are invertible except scaling by 0. 3) Transformations become increasingly complex, preserving different properties, from rigid/Euclidean to projective. Linear transformations include scaling, reflection, and shear. Homogeneous coordinates allow all transformations to be represented by matrix multiplication in a consistent way.

Uploaded by

Alif hasan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 46

Transformation

Background
What is Transformation ?

1
What is a Transformation

• Transformation:
• An operation that changes one configuration into
another
• For images, shapes, etc.
• A geometric transformation maps positions that
define the object to other positions
• Linear transformation means the transformation is
defined by a linear function... which is what matrices
are good for.

2
What is a Transformation?

• A function that maps points x to points x':


Applications: animation, deformation, viewing,
projection, real-time shadows, …

3
Simple Transformations

• Can be combined
• Are these operations invertible?
Yes, except scale = 0
4
Rigid-Body / Euclidean Transforms

• Preserves distances
• Preserves angles

Rigid / Euclidean

Identity
Translation
Rotation

5
Similitudes / Similarity Transforms

• Preserves angles

Similitudes

Rigid / Euclidean

Identity
Translation Isotropic Scaling
Rotation

6
Linear Transformations

Similitudes
Linear
Rigid / Euclidean
Scaling
Identity
Translation Isotropic Scaling Reflection
Rotation
Shear

7
Linear Transformations

• L(p + q) = L(p) + L(q)


• L(ap) = a L(p)

Similitudes
Linear
Rigid / Euclidean
Scaling
Identity
Translation Isotropic Scaling Reflection
Rotation
Shear

8
Affine Transformations

• preserves
parallel lines
Affine

Similitudes
Linear
Rigid / Euclidean

Scaling
Identity
Translation Isotropic Scaling Reflection
Rotation
Shear

9
Projective Transformations

• preserves lines
Projective

Affine

Similitudes
Linear
Rigid / Euclidean

Scaling
Identity
Translation Isotropic Scaling Reflection
Rotation
Shear

Perspective
6.837 Fall 06 – Durand 10
How are Transforms Represented?

x' = ax + by + c
y' = dx + ey + f

x' a b x c
= +
y' d e y f

p' = Mp + t
11
Translation in homogenous coordinates

x' = ax + by + c
y' = dx + ey + f
Cartesian formulation Homogeneous formulation

x' a b c x
x' a b x c =
= + y‘ d e f y
y' d e y f
1 0 1 1
0
p' = Mp + t p' = Mp
12
Homogeneous Co-ordinates

• Translation, scaling and rotation are expressed (non-


homogeneously) as:
• translation: P = P + T
• Scale: P = S · P
• Rotate: P = R · P
• Composition is difficult to express, since translation not
expressed as a matrix multiplication
• Homogeneous coordinates allow all three to be expressed
homogeneously, using multiplication by 3 ´ 3 matrices
• W is 1 for affine transformations in graphics

13
Homogeneous Coordinates
• Add an extra dimension
• in 2D, we use 3 x 3 matrices
• In 3D, we use 4 x 4 matrices

• Each point has an extra value, w

x' a b c d x
y' e f g h y
=
z' i j k l z
w' m n o p w

p' = Mp
14
Homogeneous Coordinates

• Most of the time w = 1, and we can ignore it

x' a b c d x
y' e f g h y
=
z' i j k l z
1 0 0 0 1 1
• If we multiply a homogeneous coordinate
by an affine matrix, w is unchanged

15
Mechanics of Rigid
Transformations

• Translate
• Rotate
• Scale

16
Translation – 2D
Y Y

(4,5) (7,5)

(7,1) (10,1)
Before Translation X Translation by (3,-4) X

x’ = x + dx  x  x  d x 
P    P    T    P  P  T
y’ = y + dy
 y  y  d y 
Homogenious Form
 x   1 0 d x   x 
 y    0 1 d  *  y 
   y  

 1  0 0 1   1  17
Scaling – 2D

Y Y
Types of Scaling:

Differential ( sx != sy )
(4,5) (7,5) Uniform ( sx = sy )
(2,5/4) (7/2,5/4)
Before Scaling X Scaling by (1/2, 1/4) X

x  s x * x
y  s y * y
S * P  P Homogenious Form
    x   s x 0 0  x 
 y    0 sy 0 *  y 
sx 0   x   x * sx 
  
0 *   
 s y   y   y * s y 

 1   0 0 1  1 
18
Rotation – 2D

te d
rota
r cos   al
v  or ig i n
 r sin  

r cos     
v   
 r sin      

 x  r cos  cos   r sin  sin 


expand       
 y  r cos  sin   r sin  cos 

x  r cos  x  x cos   y sin 


but 
y  r sin  y  x sin   y cos 
Rotation – 2D
Y Y
Before Rotation Rotation of 45 deg. w.r.t. origin

(4.9,7.8)
cos 45  sin 45 0
 sin 45 cos 45 0
(2.1,4.9)  
 0 0 1
(5,2) (9,2)
X X

x * cos  y * sin   x
x * sin   y * cos  y
Homogenous Form
R *P P
 x  cos   sin  0  x 
cos  sin    x   x * cos  y * sin    y   sin  cos  0 *  y 
 sin  cos  *  y    x * sin   y * cos       
       1   0 0 120  1 
Mirror Reflection
Y Y

(1,1)
(-1,1) (1,1)

X X

(1,-1)

Reflection about X - axis Reflection about Y - axis


x  x y    y x   x y   y
1 0 0  1 0 0
M x  0  1 0 M y   0 1 0
0 0 1  0 0 1
21
  Translation   S

1 0 d x  sx 0 0
0 1 d  0 sy 0
 y 
0 0 1   0 0 1

  Rotation   Re   Re

cos   sin  0 1 0 0   1 0 0
 sin  cos  0 0  1 0   0 1 0
     
 0 0 1 0 0 1  0 0 1

22
Shearing Transformation

1 a 0  1 0 0  1 a 0
SH x  0 1 0 SH y  b 1 0 SH xy  b 1 0
0 0 1 0 0 1 0 0 1

Sheared in X Sheared in Y Sheared in both X


unit cube
direction direction and Y direction

23
Inverse Transforms

24
Inverse Transformations

Translation : T -1
(dx,dy)  T(-dx,-dy)
Rotation : R -1
(θ )  R(-θ )  R T
( )

Scaling : S -1
(sx,sy)  S( 1 sx , 1sy )
Mirror Ref : M  M x
-1
x

M  My-1
y

25
Composing Transformations

26
How are transforms combined?
Scale then Translate
(5,3)
Scale(2,2) (2,2) Translate(3,1)
(1,1) (3,1)
(0,0) (0,0)

Use matrix multiplication: p' = T ( S p ) = TS p


1 0 3 2 0 0 2 0 3
TS = 0 1 1 0 2 0 = 0 2 1
0 0 1 0 0 1 0 0 1

Caution: matrix multiplication is NOT commutative!


27
Non-commutative Composition
Scale then Translate: p' = T ( S p ) = TS p
(5,3)
Scale(2,2) (2,2) Translate(3,1)
(1,1) (3,1)
(0,0) (0,0)

Translate then Scale: p' = S ( T p ) = ST p


(8,4)
Translate(3,1) (4,2) Scale(2,2)
(1,1) (6,2)
(3,1)
(0,0)

28
Non-commutative Composition
Scale then Translate: p' = T ( S p ) = TS p
1 0 3 2 0 0 2 0 3
TS = 0 1 1 0 2 0 = 0 2 1
0 0 1 0 0 1 0 0 1

Translate then Scale: p' = S ( T p ) = ST p


2 0 0 1 0 3 2 0 6
ST = 0 2 0 0 1 1 = 0 2 2
0 0 1 0 0 1 0 0 1

29
Combining Translations, Rotations

Order matters!! TR is not the same as RT


(demo)
General form for rigid body transforms
We show rotation first, then translation
(commonly used to position objects) on
next slide. Slide after that works it out
the other way

30
Rotate then Translate

P '  (T R ) P  M P  R P  T

1 0 0 Tx   R11 R12 R13 0   R11 R12 R13 Tx 


     
 0 1 0 Ty   R21 R22 R23 0   R21 R22 R23 Ty   R T 
M   
0 0 1 Tz   R31 R32 R33 0   R31 R32 R33 
Tz  0 1 
     
0 0 0 1  0 0 0 1  0 0 0 1

31
Example Composite
Transforms

2D Case

32
Rotate clockwise 90
with respect to P

P(h,k) P(h,k)

If we only apply
Rotate(-90)
P(h,k)

33
Translate
(-h,-k)
P(h,k)

P’(0,0)

Rotate
(-90)
Translate
(h,k)

P(h,k)

34

 𝑃 =𝑇 (h , 𝑘 ) × 𝑅( −90) × 𝑇 ( −h , −𝑘 ) × 𝑃

𝐶𝑜𝑚𝑝𝑜𝑠𝑖𝑡𝑒
  𝑚𝑎𝑡𝑟𝑖𝑥 , 𝑀 =𝑇 (h , 𝑘) × 𝑅(− 90) × 𝑇 (−h ,− 𝑘)

1 0 h  cos( 90)  sin( 90) 0 1 0  h 


 0 1 k   sin( 90) cos( 90) 0 0 1  k 
0 0 1   0 0 1 0 0 1 

35

 𝑃 =𝑇 (h , 𝑘 ) × 𝑅( 𝜃) × 𝑇 ( −h ,− 𝑘) × 𝑃

𝐶𝑜𝑚𝑝𝑜𝑠𝑖𝑡𝑒
  𝑚𝑎𝑡𝑟𝑖𝑥 , 𝑀 =𝑇 (h , 𝑘) × 𝑅(𝜃 ) × 𝑇 (− h ,− 𝑘)

1 0 h  cos   sin  0  1 0  h 
 0 1 k   sin  cos  0 0 1  k 
0 0 1   0 0 1 0 0 1 

36
Suppose, a composite transformation is defined as rotating 90 degree counterclockwise
with respect to point (5, 5). Calculate the composite transformation matrix in homogenous
form. Then, find the new coordinates of the point (10, 10) after transformation.

𝐶𝑜𝑚𝑝𝑜𝑠𝑖𝑡𝑒
  𝑚𝑎𝑡𝑟𝑖𝑥 , 𝑀 =𝑇 (5,5) × 𝑅(90) × 𝑇 (−5 ,− 5)
1 0 5 cos 90  sin 90 0 1 0  5
 0 1 5  sin 90 cos 90 0 0 1  5
0 0 1  0 0 1 0 0 1 
1 0 5 0  1 0  1 0  5
 0 1 5 1 0 0 0 1  5
0 0 1 0 0 1 0 0 1 
0  1 10
 1 0 0 
0 0 1 
37
Suppose, a composite transformation is defined as rotating 90 degree counterclockwise
with respect to point (5, 5). Calculate the composite transformation matrix in homogenous
form. Then, find the new coordinates of the point (10, 10) after transformation.

 𝑃 ′=𝑀 × 𝑃

0  1 10 10
 1 0 0  10
0 0 1   1 
0
 10
 1 

So, the new coordinate of P is (0, 10)

38
Isotropic scale by
1.5 with respect to
P(h,k)
P(h,k) P(h,k)

If we only apply
Scale(1.5, 1.5)

P(h,k)

39
Translate
(-h,-k)
P(h,k)

P’(0,0)

Scale(1.5, 1.5)

Translate
(h,k)

P(h,k)

40

 𝑃 =𝑇 (h , 𝑘 ) × 𝑆(𝑎 ,𝑏) × 𝑇 ( −h , −𝑘 ) × 𝑃

𝐶𝑜𝑚𝑝𝑜𝑠𝑖𝑡𝑒
  𝑚𝑎𝑡𝑟𝑖𝑥 , 𝑀 =𝑇 (h , 𝑘) × 𝑆 (𝑎 , 𝑏) ×𝑇 (−h , −𝑘)

1 0 h   a 0 0  1 0  h 
 0 1 k   0 b 0 0 1  k 
0 0 1   0 0 1 0 0 1 

41
Suppose, a composite transformation is defined as scaling 2 times in both axis with
respect to point (5, 5). Calculate the composite transformation matrix in homogenous
form. Then, find the new coordinates of the point (10, 10) after transformation.

𝐶𝑜𝑚𝑝𝑜𝑠𝑖𝑡𝑒
  𝑚𝑎𝑡𝑟𝑖𝑥 , 𝑀 =𝑇 (5 ,5) × 𝑆(2 ,2) × 𝑇 (−5 ,− 5)

1 0 5 2 0 0 1 0  5
 0 1 5 0 2 0 0 1  5
0 0 1 0 0 1 0 0 1 
2 0  5
 0 2  5
0 0 1 

42
Suppose, a composite transformation is defined as scaling 2 times in both axis with
respect to point (5, 5). Calculate the composite transformation matrix in homogenous
form. Then, find the new coordinates of the point (10, 10) after transformation.

 𝑃 ′=𝑀 × 𝑃

2 0  5 10
 0 2  5 10
0 0 1   1 
15
 15
 1 

So, the new coordinate of P is (15, 15)

43
Reflection about line L, ML
Y Y Y
P(x,y)

Rotate(-θ)
Translate(0,-b)
(0,b)

t
O X O X O X

Reflect(x axis)

Y Y Y

Translate(0,b)
Rotate(θ)

(0,b)

t
O X O X O X

44
Reflection about line L, ML
Y

Step 1: Translate (0,b) to origin


Step 2: Rotate - degrees

Step 3: Mirror reflect about X-axis


(0,b)

t
O X
Step 4: Rotate  degrees
Step 5: Translate origin to (0,b)

ML = T(0 ,b) * R() * M x* R(-) * T(0 ,-b)


45
Reflect the point (10, 5) with respect to the line y=x+2.

−1
𝑏=2 , 𝑚=1 , 𝜃=tan 1=45
 

 𝑀 𝑐𝑜𝑚𝑝𝑜𝑠𝑖𝑡𝑒 =𝑇 (0 ,2) × 𝑅( 45) × 𝑅𝑒𝑓𝑙 (𝑥 𝑎𝑥𝑖𝑠) × 𝑅 (− 45) × 𝑇 ( 0 ,−2)

1 0 0 cos 45  sin 45 0 1 0 0 cos(45)  sin(45) 0 1 0 0 


 0 1 2  sin 45 cos 45 0 0  1 0  sin(45) cos(45) 0 0 1  2
0 0 1  0 0 1 0 0 1  0 0 1 0 0 1 
0 1  2
 1 0 2 
0 0 1 
0 1  2 10  3 
P '  1 0 2   5   12 New coordinate (3, 12)

0 0 1   1   1 
46

You might also like