Modeling Transformation
Modeling 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?
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
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
13
Homogeneous Coordinates
• Add an extra dimension
• in 2D, we use 3 x 3 matrices
• In 3D, we use 4 x 4 matrices
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
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
(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)
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
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)
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
29
Combining Translations, Rotations
30
Rotate then Translate
P ' (T R ) P M P R P T
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 ,− 𝑘)
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
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
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
t
O X
Step 4: Rotate degrees
Step 5: Translate origin to (0,b)
−1
𝑏=2 , 𝑚=1 , 𝜃=tan 1=45
0 0 1 1 1
46