2D Transformations
2D Transformations
2D Transformations
2D Transformations
What is transformations?
The geometrical changes of an object from a
current state to modified state.
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
Matrix Math
Why do we use matrix?
More convenient organization of data.
More efficient processing
Enable the combination of various
concatenations
c
d
a c
b d
Matrix Math
Matrix Multiplication
Dot product
a
c
b
d
e
g
f
= a.e + b.g
h
c.e + d.g
a.f + b.h
c.f + d.h
Translation
A translation moves all points
in an object along the same
straight-line path to new
positions.
The path is represented by a
vector, called the translation or
shift vector.
We can write the components:
p'x = px + tx
p'y = py + ty
or in matrix form:
P' = P + T
tx
x
x
y = y + ty
?
ty=4
(2, 2)
tx = 6
Rotation
A rotation repositions
all points in an object
along a circular path in
the plane centered at
the pivot point.
First, well assume the
pivot is at the origin.
Rotation
Review Trigonometry
P(x, y)
P(x,y)
x
Identity of Trigonometry
Rotation
P(x, y)
or in matrix form:
P' = R P
can be clockwise (-ve) or
counterclockwise (+ve as our
example).
Rotation matrix
cos
sin
sin
cos
P(x,y)
Rotation
Example
Find the transformed point, P, caused by
rotating P= (5, 1) about the origin through an
angle of 90.
cos
sin
sin
x x cos y sin
5 sin 90 1 cos 90
5 0 1 1
5 1 1 0
Scaling
0
s y
Scaling
P(2, 5)
Scaling
P(2, 5)
Scaling
If the scale factors are the same,
Sx = Sy uniform scaling
Only change in size (as previous
example)
If Sx Sy differential scaling.
Change in size and shape
Example : square rectangle
P(1, 3), Sx = 2, Sy = 5 , P ?
P(1, 2)