0% found this document useful (0 votes)
818 views26 pages

2D & 3D Transformations

The document discusses various geometric transformations used in computer graphics, including translation, rotation, scaling, and reflections in 2D and 3D spaces. It introduces key concepts like world coordinate systems, object coordinate systems, and homogeneous coordinates. The key types of 2D transformations covered are translation using shift vectors, rotation by specifying an angle of rotation, and scaling using x and y scale factors. It also discusses specifying composite transformations using transformation matrices and calculating inverse transformations.

Uploaded by

aru
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
818 views26 pages

2D & 3D Transformations

The document discusses various geometric transformations used in computer graphics, including translation, rotation, scaling, and reflections in 2D and 3D spaces. It introduces key concepts like world coordinate systems, object coordinate systems, and homogeneous coordinates. The key types of 2D transformations covered are translation using shift vectors, rotation by specifying an angle of rotation, and scaling using x and y scale factors. It also discusses specifying composite transformations using transformation matrices and calculating inverse transformations.

Uploaded by

aru
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 26

Geometric Transformations for

Computer Graphics

Presentation by
R.Sakthivel Murugan,
AP/Mech,
KCET.
Coordinate Systems
• World Coordinate System
• Object Coordinate System
• Hierarchical Coordinate Systems
• Viewpoint Coordinate System
• Model Window Coordinate System
• Screen Coordinate System
• Viewport Coordinate System
World Coordinate System
• Also known as the "universe" or sometimes
"model" coordinate system.
• This is the base reference system for the overall
model, ( generally in 3D ), to which all other
model coordinates relate.

Object Coordinate System


• When each object is created in a modelling
program, the modeler must pick some point to
be the origin of that particular object, and the
orientation of the object to a set of model axes.
Hierarchical Coordinate Systems
• Objects in a scene are arranged in a hierarchy, so
that the "position" of one object in the hierarchy is
relative to its parent in the hierarchy scheme,
rather than to the world coordinate system.

View point Coordinate Systems


• This coordinate system is based upon the
viewpoint of the observer, and changes as
they change their view.
Model Window Coordinate System
• Coordinate system refers to the subset of the overall
model world that is to be displayed on the screen

Screen Coordinate System


• 2D coordinate system refers to the physical coordinates
of the pixels on the computer screen, based on current
screen resolution. ( E.g. 1024x768 )

Viewport Coordinate System


• Coordinate system refers to a subset of the screen space
where the model window is to be displayed.
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.
Types of 2D Transformations
• Translation
• Rotations
• Scaling
• Reflections
2D Translation
(x’,y’)

(tx,ty)

(x,y)

• 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.
2D Translation
P  ( x, y )
T  (t x , t y )
?
P'  ( x' , y ' )
x'  x  t x
ty =4 y'  y  t y
By Matrix Form,
tx = 6  x '   x  t x 
 y '   y   t 
(2, 2)

     y
P'  P  T
T  TransformationMatrix
2D Rotation
P’

• A rotation repositions all points in an object along a


circular path in the plane centered at the pivot point.
• First, we’ll assume the pivot is at the origin.
2D Rotation
Review Trigonometry
=> cos  = x/r ,
sin = y/r
P’(x’, y’)
x = r. cos , y = r.sin 
=> cos (+ ) = x’/r 
•x’ = r. cos (+ ) r
y’ P(x,y)
•x’ = r.coscos -r.sinsin
•x’ = x.cos  – y.sin   r
y

=>sin (+ ) = y’/r x
x’
y’ = r. sin (+ )
•y’ = r.cossin + r.sincos
•y’ = x.sin  + y.cos 
2D Rotation
x'  r cos  cos   r sin  sin 
y '  r cos  sin   r sin  cos 
x'  x cos   y sin 
y '  x sin   y cos 
By Matrix Form,

 x' cos   sin    x 


 y '   sin  cos    y 
    
P'  R  P
R  RotationMatrix
Scaling
P’

• Scaling changes the size of an object and


involves two scale factors, Sx and Sy for the x-
and y- coordinates respectively.
• Scales are about the origin.
Scaling
P  ( x, y )
Sx S  (s x , s y )

Sy
x'  s x x
y'  s y y
y

 x'  s x 0  x
 y '   0 s y   y 
  
x , yf 
P'  S  P
f
x
S-> Scale factor
2D Reflections
y y y

x x

Reflection about X axis Reflection about Y axis Reflection about X & Y axis

P  ( x, y ) P  ( x, y ) P  ( x, y )
P '  ( x' , y ' )  [ X ,Y ] P'  ( x' , y ' )  [ X , Y ] P '  ( x' , y ' )  [ X ,Y ]

1 0   x    1 0  x   1 0   x 
P'     P'     P'    
0  1  y   0 1  y   0  1  y 
P '  Pm  P P '  Rm  P P'  Z m  P
Specifying 2D Transformations

• Translation
– T(tx, ty)
– Translation distances
• Scale
– S(sx,sy)
– Scale factors
• Rotation
– R()
– Rotation angle
Homogeneous Coordinates
w

x 

• Let’s move our problem into 3D.


• Let point (x, y) in 2D be represented by point (x, y, 1) in the new
space.
• Scaling our new point by any value a puts us somewhere along a
particular line: (ax, ay, a).
• A point in 2D can be represented in many ways in the new space.
• (2, 4) ---------- (8, 16, 4) or (6, 12, 3) or (2, 4, 1) or etc.
Homogeneous Coordinates
Why do we use 1 for the last coordinate?

• The fact that all the points along each line can
be mapped back to the same point in 2D gives
this coordinate system its name – homogeneous
coordinates.
 x  1 0 t x   x 
 y  0 1 t    y  , P  T t , t  P
2D Translation
   y    x y
 1  0 0 1   1 

 x  cos   sin  0  x 
2D Rotation  y   sin  cos  0   y  , P  R    P
  
 1   0 0 1   1 

 x   S x 0 0  x 
2D Scaling  y   0 Sy 0   y  , P  S  S x , S y   P
  
 1   0 0 1   1 
Composite transformations
• More complex geometric & coordinate transformation
can be built from the basic transformation by using the
process of composition of function.

• We can represent any sequence of transformations as a


single matrix.
– No special cases when transforming a point
• matrix • vector.
– Composite transformations
• matrix • matrix.
Inverse transformations:

1 0 t x   cos  sin  0 1 S x 0 0
T1  0 1 t y  , R 1    sin  cos  0 , S 1   0 1 S y 0
0 0 1   0 0 1   0 0 1 

Composite transformations: P  M2  M1  P    M2  M1   P  M  P

   
P  T  t2 x , t2 y  T  t1x , t1 y   P  T  t2 x , t2 y   T  t1x , t1 y   P

1 0 t2 x  1 0 t1x  1 0 t1x  t2 x 
0 1 t   0 1 t   0 1 t  t 
Composite translations:  2y   1y   1y 2y 

0 0 1  0 0 1  0 0 1 

T  t2 x , t2 y   T  t1x , t1 y   T  t1x  t2 x , t1 y  t2 y 
P  R  2  R 1   P  R  2   R 1   P

Composite Rotations: R  2   R 1   R 1   2 

P  R 1   2   P

 S2 x 0 0   S1x 0 0   S1x  S2 x 0 0
 0 S2 y 0    0 S1 y 0    0 S1 y  S2 y 0 

 0 0 1   0 0 1   0 0 1 

Composite Scaling: S  S2 x , S2 y   S  S1x , S1 y   S  S1x  S2 x , S1 y  S2 y 


3D Translation
Very similar to 2D. Using 4x4 matrices rather than 3x3.

Translation x  x  t x
y
y  y  t y

z  z  tz

 x, y, z  x   1 0 0 tx   x 


 x, y, z   y  0
  1 0 t y   y 

 z  0 0 1 tz   z 
z x      
 1  0 0 0 1  1
3D Scaling
y y
x  x  S x

y  y  S y

z  x  S z

z x z x
Enlarging object also moves it from origin

 x   S x 0 0 0  x 
 y  0 Sy 0 0  y 
P        SP
 z   0 0 Sz 0  z 
     
1  0 0 0 1  1 
3D Rotations
 x' 1 0 0 0  x 
 y ' 0 Cos  Sin 0  y 
Rotation about X-axis ( Y-Z Plane) P'      
 z '  0 Sin Cos 
0 z
     
 1  0 0 0 1  1 

 x'  Sin 0 Cos 0  x 


 y '  0 1 0 0  y 
Rotation about Y-axis ( Z-X Plane) P'      
 z '  Cos 0  Sin 
0 z
     
1  0 0 0 1  1 

 x' Cos  Sin 0 0  x 


 y '  Sin Cos 0 0  y 
Rotation about Z-axis ( X-Y Plane) P'      
 z'  0 0 1 0  z 
     
1  0 0 0 1  1 
Thank You

You might also like