Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

2D Transformations

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 15
At a glance
Powered by AI
The key takeaways are that there are different types of 2D transformations including translation, rotation, and scaling. These transformations can be represented using matrix math to manipulate object coordinates.

The different types of 2D transformations discussed are translation, rotation, and scaling. Translation moves all points along a straight path. Rotation repositions points along a circular path. Scaling changes the size of objects.

A rotation transformation is defined by rotating each point around a pivot point. The new x-coordinate is calculated as the original x multiplied by the cosine of the angle minus the original y multiplied by the sine of the angle. The new y-coordinate is the original x multiplied by the sine of the angle plus the original y multiplied by the cosine of the angle.

2D& 3D TRANSFORMATIONS

2D Transformations
What is transformations?
The geometrical changes of an object from a
current state to modified state.

Why the transformations is needed?


To manipulate the initially created object and to
display the modified object without having to
redraw it.

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

Matrix addition and subtraction


a
b

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

=> cos = x/r , sin = y/r


x = r. cos , y = r.sin
=> cos (+ ) = x/r
x = r. cos (+ )
x = r.coscos -r.sinsin
x = x.cos y.sin
=>sin (+ ) = y/r
y = r. sin (+ )
y = r.cossin + r.sincos
y = x.sin + y.cos

P(x, y)

P(x,y)

x
Identity of Trigonometry

Rotation

We can write the components:


p'x = px cos py sin
p'y = px sin + py cos

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

cos y x sin y cos


5 cos 90 1 sin 90

5 sin 90 1 cos 90

5 0 1 1

5 1 1 0

Scaling

Scaling changes the size of an


object and involves two scale
factors, Sx and Sy for the xand y- coordinates
respectively.
Scales are about the origin.
We can write the components:
p'x = sx px
p'y = sy py
or in matrix form:
P' = S P
Scale matrix as:
sx
S
0

0
s y

Scaling

If the scale factors are in between 0


and 1 the points will be moved
closer to the origin the object
will be smaller.
Example :
P(2, 5), Sx = 0.5, Sy = 0.5
Find P ?

P(2, 5)

Scaling

If the scale factors are in between 0


and 1 the points will be moved
closer to the origin the object
will be smaller.
Example :
P(2, 5), Sx = 0.5, Sy = 0.5
Find P ?
If the scale factors are larger than 1
the points will be moved away
from the origin the object will be
larger.
Example :
P(2, 5), Sx = 2, Sy = 2
Find P ?

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)

What does scaling by 1 do?


What is that matrix called?
What does scaling by a negative value do?

Concatentation - Combining transformations

You might also like