[go: up one dir, main page]

0% found this document useful (0 votes)
66 views44 pages

Graphics 06 Transformation I and II SC

The document discusses 2D geometric transformations including translation, scaling, and rotation. Translation moves all points in an object by a constant amount in the x and y directions. Scaling resizes an object by multiplying the x and y coordinates of points by scale factors. Rotation repositions points along a circular path centered at the origin by a specified angle. These transformations can be represented using transformation matrices and applied using matrix multiplication in homogeneous coordinates.

Uploaded by

Developers torch
Copyright
© © All Rights Reserved
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)
66 views44 pages

Graphics 06 Transformation I and II SC

The document discusses 2D geometric transformations including translation, scaling, and rotation. Translation moves all points in an object by a constant amount in the x and y directions. Scaling resizes an object by multiplying the x and y coordinates of points by scale factors. Rotation repositions points along a circular path centered at the origin by a specified angle. These transformations can be represented using transformation matrices and applied using matrix multiplication in homogeneous coordinates.

Uploaded by

Developers torch
Copyright
© © All Rights Reserved
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/ 44

CSE- 4105

Transformation
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 Geometric Transformation
Modeling
Coordinates

World Coordinates
2D Translation

x  x  t x , y   y  t y
y
P
 x  x  t x 
P    , P    , T   
T
 y  y t y 
P x P  P  T

8/7/2017 4
2D Scaling

Sx

Sy

x  x  s x , y   y  s y

 x   s x 0   x
 y   0   
   sy   y 

8/7/2017 P  S  P 5
2D Rotation
• Rotate counter-clockwise about the origin by
an angle   x   cos  sin    x 
 y   sin    
cos   y 
  
y y


x x

P’ = R . P
8/7/2017 6
Transformations
• Transform every point on an object according
to certain rule. Q (x’, y’)

P (x,y) T

Initial Object

Transformed Object

x x’ The point Q is the image of P under the tra


y y’ nsformation T.
Whyonce
• In graphics, Transformations?
we have an object described,
transformations are used to move that object,
scale it and rotate it
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
Transformations
• Transformations modify an object’s shape and
location in one coordinate system
(2,3) x’=x-1
y y’=y-1 y (1,2)

x=x’+1
x y=y’+1 x
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.

(8,6)

dy=4

(2, 2) dx= 6
Translation

• Represent in in matrix
dy=4

• dx= 6
(2, 2)


Translation
• Translation
y

P’(x’, y’)

dy P(x, y)

x
dx
Translations
(55,60)

(20,35)

(45,30)
(65,30)

(10,5) (30,5)

The vector (dx, dy) is called the offset vector.


Scaling
• Resizes an object in each dimension to altering the size of an object.
• Scaling changes the size of an object and involves two scale factors, Sx
and Sy for the x- and y- coordinates respectively.
• If Sx = Sy then uniform scaling then

x  xS x P’

y  yS y

P
Scaling
• Represent in in matrix

y

P1(x1, y1)
y1

y0
1y P0(x0, y0)
1
2
1y
2
0
x
1x 1x x1 x0
1 0
2 2
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’ ?
Scaling
• If the scale factors are larger than 1
• the points will be moved away from P’
the origin
• the object will be larger.

• Example :
P(2, 5)
– P(2, 5), Sx = 2, Sy = 2
– Find P’ ? P’

Scaling
If the scale factors are larger than 1
• the points will be moved away from P’
the origin
• the object will be larger.
• Example :
– P(2, 5), Sx = 2, Sy = 2 P(2, 5)

– Find P’ ?
P’

• If the scale factors are the same,


Sx = Sy uniform scaling
• Only change in size
Scaling
• If Sx  Sy ,differential P’
scaling.
• Change in size and shape
• Example : square 
rectangle
P(1, 2)
– P(1, 3), Sx = 2, Sy = 5 , P’ ?
Rotation
• A rotation repositions all points
in an object along a circular path
in the plane centered at the
pivot point.
P’
• First, we’ll assume the pivot is at
the origin. 

P
Rotation
• Rotate through an abgle  about the origin

y
P’(x’, y’)

P(x, y)


• x
Rotation
• Derivation of the rotation equation
y
P’(x’, y’)
rsin(+)

P(x, y)
rsin
r


x
rcos(+) rcos
Rotation

• Rewriting in matrix form gives us :


Rotation
• Example
– Find the transformed point, P’, caused by
rotating P= (5, 1) about the origin through an
angle of 90.
cos  sin    x   x  cos  y  sin  
 sin   
 cos   y   x  sin   y  cos 

5  cos90  1 sin 90 
 
5  sin 90  1 cos 90

5  0  1 1
 
5 1  1  0
 1
 
5
Transformations.
• Translation.
P=T + P
• Scale
P=S  P
• Rotation
P=R  P
• We would like all transformations to be
multiplications
Basic Transformations

• Translation: Rotation:
1 0 t x  cos  sin  0
0 1 t   sin 
 y cos 0
 
0 0 1   0 0 1
• Scaling:  sx 0 0
0 sy 0
 
 0 0 1
Homogenous Coordinates
• A point (x, y) can be re-written in homogeneous
coordinates as (xh, yh, h)
• The homogeneous parameter h is a non-
zero value such that:

• We can then write any point (x, y) as (hx, hy, h)


• We can conveniently choose h = 1 so that
(x, y) becomes (x, y, 1)
Homogenous Coordinates
• Mathematicians commonly use homogeneous
coordinates as they allow scaling factors to be
removed from equations
• We will see in a moment that all of the
transformations we discussed previously can be
represented as 3*3 matrices
• Using homogeneous coordinates allows us use matrix
multiplication to calculate transformations –
extremely efficient!
Translation
Scaling
Rotation
At a glance…

• Translation:

• Scaling

• Rotation
Inverse Transformations
• Transformations can easily be reversed using
inverse transformations
1 0  dx
1   1 
T  0 1  dy s 0 0
0 0 1   x 
1 
S 1   0 0
 cos sin  0  sy 
  0 0 1
R   sin  cos 0
1
 
 
 0 0 1
Combining Transformations
• A number of transformations can be combined into
one matrix to make things easy
– Allowed by the fact that we use homogenous
coordinates
• Imagine rotating a polygon around a point other than
the origin
– Transform to centre point to origin
– Rotate around origin
– Transform back to centre point
Rotating About An Arbitrary Point
y y

x x

y y

x x
Combining Transformations (cont…)
• The three transformation matrices are
combined as follows
1 0  dx cos  sin  0 1 0 dx  x 
0 1  dy   sin  cos 0  0 1 dy   y 
       
0 0 1   0 0 1 0 0 1  1 
v'  T (dx,dy) R( )T (dx, dy)v
REMEMBER: Matrix multiplication is not commutative s
o order matters
Summary
• 2D Transformations
• Translation
• Scaling
• Rotation
– Homogeneous coordinates
– Matrix multiplications
– Combining transformations
3D Translation
• Repositioning an object along a straight line path from one co-ordinate
location to another
(x,y,z) (x’,y’,z’)
• To translate a 3D position, we add translation distances tx ty and tz to the
original coordinates (x,y,z) to obtain the new coordinate position
(x’,y’,z’)
x’= x + tx , y’= y + ty , z’= z + tz

Matrix form (4 × 4) y

 x   1 0 0 tx   x 
 y    0 1 0 ty   y 
T(tx, ty, tz)
 z   0 0 1 tz   z 
 1  0 0 1   1  x
   0

P  T (t x , t y , t z ) P z
3D Rotation
• z-axis
– The 2D z-axis rotation equations are extended to 3D.

x  x cos   y sin 
y  x sin   y cos  y
z  z
Matrix form
x
 x   cos   sin  0 0 x  z
 y    sin  cos  0 0 y 
 z   0 0 1 0 z 
1  0 1   1 
   0 0

P  Rz ( ) P
3D Rotation
y
• x-axis y  y cos   z sin 
z   y sin   z cos 
x  x
x

z
Matrix form

 x   1 0 0 0 x 
 y    0 cos   sin  0 y 
 z    0 sin  cos  0 z 
 1  0 1   1 
   0 0

P  Rx ( ) P
3D Rotation
y
• y-axis z  z sin   x cos 
x  z sin   x cos 
y  y
x

z
Matrix form

 x   cos  0 sin  0 x 


 y    0 1 0 0 y 
 z     sin  0 cos  0 z 
1  0 1   1 
   0 0

P  Ry ( ) P
3D Scaling
x  xsx y
y  ys y
z  zsz
x

Matrix form z

 x   s x 0 0 0  x 
    
y  0 sy 0 0  y 
 z   0 0 sz 0  z 
    
1 0 0 0 1  1 

P  S ( s x , s y , s z ) P
Reference
• Chapter 5 of your textbook.

You might also like