2D Geometric Transformations

Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

2D Geometric

2D Geometric
Transformations
Transformations
Basic Geometric
Transformations
Geometric transformations are used to transform the
objects and the camera in a scene (for animation or
modelling) and are also used to transform World
Coordinates to View Coordinates
Given the shape, transform all the points of the
shape? Transform the points and/or vectors
describing it.
For example:
Polygon: corner points
Circle, Ellipse: center point(s), point at angle 0
Some transformations preserves some of the
attributes like sizes, angles, ratios of the shape.
Translation
Simply move the object to a relative
position.
T P P
P T P
+ =
y'
x'
=
t
t
=
y
x
=
t + y = y' t + x = x'
y
x
y x
'
'

T
P
P'
Rotation
A rotation is defined by a rotation axis and a
rotation angle.
For 2D rotation, the parameters are rotation
angle () and the rotation point (x
r
,y
r
).
We reposition the object in a circular path
arround the rotation point (pivot point)

x
r
y
r
Rotation
When (x
r
,y
r
)=(0,0) we have
r
P
P'


cos sin sin cos ) sin(
sin sin cos cos ) cos(
r r r y
r r r x
+ = + = '
= + =
'

sin
cos
r y
r x
=
=
The original coordinates are:


cos sin
sin cos
y x y
y x x
+ =
'
=
'
Substituting them in the
first equation we get:
In the matrix form we have:
where
P R P =
'


=


cos sin
sin cos
R
Rotation
Rotation around an arbitrary point
(x
r
,y
r
)
This equations can be written as
matrix operations
r
P
P'


cos ) ( sin ) (
sin ) ( cos ) (
r r r
r r r
y y x x y y
y y x x x x
+ + =
'
+ =
'
(x
r
,y
r
)
Scaling
Change the size of an object. Input:
scaling factors (s
x
,s
y
)
P S P
S
'

=
s
s
=
ys = y' xs = x'
y
x
y x
0
0
P
P'
non-uniform vs.
uniform scaling
Homogenous Coordinates
All transformations can be represented by matrix
operations.
Translation is additive, rotation and scaling is
multiplicative (+ additive if you rotate around an
arbitrary point or scale around a fixed point);
making the operations complicated.
Adding another dimension to transformations make
translation also representable by multiplication.
Cartesian coordinates vs homogenous coordinates.

h
y h
x h
=
h
y
x
= P
h
y
= y
h
x
= x
h
h
h h
Many points in homogenous
coordinates can represent the same
point in Cartesian coordinates.
In homogenous coordinates, all
transformations can be written as
matrix multiplications.
Transformations in
Homogenous C.
Translation
Rotation
Scaling
( )
( ) P t , t T = P
t
t
= t , t T
y x
'
y
x
y x

1 0 0
1 0
0 1
( )
( ) P R = P


= R
'


1 0 0
0 cos sin
0 sin cos
( )
( ) P s , s S = P
s
s
= s , s S
y x
y
x
y x

'

1 0 0
0 0
0 0
Composite Transformations
Application of a sequence of
transformations to a point:
P M
P M M P
1 2
=
=
'
Composite Transformations
First: composition of similar type
transformations
If we apply to successive translations
to a point:
( ) ( ) ( )
y y x x y y
x x
y
x
y
x
y x y x
t + t , t + t T = t t
t t
= t
t
t
t
= t , t T t , t T
2 1 2 1 2 1
2 1
1
1
2
2
1 1 2 2
1 0 0
1 0
0 1
1 0 0
1 0
0 1
1 0 0
1 0
0 1

+
+

P T T
P T T P
=
=
'
)} , ( ) , ( {
} ) , ( { ) , (
1 1 2 2
1 1 2 2
y x y x
y x y x
t t t t
t t t t
( ) ( ) ( )
y y x x y y
x x
y
x
y
x
y x y x
s s , s s = s s
s s
= s
s
s
s
= s , s s , s
2 1 2 1 2 1
2 1
1
1
2
2
1 1 2 2
1 0 0
0 0
0 0
1 0 0
0 0
0 0
1 0 0
0 0
0 0

S S S
Composite Transformations
( ) ( )
( ) + = + +
+ +
= + +

=

=
R
R R

1 0 0
0 ) cos( ) sin(
0 ) sin( ) cos(
1 0 0
0 cos cos sin sin sin cos cos sin
0 cos sin sin cos sin sin cos cos
1 0 0
0 cos sin
0 sin cos
1 0 0
0 cos sin
0 sin cos


Composition of transformations
The transformation matrices of a series of transformations can be
concatenated into a single transformation matrix.
* Translate P
1
to origin
* Perform scaling and rotation
* Translate to P
2
Example:
Rotation around a pivot point
Translate the object so that the pivot
point moves to the origin
Rotate around origin
Translate the object so that the pivot
point is back to its original position
( ) ( ) ( )
( )
( )


1 0 0
sin cos 1 cos sin
sin cos 1 sin cos
1 0 0
1 0
0 1
1 0 0
0 cos sin
0 sin cos
1 0 0
1 0
0 1
x y
y + x
= y
x


y
x
= y , x y , x
r r
r r
r
r
r
r
r r r r
T R T
( )
r r
y , x T
( ) R
( )
r r
y , x T
Scaling with respect to a fixed
point
Translate to origin
Scale
Translate back
( ) ( ) ( )
( )
( )


1 0 0
1 0
1 0
1 0 0
1 0
0 1
1 0 0
0 0
0 0
1 0 0
1 0
0 1
y f y
x f x
f
f
y
x
f
f
f f y x f f
s y s
s x s
= y
x
s
s
y
x
= y , x s , s y , x T S T
( )
f f
y , x T
( )
y x
s , s S
( )
f f
y , x T
Order of matrix compositions
Matrix composition is not
commutative. So, be careful when
applying a sequence of
transformations.
pivot
same pivot
Other Transformations
Reflection

1 0 0
0 1 0
0 0 1

1 0 0
0 1 0
0 0 1

1 0 0
0 1 0
0 0 1
Shear: Deform the shape like shifted
slices.
(1,1)
(3,1)
(2,1)
x ' x sh
x
y y ' y
1 sh
x
0
0 1 0
0 0 1
(0,1)
Affine Transformations
Involve translation, rotation, scale, and shear
Preserve parallelism of lines but not lengths and angles
Affine Transformations
Under certain assumptions, could be used to
approximate the effects of perspective projection!
affine transformed object

You might also like