0% found this document useful (0 votes)
16 views59 pages

CH05 Two Dimensional Geometric Transformations

Chapter Five discusses two-dimensional geometric transformations in computer graphics, focusing on how geometric modeling, analysis, and visualization interact. It outlines types of transformations, including modeling and visual transformations, and details basic operations such as translation, rotation, and scaling, along with their mathematical representations. The chapter emphasizes the importance of transformations in manipulating geometric objects for applications in computer-aided design (CAD).

Uploaded by

xuseendahir18
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)
16 views59 pages

CH05 Two Dimensional Geometric Transformations

Chapter Five discusses two-dimensional geometric transformations in computer graphics, focusing on how geometric modeling, analysis, and visualization interact. It outlines types of transformations, including modeling and visual transformations, and details basic operations such as translation, rotation, and scaling, along with their mathematical representations. The chapter emphasizes the importance of transformations in manipulating geometric objects for applications in computer-aided design (CAD).

Uploaded by

xuseendahir18
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/ 59

Computer Graphics

Chapter Five: Two – Dimensional


Geometric Transformations
Introduction
• As stated earlier, Computer Aided Design consists of three
components, namely, Design (Geometric Modeling),
Analysis (FEA, etc), and Visualization (Computer Graphics).
Geometric Modeling provides a mathematical description
of a geometric object - point, line, conic section, surface, or
a solid. Visualization deals with creation of visual effects,
e.g., creation of pie charts, contour plots, shading,
animation, etc. Computer graphics provides visual displays
and manipulations of objects, e.g., transformation, editing,
printing, etc. Fortran and visual C languages are used to
effect these operations. Transformation is the backbone of
computer graphics, enabling us to manipulate the shape,
size, and location of the object. It can be used to effect the
following changes in a geometric object:
Geometric Object
• Change the location
• Change the Shape
• Change the size
• Rotate
• Copy
• Generate a surface from a line
• Generate a solid from a surface
• Animate the object
Two-Dimensional Transformation
• Geometric transformations have numerous
applications in geometric modeling, e.g., manipulation
of size, shape, and location of an object. In CAD,
transformation is also used to generate surfaces and
solids by sweeping curves and surfaces, respectively.
The term ‘sweeping’ refers to parametric
transformations, which are utilized to generate
surfaces and solids. When we sweep a curve, it is
transformed through several positions along or around
an axis, generating a surface. The appearance of the
generated surface depends on the number of instances
of the transformation.
Types of Transformations
• There are two types of transformations
Modeling Transformation:
this transformation alters the coordinate values of
the object. Basic operations are scaling, translation,
rotation and, combination of one or more of these
basic transformations. Examples of these
transformations can be easily found in any
commercial CAD software. For instance, AutoCAD
uses SCALE, MOVE, and ROTATE commands for
scaling, translation, and rotation transformations,
respectively
Types of Transformations
• Visual Transformation:
In this transformation there is no change in
either the geometry or the coordinates of the
object. A copy of the object is placed at the
desired sight, without changing the coordinate
values of the object. In AutoCAD, the ZOOM and
PAN commands are good examples of visual
transformation.
Basic Modeling Transformations
• There are three basic modeling
transformations:, Translation, Rotation and
Scaling. Other transformations, which are
modification or combination of any of the basic
transformations, are Shearing, Mirroring, copy,
etc.
Translation
• A translation is applied to an object by
repositioning it along a straight-line path from
one coordinate location to another. We
translate a two-dimensional point by adding
translation distances, t x, and t y to the original
coordinate position (x, y) to move the point to
a new position (x', y')

x' = x + t x y' = y + t y
• The translation distance pair [t x , t y] is called a
translation vector or shift vector.

t x 
 x' x T= 
P' =   P=  t y 
 y ' y
Translation
• This allows us to write the two-dimensional
translation equations in the matrix form:

P' = P + T
– We could translate an object by applying the
equation to every point of an object.
• Because each line in an object is made up of an infinite
set of points, however, this process would take an
infinitely long time.
• Fortunately we can translate all the points on a line by
translating only the line’s endpoints and drawing a new
line between the endpoints.
• This figure translates the “house” by (3, -4)
Translation
• Translating a point from position P
to‘ position P' with translation
vector T.

Sometimes matrix-transformation equations are


expressed in terms of coordinate row vectors instead
of column vectors. In this case, we would write the
matrix representations as P = [x y] and T = [tx , t y] .
Since the column-vector representation for a point is
standard mathematical notation, and since many
graphics packages, for example, GKS and PHIGS, also
use the column-vector representation, we will follow
this convention
Homogeneous Coordinates
• A transformation can be expressed as:
• [P*] = [P] [T]
• where,
• [P*] is the new coordinates matrix
• [P] is the original coordinates matrix, or points
matrix
• [T] is the transformation matrix
Homogeneous Coordinates
• With the z-terms set to zero, the P matrix can
be written as,

The size of this matrix depends on the geometry of the


object, e.g., a point is defined by a single set of coordinates
(x1, y1, z1), a line is defined by two sets of coordinates (x1,
y1, z1) and (x2, y2, z2), etc. Thus a point matrix will have the
size 1x3, line will be 2x3, etc.
• A transformation matrix is always written as a 4x4
matrix, with a basic shape shown below,

• Values of the elements in the matrix will change


according to the type of transformation being used, as
we will see shortly. The transformation matrix changes
the size, position, and orientation of an object, by
mathematically adding, or multiplying its coordinate
values. We will now discuss the mathematical
procedure for scaling, translation, and rotation
transformations.
Homogeneous Coordinates
• we should review the concept of homogeneous coordinate
system. Since the points matrix has three columns for the x, y,
and z values, and a transformation matrix is always 4x4
matrix, the two matrices are incompatible for multiplication.
A matrix multiplication is compatible only if the number of
columns in the first matrix equals the number of row in the
second matrix. For this reason, a points matrix is written as,
Homogeneous Coordinates
• Here, we have converted the Cartesian coordinates
into homogeneous coordinates by adding a 4th
column, with unit value in all rows. When a fourth
column, with values of 1 in each row, is added in the
points matrix, the matrix multiplication between the
[P] and [T ] becomes compatible. The values (x1, y1, z1,
1) represent the coordinates of the point (x1, y1, z1),
and the coordinates are called as homogeneous
coordinates. In homogeneous coordinates, the points
(2,3,1), (4,6,2), (6,9,3), (8,12,4), represent the same
point (2,3,1), along the plane z = 1, z = 2, z = 3, and z =
4, respectively. In our subsequent discussion on
transformation, we will use homogeneous coordinates.
Example
• If the triangle A(1,1), B(2,1), C(1,3) is scaled by
a factor 2, find the new coordinates of the
triangle.
• Solution
• The new points matrix can be evaluated by
the equation:
Solution

• Note that the new coordinates represent the original value


times the scale factor. The old and the new positions of the
triangle are shown in the figure.
Example 2
• Translate the rectangle (2,2), (2,8), (10,8),
(10,2) 2 units along x-axis and 3 units along y-
axis
• Solution: Using the matrix equation for
translation, we have [P*] = [P] [Tt],
substituting the numbers, we get
• Note that the resultant coordinates are equal
to the original x and y values plus the 2 and 3
units added to these values, respectively.
Rotation
• Rotation of a geometric model about an arbitrary axis,
other than any of the coordinate axes, involves several
rotational and translation transformations. When we
rotate an object about the origin (in 2-D), we in fact
rotate it about the z-axis.
• Thus, the rotation of an object about an arbitrary axis,
involves three steps:
• Step 1: Translate the fixed axis so that it coincides with
the z-axis
• Step 2: Rotate the object about the axis
• Step 3:Translate the fixed axis back to the original
position.
Rotation
• A two-dimensional rotation is applied to an object by
repositioning it along a circular path in the xy plane. To
generate a rotation, we specify a rotation angle 0 and
the position [x r yr ] of the rotation point (or pivot
point) about which the object is to be rotated.
• Positive values for the rotation angle define
counterclockwise rotations about the pivot point, as in
and negative values rotate objects in the clockwise
direction. This transformation can also be described as
a rotation about a rotation axis that is perpendicular to
the xy plane and passes through the pivot point.
Rotation
Equation of rotation
• We first determine the transformation equations
for rotation of a point position P when the pivot
point is at the coordinate origin. The angular and
coordinate relationships of the original and
transformed point positions are shown in Fig. 5-4.
In this figure, r is the constant distance of the
point from the origin, angle 4 is the original
angular position of the point from the horizontal,
and t3 is the rotation angle. Using standard
trigonometric identities, we can express the
trans- formed coordinates in terms of angles ϴ
and Ф as
• Two-Dimensional rotation
– Rotation axis and angle are specified for rotation
– Convert coordinates into polar form for calculation
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=
 sin  cos   P' = R  P
• Rotation about a point (xr, yr)
x' = xr + ( x − xr ) cos  − ( y − yr ) sin 
y ' = yr + ( x − xr ) sin  + ( y − yr ) cos 
Equation of rotation

• The original coordinates of the point in polar


coordinates are
• Substituting expressions into , we obtain the
transformation equations for rotating a point
at position (x, y) through an angle ϴ about the
origin:

• With the column-vector representations for


coordinate positions, we can write the
rotation equations in the matrix form
• where the rotation matrix is:
• Rotation of a point about an arbitrary pivot
position. Using the trigonometric
relationships in this figure, we can generalize
Eqs. to obtain the transformation equations
for rotation of a point about any specified
rotation position, (x r, yr ):
– This figure shows the rotation of the house by 45
y
degrees. 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:
❖cos(-) = cos() and sin(-)=-sin()
Scaling
• A scaling transformation alters the size of an
object. This operation can be carried out for
polygons by multiplying the coordinate values
(x, y) of each vertex by scaling factors s, and s ,
to produce the transformed coordinates (x',
y'):
Types of scaling
• There are two types of scaling
transformations: uniform and non-uniform. In
the uniform scaling, the coordinate values
change uniformly along the x, y, and z
coordinates, where as, in non-uniform scaling,
the change is not necessarily the same in all
the coordinate directions.
Uniform Scaling
• For uniform scaling, the scaling transformation
matrix is given as

• Here, s is the scale factor.


Non-Uniform Scaling
• Matrix equation of a non-uniform scaling has the
form:

• where, sx, sy, sz are the scale factors for the x, y,


and z coordinates of the object.
Scaling
Scaling
– In this figure, the house is scaled by 1/2 in x and
1/4 in y
• Notice that the scaling is about the origin:
– The house is smaller and closer to the origin
• Two-Dimensional scaling
– To alter the size of an object by multiplying the coordinates
with scaling factor sx and sy
x' = x  s x y = y  sy
– In matrix format, where S is a 2by2 scaling matrix
 x '  s x 0  x 
  = 0  P' = S  P
 y'  s y   y 
– Choosing a fix point (xf, yf) as its centroid to perform scaling
x' = x  s x + x f (1 − s x )
y' = y  s y + y f (1 − s 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
Combined Transformations
• Most applications require the use of more
than one basic transformation to achieve
desired results. As stated earlier, scaling with
an arbitrarily fixed point involves both scaling
and translation. And rotation around a given
point, other than the origin, involves rotation
and translation. We will now consider these
combined transformations.
Scaling With an Arbitrary Point
• Scaling With an Arbitrary Point In uniform
scaling, all points and their coordinates are scaled
by a factor s. Therefore, unless the fixed point is
located at (0, 0), it will be moved to a new
location with coordinates s-times x and s-times y.
To scale an object about a fixed point, the fixed
point is first moved to the origin and then the
object is scaled. Finally, the object is translated or
moved so that the fixed point is restored to its
original position. The transformation sequence is,
• [P*] = [P] [Tt] [Ts] [T-t]
• Where, [Tt] is the translation transformation
matrix, for translation of the fixed point to the
origin,
• [ T s] is the scaling transformation matrix,
and
• [T-t] is the reverse translation matrix, to
restore the fixed point to its original
position.
• The three transformation matrices [Tt] [Ts] [T-
t] can be concatenated to produce a single
transformation matrix, which uniformly scales
an object while keeping the pivot point fixed.
Thus, the resultant, concatenated
transformation matrix for scaling is,
• The concatenated equation can be used
directly instead of the step-by-step matrix
solution. This form is preferable when writing
a CAD program
Example
• Given the triangle, described by the
homogeneous points matrix below, scale it by
a factor 3/4, keeping the centroid in the same
location. Use
• (a) separate matrix operation and
• (b) condensed matrix for transformation.
Example
• The centroid of the triangle is at
x=(2+2+5)/3=3 y=(2+5+5)/3= 4 C(3,4)

• Scaling the triangle, we get,


Example
• Translating the triangle so that the centroid is
positioned at (3, 4), we get

• (b) The foregoing set of three operations can


be reduced to a single operation using the
condensed matrix with x = 3, and y = 4
Rotation About an Arbitrary Point (in
xy-plane)
• In order to rotate an object about a fixed
point, the point is first moved (translated) to
the origin. Then, the object is rotated around
the origin. Finally, it is translated back so that
the fixed point is restored to its original
position. For rotation of an object about an
arbitrary point, the sequence of the required
transformation matrices and the condensed
matrix is given as

• where, θ is the angle of rotation and the point


(x, y) lies in the xy plane.
Example
• Rotate the rectangle formed by points A(1,1),
B(2,1), C(2,3), and D(1,3) 300 ccw about the
point (3,2).
• [P*] = [P] [Tt] [Tr] [T-t]

Mirroring
• In modeling operations, one frequently used operation
is mirroring an object. Mirroring is a convenient
method used for copying an object while preserving its
features. The mirror transformation is a special case of
a negative scaling, as will be explained below.
• Let us say, we want to mirror the point A(2,2) about the
x-axis(i.e., xz-plane), as shown in the figure.
• The new location of the point, when reflected about
the x-axis, will be at (2, -2). The point matrix
[P*] = [2 -2] can be obtained with the matrix
transformation given below.
Mirroring About an Arbitrary Plane
• If mirroring is required about an arbitrary
plane, other than one defined by the
coordinate axes, translation and/or rotation
can be used to align the given plane with one
of the coordinate planes. After mirroring,
translation or rotation must be done in
reverse order to restore the original geometry
of the axis.
• Step 1: Translate the line AB (i.e., the plane)
such that it passes through the origin, as
shown by the dashed line.
• Step 2: Next, rotate the line about the origin
(or the z-axis) such that it coincides with x or y
axes (we will use the x-axis).
• Step 3: Mirror the rectangle about the x-axis.
• Step 4: Rotate the line back to its original
orientation.
• Step 5: Translate the line back to its original
position.
• The new points matrix, in terms of the original
points matrix and the five transformation
matrices is given as,
• [P*] = [P] [Tt] [Tr] [Tm] [T-r] [T-t] (Note: A
negative sign is used in the subscripts to
indicate a reverse transformation).

You might also like