Professional Documents
Culture Documents
Chapter 3
Chapter 3
• Affine Transformation:
– Known as line preserving transformations
– That means after performing transformation on
any object, structure of the object doesn’t
change.
– Also called Solid Body Transformation
2D Transformations
y
x
x y
x
Dr. M Zahidul Islam 4
2D Transformations
• 2 ways
– Object Transformation
• Alter the coordinates descriptions an object
• Translation, rotation, scaling etc.
• Coordinate system unchanged
– Coordinate transformation
• Produce a different coordinate system
a c a± c
± = b± d
b d
• Matrix Multiplication
– Dot product
a b e f
. = a.e + b.g a.f + b.h
c d g h c.e + d.g c.f + d.h
2 1 2
3
. 3 1 = !!
• Type of matrix
a b a
b
Row-vector Column-vector
Dr. M Zahidul Islam 10
Matrix Math
• Is there a difference between possible
representations?
⎡ a b ⎤ ⎡ e ⎤ ⎡ ae + bf ⎤
⎢ ⎥∙ ⎢ ⎥ =⎢ + ⎥
⎣ c d ⎦ ⎣ f ⎦ ⎣ ce d ⎦
f
⎡a b⎤
[e f ]∙ ⎢ ⎥ = [ae + cf be + d ]
⎣c d⎦ f
⎡a c⎤
[e f ]∙ ⎢ ⎥ = [ae + bf ce + d ]
⎣b d ⎦ f
0
1 2 3 4 5 6 7 8 9 10
X
OR P’ = P + T where P’ = x’ p= x T= tx
y’ y ty
x’ x tx
y’ = y + ty
Dr. M Zahidul Islam 17
2D Rotation
• Rotation must be done about a point.
• Amount of rotation is denoted by Ө .
• Rotation through an angle Ө we get :
[P’ ]= [R] [P ]
where ,
and
x’ = x cos Ө – y sin Ө
y’ = x sin Ө + y cos Ө
• So,the rotation matrix is :
• Types of rotation:
– Positive Rotation: Counter clockwise about the origin.
– Negative Rotation: Clockwise about the origin.
2D Rotation
• Default rotation center: Origin (0,0)
5 Note: House
shifts position
4 relative to
3 origin
0
1 2 3 4 5 6 7 8 9 10
X
0
1 2 3 4 5 6 7 8 9 10
X
We know, [P’ ] = [S] [P] where
and
x’ = x . Sx x’ Sx 0 x
=
y’ = y . Sy y’ 0 Sy y
(4,4)
(2,2) Sx = 2, Sy = 2
(2,2)
(1,1)
Dr. M Zahidul Islam 29
2D Scaling
(4,4)
(2,2) Sx = 2, Sy = 2
(2,2)
(1,1)
x’ Sx 0 x
=
y’ 0 Sy y
x’ Sx 0 0 x
y’ = 0 Sy 0 * y
1 0 0 1 1
P’
sx = -1 sy = 1
original
sx = 1 sy = -1
2D Shearing
• Shearing: whenever we give force on any object ,it tries to bend
on the direction of the force. This is known as shearing.
• Useful for forming general affine transformation.
• Shear normally soft objects.
• Conditions:
– a=d=1 : that means Diagonal elements will be 1
– (c=0 and b=2) or (c=2 and b=0): any of the off diagonal
element will be 0 here.
– So equations for the transformed coordinates will be-
or
0
Figure: 1
y
2 3 4 5 6
y
7 8 9 10
X
Shearing
using (1,1)
(0,1) (2,1) (3,1)
y y
Figure:
Shearing (0,3/2) (1,2)
• Scaling: x’ Sx 0 x
= *
y’ 0 Sy y
It’d be nicer if we could use the same matrix operation all the
time. But we’d have to combine multiplication and addition
into a single operation.
• The fact that all the points along each line can be mapped
back to the same point in 2D gives this coordinate system its
name – homogeneous coordinates.
• Scaling
• Composite transformations:
– Rotate about an arbitrary point – translate, rotate,
translate
– Scale about an arbitrary point – translate, scale,
translate
– Change coordinate systems – translate, rotate, scale
• Example
– Perform 60° rotation of a point P(2, 5) about a
pivot point (1,2). Find P’?
cosθ -sinθ -tx cosθ+ ty sinθ + tx x Sin 60 = 0.8660
sinθ cosθ -tx sinθ - ty cosθ + ty . y
Kos 60 = 1/2
0 0 1 1
1 0 tx Sx 0 -tx Sx
Sx 0 -tx Sx + tx
0 1 ty 0 Sy -ty Sy
= 0 Sy -ty Sy + ty
0 0 1 . 0 0 1
0 0 1
x =6, y = 8, Sx = 2, Sy = 3, tx =2, ty = 2
2 0 -2( 2) + 2 6 10
0 3 -2(3) + 2
. 8 = 20
0 0 1 1 1
Sx 0 0 cosθ -sinθ tx
0 Sy 0 sinθ cosθ ty
0 0 1 . 0 0 1
Sxcosθ Sx(-sinθ) Sx tx
Sy sinθ Sy cosθ Sy ty
0 0 1
x-axis y-axis
x-direction y-direction