0% found this document useful (0 votes)
53 views33 pages

Section - III: Transformations in 2-D in 2-D

This document discusses 2D transformations and their representation using matrices. It begins by introducing the general problem of applying a transformation T to points represented by a matrix A to obtain transformed points in matrix B. Several types of 2D transformations are then described in detail, including scaling, reflections, rotations, shears, and translations. Homogeneous coordinates are introduced to represent translations using matrices. The concept of composite transformations is explained, noting that multiple transformations can be applied either sequentially or by computing their product. The document concludes by discussing rotating and scaling about arbitrary points through a sequence of translations and the specified transformation.

Uploaded by

Imblnr
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views33 pages

Section - III: Transformations in 2-D in 2-D

This document discusses 2D transformations and their representation using matrices. It begins by introducing the general problem of applying a transformation T to points represented by a matrix A to obtain transformed points in matrix B. Several types of 2D transformations are then described in detail, including scaling, reflections, rotations, shears, and translations. Homogeneous coordinates are introduced to represent translations using matrices. The concept of composite transformations is explained, noting that multiple transformations can be applied either sequentially or by computing their product. The document concludes by discussing rotating and scaling about arbitrary points through a sequence of translations and the specified transformation.

Uploaded by

Imblnr
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

Sec t i on I I I :

TRANSFORMATI ONS
i n 2-D i n 2-D
2D TRANSFORMATI ONS AND MATRI CES
Representation of Points:
2D TRANSFORMATI ONS AND MATRI CES
Representation of Points:
2 x 1 matrix:
(
(

X
(

Y
General Problem: [B] = [T] [A]
[T] represents a generic operator to
be applied to the points in A. T is the pp p
geometric transformation matrix.
If A & T are known, the transformed
points are obtained by calculating B points are obtained by calculating B.
General Transformation of 2D points:
x c a x
(
(

(
(

=
(
(

'
b a x x
T T
(
(

(
(

(
(

'
y d b y
(

=
(


'
d c y y
(

=
(


'
cy ax x + = ' cy ax x + = '
dy bx y + = '
dy bx y + = '
Solid body transformations the above Solid body transformations the above
equation is valid for all set of points and lines of
the object being transformed. j g
Spec i al c ases of 2D Tr ansf or mat i ons:
1) T = identity matrix:
p
a=d=1, b=c=0 => x'=x, y'=y
2) Scaling & Reflections: 2) Scaling & Reflections:
b=0, c=0 => x' = a.x, y' = d.y;
This is scaling by a in x d in y This is scaling by a in x, d in y.
If, a = d > 1, we have enlargement; , , g ;
If, 0 < a = d < 1, we have compression;
(
S 0
If a = d, we have uniform scaling,
else non-uniform scaling.
(

x
S
S
0
0
Scale matrix: let S
x
= a, S
y
= d:

y
S 0
Scale matrix: let S
x
a, S
y
d:
Y
Ex ampl e
6
5
p
of Sc al i ng
4
3
(
2
(
3
(

2
9
S
x
= 3
2
1
(

1
2
(

1
3
(

2
6

2
S
x
3
S
y
= 2
0
1 2 3 4 5 6 7 8 9
X
(

2
What if S
x
and/ or S
y
< 0 (are negative)?
Get reflections through an axis or plane Get reflections through an axis or plane.
Only diagonal terms are involved in scaling and Only diagonal terms are involved in scaling and
reflections.
N t H hift iti l ti t i i Note : House shifts position relative to origin
Mor e ex ampl es of Sc al i ng and r ef l ec t i on p g
Reflection
(about the Y-axis) ( )
x= x
x
Non-uniform scaling
u
xx
x= x + ay
Spec i al c ases of Ref l ec t i ons (|T| = -1)
Matrix T Reflection about Matrix T Reflection about
(
0 1
Y=0 Axis (or X-axis)
(

1 0
0 1
X=0 Axis (or Y-axis)
(

1 0
0 1
Y X A i

1 0
(
(

1 0
Y = X Axis
(

0 1
(
Y = -X Axis
(


0 1
1 0

Off diagonal terms are involved g
in SHEARING;
x x c a
( ( (
'
a = d = 1;
y y d b
(

=
(

'
let, c = 0, b = 2
cy ax x
y y
+ =

'
x' = x
y' = 2x + y ;
dy bx y + = '
y' depends linearly on x ; This effect is called
h shear.
Similarly for b=0, c not equal to zero. The Similarly for b=0, c not equal to zero. The
shear in this case is proportional to y-coordinate.
ROTATI ON Y
5
u 30
sin cos ' y x X =
4
3
u = 30
cos sin ' y x Y
y
+ =
In matrix form, this is :
3
2
(
(

=
) sin( - ) cos(
T
0
1
u
(

) cos( ) sin(
T
0
1
2
3
4
5
X
Positive Rotations: counter clockwise about
the origin the origin
For rotations, |T| = 1 and [T]
T
= [T]
-1
.
Rotation matrices are orthogonal.
Spec i al c ases of Rot at i ons
u (in degrees)
Matrix T
u (in degrees)
Matrix T
(
1 0
90
(

0 1
1 0
180

(

1 0
0 1
(

1 0
(
1 0
270 or -90
(

0 1
360 or 0
(

1 0
0 1

1 0
Example - Transformation of a Unit Square
YY
b+d
Y
d
(1, 1)
x
b
c
a
a+c
c
a
a+c
x
(
(

0 0
(
(

0 0
(
(
(
(

=
1 1
0 1
S
(
(
(

+ +
=
(

=
d b c a
b a
d c
b a
S S'
(
(

1 0
1 1
(
(

+ +

d c
d b c a d c
Area of the unit square after transformation
= ad - bc = |T|. ad bc |T|.
Extend this idea for any arbitrary area.
Tr ansl at i ons Tr ansl at i ons
Y
6
55
4
3
(

2
2
t
x
= 5
t 1
3
2
1
(

2
(

3
7
t
y
= 1
0
1
1 2 3 4 5 6 7 8 9
X

1 2 3 4 5 6 7 8 9
Tr ansl at i ons
B = A + T
d
, where T
d
= [t
x
t
y
]
T
Wher e el se ar e t r ansl at i ons i nt r oduc ed?
1) Rotations - when objects are not centered
at the origin.
2) Scaling - when objects/lines are not
t d t th i i if li i t t th
g
centered at the origin - if line intersects the
origin, no translation.
Origin is invariant to Scaling, reflection
and Shear not translation.
Note: we cannot directly represent translations
as matrix multiplication, as we can for:
SCALING
ROTATION
SCALING
ROTATION
Can we represent translations in our
general transformation matrix?
Yes, by using homogeneous coordinates
HOMOGENEOUS COORDI NATES
( ( (
x t c a x'
(
(
(

(
(
(

=
(
(
(

y
x
t d b
t c a
y
x
y
x
* '
Use a 3 x 3 matrix:
(
(

(
(

(
(

w
y
w
y
y
1 0 0 '
We have:

We have:
x' = ax + cy + t
x
y' = bx + cy + t y = bx + cy + t
y
Each point is now represented by a triplet: Each point is now represented by a triplet:
(x, y, w).
(x/w, y/w) are called the Cartesian
coordinates of the homogeneous points. coordinates of the homogeneous points.
I nt er pr et at i on of
W
Homogeneous Coor di nat es
W
P
h
(x, y, w)
1
P ( / / 1) P
2d
(x/w, y/w, 1)
x
YY
Two homogeneous coordinates (x y w ) Two homogeneous coordinates (x
1
, y
1
, w
1
)
& (x
2
, y
2
, w
2
) may represent the same point,
iff they are multiples of one another: iff they are multiples of one another:
say, (1,2,3) & (3,6,9).
There is no unique homogeneous
representation of a point. representation of a point.
All triples of the form (t.x, t.y, t.W) form a
line in x,y,W space.
Cartesian coordinates are just the plane Cartesian coordinates are just the plane
w=1 in this space.
W=0, are the points at infinity
General Purpose 2D transformations in
homogeneous coordinate representation homogeneous coordinate representation
(
p b a
(
(
(

= q d c
p b a
T
(
(

s n m
q d c T

Parameters involved in scaling, rotation,
reflection and shear are: a, b, c, d
If B = T A then
If B = A T then
If B = T.A, then
Translation
If B = A.T, then
Translation
Translation
parameters:
(p q)
Translation
parameters:
(m, n)
What about
(p, q)
(m, n)
S ?
COMPOSI TE TRANSFORMATI ONS
If we want to apply a series of
transformations T
1
T
2
T
3
to a set of points transformations T
1
, T
2
, T
3
to a set of points,
We can do it in two ways:
1) We can calculate p'=T
1
*p, p''= T
2
*p',
p'''=T
3
*p'' p T
3
p
2) Calculate T= T
1
*T
2
*T
3
, then p'''= T*p.
Method 2, saves large number of additions
and multiplications (computational time) p ( p )
needs approximately 1/3 of as many operations.
Therefore, we concatenate or compose the , p
matrices into one final transformation matrix,
and then apply that to the points.
Translations: (
+ ) ( 0 1 tx tx
Translations:
Translate the points
by tx ty then by tx ty :
(
(
(

+
+
) ( 1 0
) ( 0 1
2 1
2 1
ty ty
tx tx
by tx
1
, ty
1
, then by tx
2
, ty
2
:
S li
(
(

1 0 0
) (
2 1
y y
Scaling:
Similar to translations

Rotations:
Rotate by u then by u : Rotate by u
1
, then by u
2
:
(i) stick the (u
1
+ u
2
) in for u, or
(ii) l l t T f u th T f u & (ii) calculate T
1
for u
1
, then T
2
for u
2
&
multiply them.
Exercise: Both gives the same result work
it out it out
Rot at i on about an ar bi t r ar yy
poi nt P i n spac e
As we mentioned before, rotations are
applied about the origin. So to rotate about pp g
any arbitrary point P in space, translate so
that P coincides with the origin, then rotate, g , ,
then translate back. Steps are:
Translate by (-P
x
, -P
y
)
y
Rotate
Translate by (P , P ) Translate by (P
x
, P
y
)
Rot at i on about an ar bi t r ar y
poi nt P i n spac e
P
1
u
House at P
1
Rotation by u
P
1
Translation of
P to Origin
Translation
b k P
P
1
to Origin
back to P
1
Rot at i on about an ar bi t r ar y Rot at i on about an ar bi t r ar y
poi nt P i n spac e
T = T
1
(-P -P ) * T
2
(u) * T
3
(P P ) T = T
1
( P
x
, P
y
) T
2
(u) T
3
(P
x
, P
y
)
Sc al i ng about an ar bi t r ar y poi nt i n Spac e
Again,
g y p p
Translate P to the origin
S l Scale
T l t P b k Translate P back
T = T
1
(P
x
, P
y
)* T
2
(S
x
, S
y
)*T
3
(-P
x
, -P
y
)
(
)} 1 ( * { 0
x
S
x
P
S
1
(
x
,
y
)
2
(
x
,
y
)
3
(
x
,
y
)
(
(
(

= )} 1 ( * { 0
)} 1 ( { 0
y
S
y
P
Sy
x
S
x
P
x
S
T
(

1 0 0
)} 1 ( { 0
y
S
y
P
Sy
T

Reflection through an arbitrary line g y
Steps:
Translate line to the origin Translate line to the origin
Rotation about the origin Rotation about the origin
Reflection matrix Reflection matrix
Reverse the rotation
Translate line back
1 T
T R T R T T
r rfl r GenRfl
T R T R T T
Commut i vi t y of Tr ansf or mat i ons
If we scale, then translate to the origin,
and then translate back, is that equivalent to and then translate back, is that equivalent to
translate to origin, scale, translate back?
When is the order of matrix
multiplication unimportant?
Cases where T * T = T * T :
When does T
1
* T
2
= T
2
* T
1
?
Cases where T
1
* T
2
= T
2
* T
1
:
T
1
T
2 1 2
translation translation
scale scale scale scale
rotation rotation
scale(uniform) rotation
Order:
R- G- B R- G- B
Scale translate
T l l
Scale, translate
Translate, scale
Rotate, differential
Differential scale,
,
scale
rotate
COORDI NATE SYSTEMS
Screen Coordinates: The coordinate system Screen Coordinates: The coordinate system
used to address the screen (device coordinates)
World Coordinates: A user-defined application
specific coordinate system having its own specific coordinate system having its own
units of measure, axis, origin, etc.
Window: The rectangular region of the world
that is visible.
Viewport: The rectangular region of the screen
space that is used to display the window. space that is used to display the window.
Window
Y
Viewport2
Window
Y
V
Vi t1 Viewport1
X
U
World
Screen
WI NDOW TO VI EWPORT
TRANSFORMATI ON
Purpose is to find the transformation matrix
that maps the window in world coordinates to p
the viewport in screen coordinates.
Window: (x, y space) denoted by:
x
min
, y
min
, x
max
, y
max min
, y
min
,
max
, y
max
Viewport: (u v space) denoted by: Viewport: (u, v space) denoted by:
u
min
, v
min
, u
max
, v
max
The overall transformation:
Translate the window to the origin
Scale it to the size of the viewport
Translate it to the viewport location
=
) /( ) (
); , ( * ) , ( * ) , (
min min min min
U U S
y x T S S S V U T M
y x WV
=
=
); /( ) (
); /( ) (
min max min max
min max min max
y y V V S
x x U U S
y
x
(
(

+ ) * ( 0
); /( ) (
min min
min max min max
U S x S
y y V V S
x x
y
(
(
(

+ =
1 0 0
) * ( 0
min min
V S y S M
y y WV
(

1 0 0
Y
Wi ndow Vi ew por t Tr ansf or mat i on
(X
max
, Y
max
) Y
Y
(X
min
, Y
min
)
Window in World
(
min
,
min
)
X
Window translated
X
Coordinates
to origin
V
V
V
Maximum
Screen
Coordinates
(U
min
, V
min
)
Window Scaled to
U
U
Viewport Translated
size to Viewport
e po t a s ated
to final position
Exer c i se -Tr ansf or mat i ons of Par al l el Li nes
Consider two parallel lines:
(i) A[X Y ] to B[X Y ] and (i) A[X
1
, Y
1
] to B[X
2
, Y
2
] and
(ii) C[X
3
, Y
3
] to B[X
4
, Y
4
].
Slope of
the lines:
3 4 1 2
X X
Y Y
X X
Y Y
m

=

=
3 4 1 2
X X X X
Solve the problem:
(
b
Solve the problem:
If the lines are
transformed by a matrix:
(

=
d c
b a
T
transformed by a matrix:
d b

d c
The slope of the
dm b
m'
The slope of the
transformed lines is:
cm a

You might also like