0% found this document useful (0 votes)
44 views45 pages

Computer Graphic Chapter 2

The document discusses two and three dimensional geometric transformations used in computer graphics. It describes transformations like translation, rotation, scaling, reflection and shearing in 2D and their representation using homogeneous coordinates and matrix. It also discusses 3D transformations and issues with 3D graphics.

Uploaded by

Rahul Karn
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)
44 views45 pages

Computer Graphic Chapter 2

The document discusses two and three dimensional geometric transformations used in computer graphics. It describes transformations like translation, rotation, scaling, reflection and shearing in 2D and their representation using homogeneous coordinates and matrix. It also discusses 3D transformations and issues with 3D graphics.

Uploaded by

Rahul Karn
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/ 45

Computer Graphics

Unit 2: Two Dimensional and


Three Dimensional Transformations

By
Gaurav Bhattarai

GauravBhattarai
Two Dimensional Geometric
Transformations
• In computer graphics, transformations of 2D objects are essential to many graphics
applications.
• The transformations are used directly by application programs and within many
graphics subroutines in application programs.
• Many applications use the geometric transformations to change the position ,
orientation, and size or shape of the objects in drawing.
• Rotation, Translation and scaling are three major transformations that are
extensively used by all most all graphical packages or graphical subroutines in
applications.
• Other than these , reflection and shearing transformations are also used by some
graphical packages.

GauravBhattarai
Translation
Changing the co-ordinate position along a straight line is
called 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. If P(x, y) is translated to a
position P’(x’, y’) by tx units parallel to x-axis and ty units
parallel to y axis then,
x’ = x+ tx
y’ = y+ ty

In matrix form:

i.e. P' = P + T,
where T is transformation matrix.

GauravBhattarai
Rotation
Changing the co-ordinate position along a circular path is called rotation. A rotation
repositions all points in an object along a circular path. The point about to which
object is to be rotated is called pivot point.
About origin:
If P(x, y) is rotated to a new position P’ (x, y’) in anti-clockwise direction by an angle θ,
then (x’, y’) can be calculated as following.
Let the angle made by line OP with x-axis is Ø and the radius of circulation path is r
then,
x = r cosØ
y = r sinØ
Also,
x’ = r cos(θ +Ø)
x’ = r(cosθ. CosØ – sinθ. SinØ)
x’ = x cosθ – y sinθ

y’ = r sin( θ + Ø)
y’ = r (sin θ. CosØ + cos θ .sinØ)
y’ = x sinθ + y cosθ

GauravBhattarai
In matrix form:

P' = R • P, where R is a rotation matrix.


• can be clockwise (-ve) or counterclockwise (+ve in this example).

GauravBhattarai
GauravBhattarai
Scaling
Scaling transformation alters 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.
Scaling about the origin:
If P(x, y) be scaled to a point P’(x’, y’) by sx times in x-coordinate and sy times in y-
coordinate then,
x’ = sx . x
y’ = sy . y
In matrix form:

P' = S . P, where S is a scaling matrix.


• If the scale factors are the same,
➢ That is, sx = sy →uniform scaling.
➢ Only change in size.
• If the scale factors are different
➢ That is, Sx  Sy →differential scaling.
➢ Change in size and shape.

GauravBhattarai
Matrix Representations and Homogeneous co-
ordinates
Many graphics applications involve sequences of geometric transformations. An
animation, for example, might require an object to be translated and rotated at each
increment of the motion. In design and picture construction applications, we perform
translations, rotations, and scaling's to fit the picture components into their proper
positions. Here we discuss how such transformation sequences can be efficiently
processed using matrix notation.

Homogeneous coordinate system


• It is the way representing n-dimensional Cartesian coordinates into n+1
dimensional projective coordinates or projective plane.
• In homogeneous coordinate representation, each 2D point (x, y) is represented as
homogeneous coordinate triple (xh, yh, h), where x = xh/h, y = yh/h
• h is 1 for 2D, and 3D case.
• Example:
2D point (2, -4) can be represented as (2, -4, 1).

GauravBhattarai
Why Homogeneous Co-ordinates?
• The homogeneous co-ordinate system provides a uniform framework for handling
different geometric transformations, simply as multiplication of matrices.
➢ To express any two-dimensional transformation as a matrix multiplication.
➢ To represent all the transformation equations as matrix multiplications.
➢ To perform more than one transformation at a time.
➢ To reduce unwanted calculations of intermediate steps, to save time and
memory and produce a sequence of transformations.

GauravBhattarai
Homogeneous Coordinate Representation For translation:

Therefore,
P’ = T(tx, ty).P
For inverse translation:
T-1 (tx, ty )= T (-tx, -ty)

Homogeneous Coordinate Representation for Rotation (about origin):

Therefore,
P’ = R(θ). P
For inverse rotation:
R-1 (θ) = R(-θ)

GauravBhattarai
Homogeneous Coordinate Representation For Scaling (about origin):

Therefore,
P’ = S(sx, sy).P
For inverse scaling:
S-1(sx, sy) = S(1/sx, 1/sy)

GauravBhattarai
Composite Transformation
In many cases, we need to apply several transformations (scaling, rotation,
translation) to one object. It is possible to set up a matrix for any sequence of
transformations as a composite transformation matrix by calculating the matrix
product of the individual transformations.
The basic purpose of composite transformations is gain efficiency by applying a single
composed transformation to a point, rather than applying a series of transformations,
one after another.

GauravBhattarai
GauravBhattarai
Q) Prove that two successive translations are additive i.e. T(tx1, ty1). T(tx2,ty2) =
T(tx1 + tx2, ty1+ ty2).

GauravBhattarai
Q) Prove that two successive rotation are additive i.e. R(θ2) . R(θ1) = R(θ1 +θ2).

GauravBhattarai
Q) Prove that two successive scaling are multiplicative i.e. S(sx2 , sy2). S(sx1,sy1) = S
(sx1.sx2, sy1.sy2).

GauravBhattarai
General Pivot Point Rotation

GauravBhattarai
General Fixed Point Scaling

GauravBhattarai
GauravBhattarai
GauravBhattarai
GauravBhattarai
GauravBhattarai
GauravBhattarai
Reflection
Reflection is a transformation that produces a mirror image of an object. In 2D-
transformation, reflection is generated relative to an axis of reflection. The reflection
of an object to a relative axis of reflection is same as 180 degree rotation about the
reflection axis.
Following are examples of some common reflections:
1. Reflection about the line y=0, the X- axis.
2. Reflection about the line x=0, the Y- axis.
3. Reflection about the line passing through the coordinate origin.
4. Reflection of an object w.r.t the straight line y=x.
5. Reflection of an object w.r.t the straight line y= -x.
6. Reflection of an object w.r.t arbitrary axis y=mx+b.

GauravBhattarai
GauravBhattarai
GauravBhattarai
GauravBhattarai
Shearing
• A shear is a transformation that distorts the shape of an object along coordinate
axes.
• It distorts the shape of an object such that the transformed shape appears as if the
object were composed of internal layers that had been caused to slide over each
other.
• Two common shearing transformations are those that shift coordinate x-values and
those that shift y-values.
• However, in both the cases, only one coordinate changes its coordinates and other
preserves its values.
• Shearing is also termed as Skewing.

Original Y-Shear
GauravBhattarai
GauravBhattarai
Similarly, we can determine XY-shear.

GauravBhattarai
Three Dimensional Graphics
• 3D computer graphics or three dimensional computer graphics are graphics that
use a three dimensional representation of geometric data that is stored in the
computer for the purpose of performing calculations and rendering 2D images.
• 2D is “flat” using the horizontal and vertical (X & Y) dimensions, the image has only
two dimensions.
• 3D adds the depth (Z) dimension.
• This third dimension allows for rotation and visualization from multiple
perspectives.
• We can perform different transformation by specifying the three dimensional
transformation vector, however the 3D transformation is more complex than 2D
transformation.

GauravBhattarai
Q. What are the issue in 3D that makes it more complex than 2D?
When we model and display a three-dimensional scene, there are many more
considerations we must take into account besides just including coordinate value
as 2D, some of them are:
• Relatively more coordinates point are necessary.
• Object boundaries can be constructed with various combinations of plane and
curved surfaces.
• Consideration of projection (dimension change with distance) and
transparency.
• Many consideration on visible surface detection and remove the hidden
surfaces.

GauravBhattarai
3-D Geometric Transformation
3-D Translation

GauravBhattarai
3-D Rotation

GauravBhattarai
GauravBhattarai
GauravBhattarai
General 3D Rotation (Rotation about any coordinate axis)

GauravBhattarai
3D Scaling
Matrix representation for scaling transformation of a position 𝑃 = (𝑥, 𝑦, 𝑧) relative to
the coordinate origin can be written as;

For scaling of point P(x, y, z) w.r.t to fixed point (𝑥𝑓 , 𝑦𝑓 , 𝑧𝑓 ) can be represented with
the following transformation.
1. Translate the fixed point to the origin. 𝑇(−𝑥𝑓 , −𝑦𝑓 , −𝑧𝑓 )
2. Apply scaling w.r.to origin. 𝑆(𝑠𝑥 , 𝑠𝑦, 𝑠𝑧 )
3. Translate the fixed point back to its original position. 𝑇(𝑥𝑓 , 𝑦𝑓 , 𝑧𝑓 )

GauravBhattarai
3D Reflection
In 3D-reflection the reflection takes place about a plane.

(a) About xy-plane (z-axis)


This transformation changes the sign of the z coordinates, leaving the x and y
coordinate values unchanged.

(b) About xz-plane (y-axis)


This transformation changes the sign of the y coordinates, leaving the x and z
coordinate values unchanged.

GauravBhattarai
(c) About yz-plane (x-axis)
This transformation changes the sign of the x coordinates, leaving the y and z
coordinate values unchanged.

About any plane


Step-1: Translate the plane such that it passes through origin i.e. normal vector passes
through origin.
Step-2: Rotate the plane such that normal vector lies on one of the co-ordinate axis.
Step-3: Perform reflection about the plane whose normal vector is one of the co-
ordinate axis.
Step-4: Rotate back the plane such that normal vector takes

GauravBhattarai
3D Shearing
Shearing transformations are used to modify objects shape.

(a) Z-axis shearing


This transformation alters x and y coordinates values by amount that is proportional to
the z values while leaving z coordinate unchanged.
𝑥′ = 𝑥 + 𝑠ℎ𝑥 𝑧
𝑦′ = 𝑦 + 𝑠ℎ𝑦 𝑧
𝑧′ = 𝑧

(b) X-axis shearing


This transformation alters y and z coordinates values by amount that is proportional to
the x values while leaving x- coordinate unchanged.
𝑥′ = 𝑥
𝑦′ = 𝑦 + 𝑠ℎ𝑦 𝑥
𝑧′ = 𝑧 + 𝑠ℎ𝑧 𝑥

GauravBhattarai
(c) Y- axis shearing
This transformation alters x and z coordinates values by amount that is proportional to
the y values while leaving y- coordinate unchanged.
𝑥′ = 𝑥 + 𝑠ℎ𝑥𝑦
𝑦′ = 𝑦
𝑧′ = 𝑧 + 𝑠ℎ𝑧𝑦

GauravBhattarai
Q) A homogenous coordinate point P(3, 2, 1) is translated in x, y, z direction by -2, -2
& -2 unit respectively followed by successive rotation of 60 degree about x- axis. Find
the final position of homogenous coordinate.

GauravBhattarai
Q) A cube of length 10 units having one of its corner at origin (0, 0, 0) & three edges
along principal axis. If the cube is to be rotated about z-axis by an angle of 45 degree
in counter clockwise direction, calculate the new position of point.

GauravBhattarai
Thank You

GauravBhattarai

You might also like