0% found this document useful (0 votes)
30 views69 pages

Unit 3

Uploaded by

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

Unit 3

Uploaded by

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

UNIT 3

2D, 3D Transformations and Projections

Prepared By:
Aarati Gangshetty
Unit III – 2-D, 3-D Transformations and Projections
• Syllabus
Unit III 2-D, 3-D Transformations and Projections 07 Hours
2-D transformations: introduction, homogeneous coordinates, 2-D
transformations - Translation, scaling, rotation and shear, rotation about an
arbitrary point.

3-D transformations: introduction, 3-D transformations - Translation, scaling,


rotation and shear, rotation about an arbitrary axis.

Projections : Parallel (Oblique: Cavalier, Cabinet and orthographic: isometric,


diametric, trimetric) and Perspective ( Vanishing Points – 1 point, 2 point and
3 point)

Department of Computer
Computer Graphics 2
Engineering
Introduction
• Major asset of computer graphics is the ease with which certain
alterations to a picture may be performed. Like,
– Viewing a building from different angles
– Zooming in and out
– Changing positions of a character / sub picture
– Changing the size of a graph
• These alterations are easy to perform as images are stored as a series of
numbers in the computer. These numbers may be modified by
mathematical operations called transformations
• Computer images are generated from a series of line segments which are
represented by the coordinates of their endpoints.
• Transformations are expressed in terms of matrix multiplications

Department of Computer
Computer Graphics 3
Engineering
Matrices
• Matrix multiplication is possible on two matrices M1 ( R1, C1) and M2
(R2, C2) only if C1 = R2. The resultant is matrix M3(R1, C2)
• E.g.
1 2 3 1 0 -1 7
4 5 6 -1 2 -1 16
* =
7 8 9 0 1 -1 25

• Identity Matrices : This is a set of matrices, which when multiplied with


any matrix, produce the same matrix. These are square matrices with all
elements as 0, except the elements of the main diagonal, which are 1.
• E.g.
1 0 0

I = 0 1 0
0 0 1

Department of Computer
Computer Graphics 4
Engineering
Basic Transformations
• Scaling Transformation
• Rotation Transformation
• Translation Transformation
Purposes:
– To move the position of objects
– To alter the shape / size of objects
– To change the orientation of objects

Department of Computer
Computer Graphics 5
Engineering
2D Transformation

• Transformation means changing some graphics into something


else by applying rules.
• When a transformation takes place on a 2D plane, it is called 2D
transformation.
Homogenous Coordinates
To perform a sequence of transformation such as translation
followed by rotation and scaling, we need to follow a sequential
process −
• Translate the coordinates,
• Rotate the translated coordinates, and then
• Scale the rotated coordinates to complete the composite
transformation.
Translation

• A translation moves an object to a different position


on the screen. You can translate a point in 2D by
adding translation coordinate (tx, ty) to the original
coordinate X,Y to get the new coordinate X′,Y′.
• From the above figure, you can write that −
• X’ = X + tx
• Y’ = Y + ty
Translation
• Translation - repositioning an object along a
straight-line path (the translation distances)
from one coordinate location to another.

(x’,y’)

(tx,ty)

(x,y)
Translation
• Given: P ( x, y )
P ( 3.7, 4.1)
T (7.1,8.2)
T (t x , t y )

x'  3.7  7.1


• We want: x'  x  t x
y '  4.1  8.2
y'  y  t y

 x'   3.7   7.1


• Matrix form:  x'  x   t x   y '   4.1   8.2
 y '  y    t       
     y  x' 3.4
P ' P  T y ' 4.1
Translation Examples
• P=(2,4), T=(-1,14), P’=(?,?)
• P=(8.6,-1), T=(0.4,-0.2), P’=(?,?)
• P=(0,0), T=(1,0), P’=(?,?)
Rotation

• Two-Dimensional rotation
– Rotation axis and angle are specified for rotation r
– Convert coordinates into polar form for calculation
r
x r cos  y  y sin
– Example, to rotation an object with angle a
• The new position coordinates
x' r cos(   ) r cos  cos   r sin  sin   x cos   y sin 
y ' r sin(   ) r cos  sin   r sin  sin   x sin   y cos 
• In matrix format
 cos   sin  
R   P' R P
sin  cos 
 about a point (x, y )
• Rotation r r

x'  xr  ( x  xr ) cos   ( y  yr ) sin 


y '  yr  ( x  xr ) sin   ( y  yr ) cos 

© 2005 Pearson Education


Rotation

– This figure shows the rotation of the house by 45 degrees.


y
6

2


1 6

0
1 2 3 4 5 6 7 8 9 10
x
• Positive angles are measured counterclockwise (from x
towards y)
• For negative angles, you can use the
identities:Clockwise
– cos(-q) = cos(q) and sin(-q)=-sin(q)
Scaling

• Scale - Alters the size of an object.


• Scales about a fixed point
(x’,y’)

(x,y)
Scaling
– If the scale factor had been greater than 1, it
would be larger and farther away.
WATCH OUT: Objects grow and move!
y
6

3  6  9
 3  3
   
2

1  2  3
 1  1
   
0
1 2 3 4 5 6 7 8 9 10
x
Note: House shifts position relative to origin
Scaling
• Given: P ( x, y ) P (1.4,2.2)
S ( s x , s y ) S (3,3)

x ' s x x x' 3 *1.4


• We want: y ' s y y y ' 3 * 2.2
 x'  3 0  1.4 
 y '  0 3  2.2
 x'  s x 0   x     
• Matrix form:  y '  0 s y   y  x' 4.2
  
P' S P y ' 6.6
Reflection

• Reflection is the mirror image of original object. In


other words, we can say that it is a rotation
operation with 180°. In reflection transformation, the
size of the object does not change.
Shear(Skewing)

• A transformation that slants the shape of an object is called


the shear transformation.
• There are two shear transformations X-Shear and Y-Shear.
Shear(Skewing)

• Shearing in the X-direction: Here shearing is done by sliding along


horizontal or x-axis. The homogeneous matrix for shearing in the x-direction
is shown below:

• Shearing in the Y-direction: Here shearing is done by sliding along vertical or y-


axis.

• Shearing in X-Y directions: Here layers will be slided in both x as well as y


direction.
Basic 2D Transformations

• Basic 2D transformations as 3x3 Matrices


 x 1 0 tx   x   x  sx 0 0   x 
 y  0 1 ty   y   y  0 sy 0  y 
         
1   0 0 1  1  1   0 0 1  1 
Translate Scale
 x  cos   sin  0   x   x 1 shy 0  x 
 y  sin  cos  0   y  y  shx 1 0   y 
         
1   0 0 1  1  1   0 0 1 1 

Rotate Shear

© 2005 Pearson Education


Homogeneous Coordinates
• To convert a 2×2 matrix to 3×3 matrix, we
have to add an extra dummy coordinate h. In
this way, we can represent the point by 3
numbers instead of 2 numbers, which is
called Homogenous Coordinate system
Homogeneous 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:
xh yh
x y
h h
• 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)
© 2005 Pearson Education
Why Homogeneous 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!
•Save required time for transformation and memory
required to store the intermediate co-ordinate values.
Homogenous Coordinates
• Combine the geometric transformation into a single matrix with 3by3 matrices
• Expand each 2D coordinate to 3D coordinate with homogenous parameter

• Two-Dimensional translation matrix  x'  1 0 t x   x 


     
y
  '  0 1 t y   y 
 1   0 0 1   1

 x'  cos   cos  0  x 


• Two-Dimensional rotation matrix      
 y'   sin cos  0  y 
 1   0 0 1  1

• Two-Dimensional scaling matrix  x'  s x 0 0  x 


     
 y'   0 sy 0  y 
 1   0 0 1  1

© 2005 Pearson Education


Inverse transformations
• Inverse Translation Matrix
 1 0  tx 
 
T 1  0 1  t y 
 0 0 1 
• Inverse Rotation Matrix
 cos  sin 0
 
R  1    sin cos  0
 0 0 1
• Inverse Scaling Matrix
 1 
s 0 0 
 x 
1
S 1  0 0
 sx 
 0 0 1
 
 
Three Dimensional
Transformations
Three Dimensional Transformations

 Methods for object modeling


transformation in three dimensions
are extended from two dimensional
methods by including consideration
for the z coordinate.
Three Dimensional Transformations

 Generalize from 2D by including z coordinate


 Straightforward for translation and scale,
rotation more difficult
 Homogeneous coordinates: 4 components
 Transformation matrices: 4×4 elements
3D Point
 We will consider points as column vectors.
Thus, a typical point with coordinates (x, y, z)
is represented as:

 x
 y
 
 z 
3D Point Homogenous Coordinate

A 3D point P is represented in
homogeneous coordinates by a 4-dim. Vect:

 x
 y
P  
 z
 
 1
3D Point Homogenous Coordinate

We don't lose anything


 x

 The main advantage: it is easier to  y


compose translation and rotation  
 Everything is matrix multiplication  z
 
 1
3D Translation
3D Translation
 P is translated to P' by:
 x   1 0 0 tx   x
 y   0 1 0 t y   y 
   
 z   0 0 1 tz   z
     
 1  0 0 0 1   1

P  T P
3D Translation
 An object is translated in 3D dimensional by
transforming each of the defining points of the
objects .
3D Translation
 An Object represented as a set of polygon surfaces, is translated
by translate each vertex of each surface and redraw the polygon
facets in the new position.

x' , y ' , z '


T t x , t y , t z 
x, y, z 

 Inverse Translation:
T (t , t , t ) T ( t , t , t )
1
x y z x y z
3D Rotation
Rotation Transformations
• In 2D, rotation is about a point. In 3D, rotation is about an axis
– In general, rotations are specified by a rotation axis and an angle
• This axis can be a major (x, y, z) or an arbitrary axis in space
– Rotation about the z axis: In xy plane
– Rotation about the y axis: In xz plane
– Rotation about the x axis: In yz plane
– Rotation about an arbitrary axis

Department of Computer
Computer Graphics 37
Engineering
Rotation About a Major Axis
 x '   cos  sin  0 0  x 
 y '   sin  cos  0 0   y 
    About ‘z’ :
 z '  0 0 1 0  z  In xy plane
     
 1  0 0 0 1  1 

 x '   cos  0  sin  0  x  About ‘y’ :


 y '  0 1 0 0   y  In xz plane
   
 z '   sin  0 cos  0  z 
     
 1  0 0 0 1  1 

 x '  1 0 0 0  x 
 y '  0 cos  sin  0   y 
    About ‘x’ :
 z '   0  sin  cos  0  z  In yz plane
     
 1  0 0 0 1  1 

Department of Computer
Computer Graphics 38
Engineering
3D Scaling
Scaling
• It is used to resize the object in 3D space.
• We can apply uniform as well as non uniform
scaling by selecting proper scaling factor.
• Scaling in 3D is similar to scaling in 2D. Only
one extra coordinate need to consider into it.
Scaling
• Simple coordinate axis scaling can be
𝑌
Scali
performed as below,
ng

Z
Example- Scaling
• Example: - Scale the line with coordinates
and respectively with scale factor .

• Final coordinates after scaling are,


Rotation About an Arbitrary Axis

1. Translate the arbitrary axis so that it passes through the origin


2. Rotate the arbitrary axis so that it coincides with one of the
principle axis, say Z
3. Rotate the object by the required angle in Z
4. Undo the rotation of the arbitrary axis
5. Undo the translation of the arbitrary axis
THE STEP TWO :
Rotate the arbitrary axis so that it coincides with one of the principle axis, say Z

a) Rotate the axis about the x axis ( Rx )


b) Rotate the axis bout y axis so that it aligns with
z axis ( Ry )
Rotation About an Arbitrary Axis
1. Translate the arbitrary axis to pass through origin ( T )
2. Rotate the axis about the x axis ( Rx )
3. Rotate the axis bout y axis so that it aligns with z axis ( Ry )
4. Rotate by angle θ ( Rz )
5. Undo rotation of axis about y axis ( Ry-1 )
6. Undo rotation of axis about x axis ( Rx-1 )
7. Translate the axis back to its original position ( T-1)
Translate the arbitrary axis to pass through origin ( T )

y
 1 0 0 0
(x2,y2,z2)  0 1 0 0 
T 
 0 0 1 0
 
(x1,y1,z1)   x1  y1  z1 1

z
Translate the arbitrary axis back to original position (T-1)
y

(x2,y2,z2)
1 0 0 0
0 1 0 0 
T-1 = 
(x1,y1,z1) 0 0 1 0
 
x  x1 y1 z1 1

z
Rotate the arbitrary axis about x axis ( Rx )

1 0 0 0
y  0 cos I sin I 0 
Rx 
 0  sin I cos I 0
(0,b,c)  
(a,b,c) 0 0 0 1

I 1 0 0 0
0 c / v b / v 0 
x
Rx 
0  b / v c / v 0
z  
0 0 0 1

Undo rotation about x axis ( Rx-1 )

1 0 0 0
0 c / v  b / v 0 
Rx = 
-1

0 b / v c / v 0
 
0 0 0 1
Rotate the arbitrary axis about y axis ( Ry )

 cos J 0 sin J 0
y  0 1 0 0 
Ry 
  sin J 0 cos J 0
 
(a,b,c)  0 0 0 1

 v/l 0 a/l 0
v l  0
J x 1 0 0 
Ry 
 a /l 0 v/l 0
z  
 0 0 0 1

Undo rotation about x axis ( Ry-1 )

v/l 0  a/l 0
 0 1 0 0 

Ry =  a / l
-1
0 v/l 0
 
 0 0 0 1
Rotate the object about z axis ( Rz)

 cos  sin  0 0
  sin  cos  0 0 
Rz 
 0 0 1 0
 
 0 0 0 1
Rotation About an Arbitrary Axis
Rθ = T.Rx.Ry.Rz.Ry-1.Rx-1.T-1
Rθ =  v/l 0 a / l 0
 1 0 0 0 1 0 0 0
0 c / v b / v  0 1 0 0 
 0 1 0 0   0  

 0 0 1 0 0  b / v c / v 0  a /l 0 v / l 0
     
  x1  y1  z1 1 0 0 0 1  0 0 0 1
 cos  sin  0 0 v/l 0  a/l 0 1 0 0 0
  sin   0 1 0  0 c / v  b / v 0 
cos  0 0   0
 
 0 0 1 0 a /l 0 v /l 0 0 b / v c / v 0
     
 0 0 0 1  0 0 0 1 0 0 0 1
1 0 0 0
0 1 0 0 

0 0 1 0
 
 x1 y1 z1 1
Projection

• It is the process of converting a 3D object into


a 2D object.
• It is also defined as mapping or
transformation of the object in projection
plane or view plane.
• Types of Projection
1. Parallel Projection
2.Perspective Projection
Parallel Projection

• The parallel projection is formed by extending parallel lines


from each vertex on the object until they intersect the view
plane.
• The point of intersection is the projection of vertex.
• When projectors are perpendicular to view plane then is
called orthographic projection.
• Parallel projections are used by
-architects and engineers for
creating working drawing of the
object.
Parallel Projection
• Characteristic of parallel Projection:
– In parallel Projection, the projection lines are parallel to each
other.
– There is the least amount of distortion within the object.
– The lines that are parallel to the object are also parallel to the
drawing.
– The view of Parallel Projection is the less realistic cause of no
foreshortening.
– The Parallel Projections are good for accurate measurements.
Types of Parallel Projections
Types of Parallel Projection

• There are two kind of parallel Projection:


1. Orthographic projection: In the Orthographic Parallel Projection,
the Projection is perpendicular to the view plane.

The Orthographic Projection is divided into two parts-


• Multiview Orthographic Projection: In Multiview Orthographic
Projection, we can represent the two-dimensional Orthographic
image into a three-dimensional object.
• The Multiview Orthographic Projection Includes-
– Front View
– Top View
– Side View
Multiview Orthographic Projection
Types of Parallel Projection
2.Axonometric Orthographic Projection: Orthographic
projections that show more than 1 side of an object are
called axonometric orthographic projections
• The Axonometric Orthographic Projection is used to construct
the pictorial representation of an object.
• The sight lines are perpendicular to the projection plane.
• Here parallel lines are equally foreshortened.
• The foreshortened factor is the ratio of projected length of
line to it’s true length.
Types of Axonometric Projection
Axonometric Orthographic Projection of 3 types:
• Isometric: All three principle axes are foreshortened equally.
• Dimetric: Two principle axes are foreshortened equally.
• Trimetric: All three principle axes are foreshortened
unequally.
Oblique Projection

• It is obtained by projecting points along parallel lines


that are not perpendicular to the projection plane.
• In oblique projection, we can view the object better
than orthographic projection.
• There are two types of oblique projections
− Cavalier and Cabinet.
Cavalier projection
• The Cavalier projection makes 45° angle with the
projection plane.
• The projection of a line perpendicular to the view
plane has the same length as the line itself in Cavalier
projection.
• In a cavalier projection, the foreshortening factors
for all three principal directions are equal.
Cabinet projection
• The Cabinet projection makes 63.4° angle with
the projection plane.
• In Cabinet projection, lines perpendicular to
the viewing surface are projected at ½ their
actual length.
Parallel Projection
Advantages:
• Good for exact Measurement
• Parallel lines remain parallel
Disadvantages:
• Less Realistic Looking
• Angles are not preserved
Perspective Projection
• Produces realistic views.
• The lines of projection are not parallel.
• In perspective projection, the distance from the center of
projection to project plane is finite.
• Instead, they all converge at a single point called center of
projection or projection reference point.
• Vanishing point-It is the point where all lines will appear to
meet.
One-point Perspective Projection
• There is only one vanishing point.
• It is easy to draw
• Use of One Point-to draw the images of roads,
railway tracks, and buildings.
Two-point Perspective Projection
• There are two vanishing points. One is the x-
direction and other in the y –direction.
• It is also called "Angular Perspective.“
• Use of Two Point- The main use of Two Point
projection is to draw the two corner roads.
Three-point Perspective Projection
• The Three-Point Perspective contains three
vanishing points.
• Two points lie on the horizon line, and one
above or below the line.
• Use of Three-Point: It is mainly used in
skyscraping.
Perspective Projection
Advantages:
• Better Look
• Clear Representation
Disadvantages:
• Difficult to Draw
• Not Suitable for many-dimensional images

You might also like