Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

ENGINEERING DESIGN AND CAD

LESSON 33:
TRANSFORMATIONS

Functions of Graphics Package origin in the x-direction and 5 units from the origin in the y-
To fulfill its role in the software configuration, the graphics direction.
package must perform a variety of different functions. These This method of representation can be conveniently extended to
functions can be grouped in to function sets. Each set accom- define a line as a 2 x 2 matrix by giving the x and y coordinates
plishes a certain kind of interaction between the user and the of the end points of the line. The notation would be
system. Some of the common functions sets are:
• Generation of graphic elements. x y 
• Transformations
L= 1 1  ........................(1)
x2 y2 
• Display control and windowing functions
Using the rules of matrix algebra, a point or line (or other
• Segmenting functions
geometric element represented in matrix notation) can be
• User input functions operated on by a transformation matrix to yield a new element.
We examine some of these functions in more detail in subse- There are several common transformations used in computer
quent sections of this chapter. What we present in the sections graphics. We will discuss three transformations:
below is a brief description of each.
• Translation
Generation Of Graphic Elements • Scaling
A graphic element in computer graphics is a basic image entity
such as a dot (or point), line segment, circle, and so forth. The • Rotation
collection of elements in the system could also include alphanu- Translation
meric characters and special symbols. There is often a special Translation involves moving the element from one location to
hardware component in the graphics system associated with the another. In the case of a point, the operation would be
display of many of the elements. This speeds up the process of
generating the element. The user can construct the application
x’ = x + m, y’ = y + n ........................(2)
model out of a collection of elements available on the system.
Where x’, y, = coordinates of the translated point
The term ‘primitive’ is often used in reference to graphic
elements. We shall reserve the use of this term to three- x, y = coordinates of the original point
dimensional graphics construction. Accordingly, a primitive is a m, n = movements in the x and y directions,
three dimensional wire frame models and solid modeling, respectively
primitives are used as building blocks to construct the three- In matrix notation this can be represented as
dimensional model of the particular object of interest to the
(x’, y’) = (x, y) + T ............................(3)
user
Where
Transformations
Transformations are used to change the image on the display T = (m, n), the translation matrix ............................(4)
screen and to reposition the item in the database. Transforma- Any geometric element can be translated in space by applying
tions are applied to graphic elements in order to aid the user in Eq. (3) to each point that defines the element. For a line, the
constructing an application model. These transformations were transformation matrix would be applied to its two end points.
in the model. For example, if a bolt is to be used several places Example 1
in the construction of a mechanical assembly model. The use of As an illustration of these transformations in two dimensions,
graphic cells is a convenient and powerful feature in the consider the line defined by
geometric model construction.
1 1
Many of the editing features involve transformations of the
L =
graphics elements or cells composed of elements or even the
entire model. In this section we discuss the mathematics of 2 4
these transformations. Two-dimensional transformations are Let us suppose that it is desired to translate the line in space by
considered first to illustrate concepts. 2 units in the x direction and 3 units in the y direction. This
Two-dimensional Transformations would involve adding 2 to the current x value and 3 to the
To locate a point in a two-axis Cartesian system, the x and y current y value of the end points defining the line. That is,
coordinates are specified. These coordinates can be treated
together as a 1 x 2 matrix (x, y). For example, the matrix (2,5)
would be interpreted to be a point, which is 2 units from the
© Copy Right: Rai University
60 7.235
ENGINEERING DESIGN AND CAD
1 1 2 3 3 4 1 1 2 0 2 2
+ = . =
2 4 2 3 4 7 2 4 0 2 4 8

8
7 •(4, 7) • (4, 8)
7
6 Translated Line
6
5
(2, 4) 5 2 x scaled line
4 • •(3, 4) (2, 4)
4 •
3
Original Line 3
2
1 2 •(2, 2)
•(1, 1)
x 1 • Original line
0 1 2 3 4 5 6 7 8 9 10 11 (1, 1)
x
Figure 1 Results of Translation in Example 1. x
0 1 2 3 4 5 6 7 8 9
Scaling
Scaling of an element is used to enlarge it or reduce its size. The Figure 2 Results of scaling in Example 2.
scaling need not necessarily be done equally in the x and y
Rotation
directions. For example, a circle could be transformed into an
In this transformation, the points of an object are rotated
ellipse by using unequal x and y scaling factors.
about the origin by an angle 0. For a positive angle, this rotation
The points of an element can be scaled by the scaling matrix as is in the counterclockwise direction. This accomplishes rotation
follows: of the object by the same angle, but it also moves the object. In
(x’, y’) = (x, y)S ............................(5) matrix notation, the procedure would be as follows:
Where (x’, y’) = (x, y)R .....................(7)
m 0 Where
S= (6) Cos 0 sin 0
0 n R= ..........(8)
This would produce an alteration in the size of the element by -Sin 0 cos 0
the factor m in the x-direction and by the factor n in the y
Defining the Graphic Elements
direction. It also has the effect of repositioning the element
The user has a variety of different ways to call a particular
with respect to the Cartesian system origin. If the scaling factors
graphic element and position it on the geometric model. Table
are less than 1, the size of the element is reduced and it is
lists several ways of defining points, lines, arcs and other
moved closer to the origin. If the scaling factors are larger than
components of geometry through interaction with the ICG
1, the element is enlarged and removed farther from the origin.
system. These components are maintained in the database in
Example 2 mathematical form and referenced to the three-dimensional
For the same original lines as in example 1, let us apply the coordinate system. For example, a point would be defined
scaling factor of 2 to the line. The scaling matrix for the 2 x 2 simply by its x, y and z coordinates. A polygon would be
line definition would therefore be defined as an ordered set of points representing the corners of
2 0 the polygon.
T = A circle would be defined in the x-y plane by the equation
0 2 (x-m) 2 + (y-n) 2 = r 2
The resulting line would be determined by Eq. As follows This specifies that the radius of the circle is r and the x and y of
the center are m and n. in each case, the mathematical definition
The new line is pictured in figure 2
can be converted in to its corresponding edges and surfaces for
(x’, y’) = (x, y) S filing in the database and display on the CRT screen.

© Copy Right: Rai University


7.235 61
Editing the Geometry
ENGINEERING DESIGN AND CAD
Example 3
We will use our same line and rotate the line about the origin by A computer aided design system provides editing capabilities to
300. make correction and adjustment in the geometric model. When
cos 30 sin 30 0.866 0.500 developing the model, the user must be able to delete, move,
copy and rotate components of the model. We have previously
R = =
discussed some of these adjustments in our discussions of the
-sin 30 cos 30 - 0.500 0.866 functions of the graphics package. The editing procedure
The new line would be defined as: involves selecting the desired portion of the model (usually by
means of one of the segmenting functions), and executing the
1 1 0.866 0.500 0.366 1.366
appropriate command (often involving one of the transforma-
. = tion functions).
2 4 -0.50 0.866 -0.268 4.464 The method of selecting the segment of the model to be
The effect of applying the rotation matrix to the line is shown modified varies from system to system. With cursor control, a
in figure 3 common method is for a rectangle to be formed on the CRT
y screen around the model segment. The rectangle is defined by
7 entering the upper left and lower right corners of the rectangle.
Another method involving a light pen is to place the pen over
6
the components to be selected. With the electronic pen and the
5 tablet, the method might be to stroke a line across the portion
of the model, which is to altered.
(-0.268, 4.464)•
•(2, 4) The computer must somehow indicate to the user which
Rotated Line 3 portion of the model has been selected. The reason for this is
verification that the portion selected by the computer is what
2 Original Line the user intended. Various techniques are used by different ICG
(0.366, 1.366) •
1 • (1, 1) systems to identify the segment. These include: placing a mark
on the segment, making the segment brighter than the rest of
x the image, and making the segment blink.
-2 -1 0 1 2 3 4 5 6 7 8

Figure 3 Results of Rotation in Example 3

© Copy Right: Rai University


62 7.235

You might also like