Computer Graphics 1 74
Computer Graphics 1 74
UNIT STRUCTURE
1.0 Objective
1.1 Definition of Computer Graphics
1.2 History of Computer Graphics
1.3 Applications of Computer Graphics
1.3.1 CAD and CAM processes
1.3.2 Scientific Visualization
1.3.3 Entertainment and photorealism
1.3.4 Medical Content Creation
1.4 Graphics Package
1.4.1 Pixels and frame Buffer
1.4.2 Input Devices
1.4.3 Output Devices
1.4.4 The CPU and GPU
1.4.5 Graphics Pipeline
1.5 Graphics Software Implements
1.6 Numerical Examples
1.7 Summary
1.8 Questions for Exercise
1.9 Suggested Readings
1.0 OBJECTIVE
The objectives of this lesson are to make the student aware of the following concepts
• Describe computer graphics, its features and characteristics;
• Discuss applications of computer graphics in various fields
• Describe various types of hardware, required to work with graphic systems like
a) Display systems
b) Cathode ray tube
c) Random Scan
d) Raster Scan and
e) Display processor
f) Graphics Pipelining
Discuss existing Graphic Softwares to assist in areas of Graphical processing
1.1 DEFINITION OF COMPUTER GRAPHICS
Computer Graphics is principally concerned with the generation of images, with wide ranging
applications from entertainment to scientific visualisation. In other words, we can say that
computer graphics is a rendering tool for the generation and manipulation of images. Thus, by
using a computer as a rendering tool for the generation and manipulation of images is called
computer graphics. Computer graphics is an art of drawing pictures on computer screens with the
help of programming. It involves computations, creation, and manipulation of data. Graphics is a
vast field that encompasses almost any graphical aspect like special effects, simulation and
training, games, medical imagery, animations and much more. “Computer Graphics refers to any
sketch, drawing, special artwork or other material generated with the help of computer to pictorially depict
an object or a process or convey information, as a supplement to or instead of written descriptions”.
It relies on an internal model of the scene, that is, a mathematical representation suitable for
graphical computations. The model describes the 3D shapes, layout, projections to compute a 2D
image from a given viewpoint and rendering which involves projecting the objects (perspective),
handling visibility (which parts of objects are hidden) and computing their appearance and lighting
interactions and materials of the scene.
In the 1950’s, graphics output were taken via teletypes, line printer, and Cathode Ray Tube (CRT).
Using dark and light characters, a picture could be reproduced. In the 1960’s, advent of modern
interactive graphics, output were vector graphics and interactive graphics. One of the worst
problems was the cost and inaccessibility of machines. In the early 1970’s, output started using
raster displays, graphics capability was still fairly chunky. In the 1980’s output were built-in raster
graphics, bitmap image and pixel. Personal computers costs decreased drastically; trackball and
mouse become the standard interactive devices. In the 1990’s, since the introduction of VGA and
SVGA, personal computer could easily display photo-realistic images and movies. 3D image
renderings became the main advances and it stimulated cinematic graphics applications. Table 1:
gives a general history of computer graphics.
It is difficult for the human brain to make sense out of the large volume of numbers produced by
a scientific computation. Numerical and statistical methods are useful for solving this problem.
Visualisation techniques are another approach for interpreting large data sets, providing insights
that might be missed by statistical methods. As the volume of data accumulated from computations
or from recorded measurements increases, it becomes more important that we be able to make
sense out of such data quickly. Scientific visualisation, using computer graphics, is one way
to do this.
Scientific visualisation involve interdisciplinary research into robust and effective computer
science and visualisation tools for solving problems in biology, aeronautics, medical imaging, and
other disciplines. The profound impact of scientific computing upon virtually every area of science
and engineering has been well established. The increasing complexity of the underlying
mathematical models has also highlighted the critical role to be played by Scientific visualisation.
Thus, Scientific visualisation is one of the most active and exciting areas of Mathematics and
Computing Science, and indeed one which is only beginning to mature. Scientific visualisation is
a technology which helps to explore and understand scientific phenomena visually, objectively,
quantitatively. Scientific visualization allow scientists to think about the unthinkable and visualise
the unviable. This concept of scientific visualisation fits well with modeling and simulation.
One of the main goals of today’s special effects producers and animators is to create images with
highest levels of photorealism. Volume graphics is the key technology to provide full immersion
in upcoming virtual worlds e.g. movies or computer games.
Real world phenomena can be realized best with true physics based models and volume graphics
is the tool to generate, visualize and even feel these models! Movies like Star Wars Episode I,
Titanic and The Fifth Element already started employing true physics based effects.
Medical content creation like virtual anatomical atlas on CD-ROM and DVD have been build on
the base of the NIH Visible Human Project data set and different kind of simulation and training
software were build up using volume rendering techniques. Volume Graphics' products like the
VGStudio software are dedicated to the used in the field of medical content creation. VGStudio
provides powerful tools to manipulate and edit volume data. An easy to use keyframer tool allows
to generate animations.
Fig : Some Input Devices in a Graphics System (Mouse, Trackball, Data tablet, Joystick)
Data tablets provide absolute positioning with rows and columns of wires embedded under its
surface. The position of the stylus is determined through electromagnetic interactions between
signals traveling through the wires and sensors in the stylus. Touch-sensitive transparent screens
that can be placed over the face of a CRT have many of the same properties as the data tablet.
Small, rectangular, pressure-sensitive touchpads are embedded in the keyboards of many portable
computers. One other device, the joystick regulates its motion of the stick in two orthogonal
directions by encoding and interpreting as two velocities, and integrated to identify a screen
location. The integration implies that if the stick is left in its resting position, there is no change in
the cursor position and that the farther the stick is moved from its resting position, the faster the
screen location changes. Thus, the joystick is a variable-sensitivity device.
The formula to calculate the video memory required at a given resolution and bit-depth is :-
Memory (in MB) = (X-resolution * Y-resolution * Bit per pixel) / (8*1024*1024)
Raster scan displays, also known as bit-mapped or raster displays, are somewhat less relaxed.
Their whole display area is updated many times a second from image data held in raster memory.
The rest of this handout concerns hardware and software aspects of raster displays. In a raster scan,
an image is cut up into successive samples called pixels, or picture elements, along scan lines.
Each scan line can be transmitted as it is read from the detector, as in television systems, or can be
stored as a row of pixel values in an array in a computer system. Each complete sweep from top
left to bottom right of the screen is one complete cycle, called the Refresh Cycle.
Refreshing on raster-scan displays is carried out at the rate of 60 to 80 frames per second, although
some systems are designed for higher refresh rates. Sometimes, refresh rates are described in units
of cycles per second, or Hertz (Hz), where a cycle corresponds to one frame. Using these units, we
would describe a refresh rate of 60 frames per second as simply 60 Hz. At the end of each
scan line, the electron beam returns to the left side of the screen to begin displaving the next scan
line. The return to the left of the screen, after refreshing each scan line, is called the horizontal
retrace of the electron beam. And at the end of each frame (displayed in 1/80th to 1/60th of a
second), the electron beam returns (vertical retrace) to the top left comer of the screen to begin
the next frame. On some raster-scan systems (and in TV sets), each frame is displayed in two
passes using an interlaced refresh procedure. In the first pass, the beam sweeps across every other
scan line from top to bottom. Then after the vertical retrace, the beam sweeps out the remaining
scan lines. Interlacing of the scan lines in this way allows us to see the entire image displayed in
one-half the time it would have taken to sweep all the lines at once from top to bottom.
Interlacing is primarily used with slower refreshing rates.
In a simple system, there may be only one processor, the central processing unit (CPU) of the
system, which must do both the normal processing and the graphical processing. The main
graphical function of the processor is to take specifications of graphical primitives (such as lines,
circles, and polygons) generated by application programs and to assign values to the pixels in the
frame buffer that best represent these entities. For example, a triangle is specified by its three
vertices, but to display its outline by the three line segments connecting the vertices, the graphics
system must generate a set of pixels that appear as line segments to the viewer. The conversion
of geometric entities to pixel colors and locations in the frame buffer is known as rasterization,
or scan conversion. In early graphics systems, the frame buffer was part of the standard memory
that could be directly addressed by the CPU. Today, virtually all graphics systems are
characterized by special-purpose graphics processing units (GPUs), to carry out specific graphics
functions. The GPU can be either on the mother board of the system or on a graphics card. The
frame buffer
is accessed through the graphics processing unit and usually is on the same circuit board as the
GPU. GPUs are characterized by both special-purpose modules geared toward graphical
operations and a high degree of parallelism—recent GPUs contain over 100 processing
units, each of which is user programmable. GPUs are so powerful that they can often be used as
mini supercomputers for general purpose computing.
The functioning of a standard graphics system is typically described by an abstraction called the
graphics pipeline. The term “pipeline” is used because the transformation from mathematical
model to pixels on the screen involves multiple steps, and in a typical architecture, these are
performed in sequence; the results of one stage are pushed on to the next stage so that the first
stage can begin processing the next polygon immediately.
Each object comprises a set of graphical primitives. Each primitive comprises a set of vertices. We
can think of the collection of primitive types and vertices as defining the geometry of the scene.
In a complex scene, there may be thousands—even millions—of vertices that define the objects.
We must process all these vertices in a similar manner to form an image in the frame buffer. If we
think in terms of processing the geometry of our objects to obtain an image, we can employ the
four major steps in the imaging process:
1. Vertex processing
2. Clipping and primitive assembly
3. Rasterization
4. Fragment processing
No matter with which advance graphic software you are working with, if your output device or
Graphics hardware is not good, or hardware handling that software is not good, then ultimate result
will be not good, as discussed in the previous section to work with graphic packages.
1.5 GRAPHICS SOFTWARE IMPLEMENTS
The programmer who sets out to write a graphics program has a wide choice of starting points.
Because graphics cards—the hardware that generates data to be displayed on a screen—or their
equivalent chipsets vary widely from one machine to the next, it’s typical to use some kind of
software abstraction of the capabilities of the graphics card. This abstraction is known as an
application programming interface or API. A graphics API could be as simple as a single
function that lets you set the colors of individual pixels on the display, or it could be as complex
as a system in which the programmer describes an illuminated scene with high-level objects and
their properties. Often such high-level APIs are just a part of a larger system for application
development, such as modern game engines.
1.5.1 Software Tools for Image Processing
The Mathematical tools for the processing of digital images include convolution, Fourier
analysis, and statistical descriptions, and manipulative tools such as chain codes and run codes.
But these tools are worked with at very core levels, in general we use some software to process
the image with the help of computers. Some of the categories of image processing software with
their respective examples and features are listed below:
3. How many Kilobytes does a frame buffer need in a 600 x 400 pixel ?
Solution :
Resolution is 600 x 400 Suppose 1 pixel can store n bits Then, the size of frame buffer =
Resolution X bits per pixel = (600 X 400) X n bits = 240000 n bits
= 240000 n/1024 X 8 = 29.30 n KB (as 1kb = 1024 bytes)
4. Find out the aspect ratio of the raster system using 8 x 10 inches screen and 100 pixel/inch.
Solution :-
Aspect ratio = Width : Height = (8 x 100) /( 10 x 100) Aspect ratio = 4 : 5
5. How much time is spent scanning across each row of pixels during screen refresh on a raster
system with resolution of 1280 X 1024 and a refresh rate of 60 frames per second?
Solution :-
Here, resolution = 1280 X 1024 that means system contains 1024 scan lines and each scan
line contains 128 pixels refresh rate = 60 frame/sec. So, 1 frame takes = 1/60 sec. Since
resolution = 1280 X 1024 1 frame buffer consist of 1024 scan lines It means then 1024 scan
lines takes 1/60 sec Therefore, 1 scan line takes , 1 /(60 X 1024) = 0.058 sec
1.6 SUMMARY
In this chapter, we have set the stage for our top-down development of computer graphics.
We have stressed that computer graphics is a discipline with multi-faceted Applications and
have covered the following areas :-
a) Introduction to Computer Graphics
b) History of Computer Graphics
c) Applications of Computer Graphics
d) The need and use of Computer Graphics in the modern world
J.D. Foley, A.Dam, S.K. Feiner, J.F. Hughes, “Computer Graphics – principles and practice”,
Addison-Wesley, 1997
Andy Johnson's CS 488 Course Notes, Lecture 1
2.0 Objectives
2.1 Graphics Primitives
2.2 Line Drawing Algorithm
2.2.1 Digital Differential Analyzer
2.2.2 Bresenham’s Algorithm
2.3 Circle Drawing Algorithm
2.3.1 Bresenham’s Circle
2.3.2 Mid Point Algorithm
2.4 Polygon Filling Techniques
2.4.1 Scan Line Algorithm
2.4.2 Boundary Fill Algorithm
2.4.3 Flood Fill Algorithm
2.5 Clipping Methods
2.5.1 Cohen Sutherland Method
2.5.2 Cyrus – Beck Algorithm
2.5.3 Polygon Clipping (Sutherland Hodgeman)
2.5.4 Text Clipping
2.6 Windowport to Viewport
2.7 Summary
2.8 Questions for Exercise
2.9 Suggested Readings
2.0 OBJECTIVE
The unit describes the Line Generation,Circle generation Algorithms and Clipping ;
• To Apply Line Generation Algorithm to practical problems;
• Describe the different types of Line Generation Algorithm;
• Describe Circle Generation Algorithm;
• apply Circle Generation algorithm to practical problems;
• describe the different types of Circle Generation Algorithms;
• describe Polygon fill algorithm, and
• describe Scan Line Polygon fill algorithm.
2.1 GRAPHICS PRIMITIVES
Scan conversion is the process of converting basic, low level objects into their corresponding
pixel map representations. This is often an approximation to the object, since the frame buffer is a
discrete grid. Each pixel on the display surface has a finite size depending on the screen resolution
and hence, a pixel cannot represent a single mathematical point.
However, we consider each pixel as a unit square area identified by the coordinate of its lower left
corner, the origin of the reference coordinate system being located at the lower left corner of the
display surface. Thus, each pixel is accessed by a non-negative integer coordinate pair (x, y). The
x values start at the origin and increase from left to right along a scan line and the y values
Step 1 − Get the input of two end points (X0,Y0) and (X1,Y1).
Step 2 − Calculate the difference between two end points.
dx = X1 - X0
dy = Y1 - Y0
Step 3 − Based on the calculated difference in step-2, you need to identify the number of steps to
put pixel. If dx > dy, then you need more steps in x coordinate; otherwise in y coordinate.
Step 5 − Put the pixel by successfully incrementing x and y coordinates accordingly and complete
the drawing of the line.
Example 1: Draw line segment from point (2, 4) to (9, 9) using DDA algorithm.
Solution: We know general equation of line is given by
y = mx+c where m =( y1 – y0) / ( x1 – x0)
given (x0, y0) → (2, 4) ; (x1, y1) → (9, 9)
⇒ m = ( y1 – y0)/( x1 – x0) = 9-4 / 9-2
For example, as shown in the following illustration, from position (2, 3) you need to choose
between (3, 3) and (3, 4). You would like the point that is closer to the original line.
At sample position Xk+1,Yk+1, the vertical separations from the mathematical line are made.
dnew = F(xp+2, yp+1/2) = a(xp+2) + b(yp+1/2) + c
but dold = a(xp+1) + b(yp+1/2) + c
Now assuming we have to determine that the pixel at (xk , yk) is to be displayed, we next need to
divide which pixel to plot in column xk+1. Our choices are the pixels at position (xk+1 , yk) and
(xk+1 , yk+1).
At sampling position xk+1, we label vertical pixel separations from the mathematical line path as
d1 and d2. . The y coordinate on the mathematical line at pixel column position x k+1 is calculated
as : y = m(xk + 1) +b
Then d1 = y – yk = m (xk + 1) +b - yk
and d2 = (yk + 1) –y = yk + 1 – m (xk + 1) – b
The difference between these two separations is
d1 - d2 = 2m (xk+1) - 2yk + 2b - 1
A decision Parameter Pk for the kth step in the line algorithm can be obtained by rearranging and
by substituting m = Δy/Δx. where Δy & Δx are the vertical & horizontal separation of the endpoint
positions & defining.
Pk = Δx (d1 – d2) = 2Δy. xk - 2Δx yk + c _ _ _ ____________(A)
The sign of Pk is same as the sign of d1 - d2.
This recursive calculation of decision Parameter is performed each integer x position, starting at
left coordinate endpoint of the line. The first parameter P0 is evaluated from equation (A) at starting
pixel position (x0, y0) and with m evaluated as Δy/Δx.
P0 = 2Δy - Δx _ _ _ ______________________(B)
Since Δx > 0 for our example Parameter C is constant & has the value 2Δy + Δx (2b -1), which is
independent of pixel position. If the pixel position at yk is closer to line path than the pixel at yk+1
(that is d1 < d2), then decision Parameter Pk is Negative. In that case we plot the lower pixel
otherwise we plot the upper pixel.
i.e. Pk+1=PK + 2* Δy;
else when Decision Parameter Pk >0
yk+1=yk+1; xk+1 = xk+1
and Pk+1=PK+ 2*( Δy - Δx);
Coordinate changes along the line owner in unit steps in either the x or directions. Therefore we
can obtain the values of successive decision Parameter using incremental integer calculations.
Example 2: Digitize the line with end points (20, 10) & (30, 18) using Bresenham’s Line
Drawing Algorithm
Hint Solution :
Δx = 10 , Δy = 8
Initial decision parameter has the value
P0 = 2Δy - Δx = 2x8 – 10 = 6
Since P0 > 0, so next point is (xk + 1, yk + 1) (21, 11)
Now k = 0, Pk+1 = Pk + 2Δy - 2Δx
P1 = P0 + 2Δy - 2Δx
= 6 + (-4)
=2
Since P1 > 0, Thus , Next point is (22, 12)
Now k = 1, Pk+1 = Pk + 2Δy - 2Δx
P2 = 2 + (- 4)
=-2
Since P2 < 0, Thus, Next point is (23, 12)
Now k = 2 Pk+1 = Pk + 2Δy
P2 = - 2 + 16
= 14
Since P3 > 0, Thus, Next point is (24, 13)
Now k = 3 Pk+1 = Pk + 2Δy - 2Δx
P4 = 14 – 4
= 10
Since P4 > 0, So, Next point is (25, 14)
Now k = 4 Pk+1 = Pk + 2Δy - 2Δx
P5 = 10 – 4
=6
Since P5 > 0, Next point is (26, 15)
Now k = 5 Pk+1 = Pk + 2Δy - 2Δx
P6 = 6 – 4
=2
Since P6 > 0, So,Next point is (27, 16)
Now k = 6 Pk+1 = Pk + 2Δy - 2Δx
P7 = 2 + (- 4)
=-2
Since P7 < 0, So, Next point is (28, 16)
Now k = 7 Pk+1 = Pk + 2Δy
P8 = - 2 + 16
= 14
Since P8 > 0, So, Next point is (29, 17)
Now k = 8 Pk+1 = Pk + 2Δy - 2Δx
P9 = 14 – 4
= 10
Since P9 > 0, So, Next point is (30, 18)
i.e. To Summarize the Raster Points
K Pk xk+1 yk+1
0 6 21 11
1 2 22 12
2 -2 23 12
3 14 24 13
4 10 25 14
5 6 26 15
6 2 27 16
7 -2 28 16
8 14 29 17
9 10 30 18
A circle is a set of points that are at a given distance r form the center position (x c, yc). This
distance relationship is given as :
(x – xc)2 + (y – yc)2 – r2 = 0
We cannot display a continuous arc on the raster display. Instead, we have to choose the nearest
pixel position to complete the arc.
This equation is used to calculate the position of points along the circle path by moving in the x
direction from (xc - r) to (xc + r) and we have put the pixel at (X, Y) location and now need to
decide where to put the next pixel − at N (X+1, Y) or at S (X+1, Y-1).
f(x, y) = x2 + y2 - r2 = 0
f(xi - 1/2 + e, yi + 1)
= (xi - 1/2 + e)2 + (yi + 1)2 - r2
= (xi- 1/2)2 + (yi + 1)2 - r2 + 2(xi - 1/2)e + e2
= f(xi - 1/2, yi + 1) + 2(xi - 1/2)e + e2 = 0
X = X + XC, Y = Y + YC
Step 2 − ScanLine intersects with each edge of the polygon from Ymin to Ymax. Name each
intersection point of the polygon. As per the figure shown above, they are named as p0, p1, p2,
p3.
Step 3 − Sort the intersection point in the increasing order of X coordinate i.e. (p0, p1), (p1, p2),
and (p2, p3).
Step 4 − Fill all those pair of coordinates that are inside polygons and ignore the alternate pairs.
current = GetPixel(x, y)
if ((current != boundaryColor) && (current != fillColor))
setPixel(fillColor, x, y);
boundaryFill (x+1, y, fillColor, boundaryColor)
boundaryFill (x, y+1, fillColor, boundaryColor)
boundaryFill (x-1, y, fillColor, boundaryColor)
boundaryFill (x, y-1, fillColor, boundaryColor)
Note that this is a recursive routine. Each invocation of boundaryFill () may call itself four more
times.
The logic of this routine is very simple. If we are not either on a boundary or already filled we first
fill our point, and then tell our neighbors to fill themselves.
The boundary fill algorithm works as its name. This algorithm picks a point inside an object and
starts to fill until it hits the boundary of the object. The color of the boundary and the color that
we fill should be different for this algorithm to work.
Step 4 − Change the default color with the fill color at the seed point.
Step 6 − Exit
There is a problem with this technique. Consider the case as shown below where we tried to fill
the entire region. Here, the image is filled only partially. In such cases, 4-connected pixels
technique cannot be used.
8-Connected Polygon
In this technique 8-connected pixels are used as shown in the figure. We are putting pixels above,
below, right and left side of the current pixels as we were doing in 4-connected technique.
In addition to this, we are also putting pixels in diagonals so that entire area of the current pixel
is covered. This process will continue until we find a boundary with different color.
Step 4 − Change the default color with the fill color at the seed point.
Step 6 − Exit
The 4-connected pixel technique failed to fill the area as marked in the following figure which
won’t happen with the 8-connected technique.
Clipping may be described as the procedure that identifies the portions of a picture lie inside the
region, and therefore, should be drawn or, outside the specified region, and hence, not to be drawn.
The algorithms that perform the job of clipping are called clipping algorithms there are various
types, such as:
• Point Clipping
• Line Clipping
• Polygon Clipping
• Text Clipping
• Curve Clipping
Further, there are a wide variety of algorithms that are designed to perform certain types of clipping
operations, some of them which will be discussed in unit.
Line Clipping Algorithms:
• Cohen Sutherland Line Clippings
• Cyrus-Beck Line Clipping Algorithm
Polygon or Area Clipping Algorithm
• Sutherland-Hodgman Algorithm
There are various other algorithms such as, Liang – Barsky Line clipping, Weiler-Atherton
Polygon Clipping, that are quite efficient in performing the task of clipping images. But, we will
restrict our discussion to the clipping algorithms mentioned earlier.
Before going into the details of point clipping, let us look at some basic terminologies used in the
field of clipping, such as, window and viewport.
Window may be described as the world coordinate area selected for display.
Viewport may be described as the area on a display device on which the window is mapped.
So, it is the window that specifies what is to be shown or displayed whereas viewport specifies
where it is to be shown or displayed. Specifying these two coordinates, i.e., window and viewport
coordinates and then the transformation from window to viewport coordinates is very essential
from the point of view of clipping.
Note:
• Assumption: That the window and viewport are rectangular. Then only, by specifying the
maximum and the minimum coordinates i.e., (Xwmax, Ywmax) and (Xwmin, Ywmin) we can
describe the size of the overall window or viewport.
• Window and viewport are not restricted to only rectangular shapes they could be of any other
shape (Convex or Concave or both).
Point clipping tells us whether the given point (X, Y) is within the given window or not; and
decides whether we will use the minimum and maximum coordinates of the window.
The X-coordinate of the given point is inside the window, if X lies in between Wx1 ≤ X ≤ Wx2.
The Y coordinate of the given point is inside the window, if Y lies in between Wy1 ≤ Y ≤ Wy2.
A variety of line clipping algorithms are available in the world of computer graphics, two of which
are :
1) Cohen Sutherland algorithm,
2) Cyrus-Beck of algorithm
All coding of regions U,D,L,R is done with respect to window region. As window is neither Up
nor Down, neither Left nor Right, so, the respective bits UDLR are 0000 of Central region. The
positioning code UDLR is 1010, i.e., the region 1 lying on the position which is upper left side of
the window. Thus, region 1 has UDLR code 1010 (Up so U=1, not Down so D=0, Left so L=1,
not Right so R=0).
The meaning of the UDLR code to specify the location of region with respect to window is:
1st bit ⇒ Up(U) ; 2nd bit ⇒ Down(D) ;3rd bit ⇒ Left(L) ; 4th bit ⇒ Right(R),
Now, to perform Line clipping for various line segment which may reside inside the window region
fully or partially, or may not even lie in the widow region; we use the tool of logical ANDing
between the UDLR codes of the points lying on the line.
Logical ANDing (^) operation => 1 ^ 1 = 1; 1 ^ 0 = 0;
between respective bits implies 0 ^ 1 = 0; 0 ^ 0 = 0
Note:
• UDLR code of window is 0000 always and w.r.t. this will create bit codes of other regions.
• A line segment is visible if both the UDLR codes of the end points of the line segment equal to
0000 i.e. UDLR code of window region. If the resulting code is not 0000 then, that line segment
or section of line segment may or may not be visible.
Now, let us study how this clipping algorithm works. For the sake of simplicity we
will tackle all the cases with the help of example lines l1 to l5 shown in Figure 4.
Line can be completely inside the window (This line should be accepted).
Line can be completely outside of the window (This line will be completely
removed from the region).
Line can be partially inside the window (We will find intersection point and draw
only that portion of line that is inside region).
Algorithm
Step 1 − Assign a region code for each endpoints.
Step 2 − If both endpoints have a region code 0000 then accept this line.
Step 3 − Else, perform the logical AND operation for both region codes.
Step 3.1 − If the result is not 0000, then reject the line.
Step 3.2.1 − Choose an endpoint of the line that is outside the window.
Step 3.2.2 − Find the intersection point at the window boundary (base on region code).
Step 3.2.3 − Replace endpoint with the intersection point and update the region code.
Step 3.2.4 − Repeat step 2 until we find a clipped line either trivially accepted or trivially
rejected.
Example : For the rectangular window boundaries given as xL=2, yB=2, xR=8, yT=8, check the
visibility of the following segments using the Cohen-Sutherland algorithm and, if necessary, clip
them against the appropriate window boundaries.
Line AB: A(3,10) B(6,12); Line CD: C(4,1), D(10,6)
Solution :-
Step 1. Set up the end codes of the two lines
A(3,10) (1000); B(6,12) (1000); Line AB is invisible
C(4,1) (0100); D(10,6) (0010); Line CD is indeterminate
Step 2. Clipping of line CD
(a) Endpoint C has a code of (0100). Since bit 2 is not zero, intersection must be found with
the boundary y=y0=2. The parametric equation of line CD is
X= 4 +(10-4)t = 4 +6t
Y = 1+(6-1)t= 1+5t Solving t=0.2 so intersection point is I1=(5.2,2)
(b) Endpoint D has a code of (0010). For bit 3 not equal to zero, the intersection with the
boundary x=xR=8 must be found. Substituting x=8 to previous equation yields
t=4/6=0.667 and y=4.33. So the intersection point is I2(8,4.33)
Since both I1 and I2 lie on the window boundary, their end codes are (0000) and (0000),
respectively. The line segment is, therefore, visible between the two intersection points.
The Cyrus-Beck algorithm is of O(N) complexity, and it is primarily intended for a clipping a line
in the parametric form against a convex polygon in 2 dimensions.It was designed to be more
efficient than the Sutherland Cohen algorithm which uses repetitive clipping. It was introduced
back in 1978 by Cyrus and Beck and it employs parametric line representation and simple dot
products.
Let Ni be the outward normal edge Ei. Now pick any arbitrary point PEi on edge Ei then the dot
product Ni.[P(t) – PEi] determines whether the point P(t) is “inside the clip edge” or “outside” the
clip edge or “on” the clip edge.
Ni.[P(t) – PEi] = 0
t=Ni.[Po−PEi]−Ni.Dt=Ni.[Po−PEi]−Ni.D
D ≠ 0 (P1 ≠ P0)
A polygon can also be clipped by specifying the clipping window. Sutherland Hodgeman polygon
clipping algorithm is used for polygon clipping. In this algorithm, all the vertices of the polygon
are clipped against each edge of the clipping window.
First the polygon is clipped against the left edge of the polygon window to get new vertices of the
polygon. These new vertices are used to clip the polygon against right edge, top edge, bottom
edge, of the clipping window as shown in the following figure.
While processing an edge of a polygon with clipping window, an intersection point is found if
edge is not completely inside clipping window and the a partial edge from the intersection point
to the outside edge is clipped. The following figures show left, right, top and bottom edge
clippings −
2.5.4 Text Clipping
Various techniques are used to provide text clipping in a computer graphics. It depends
on the methods used to generate characters and the requirements of a particular
application. There are three methods for text clipping which are listed below −
Text clipping
In all or none string clipping method, either we keep the entire string or we reject entire string
based on the clipping window. As shown in the above figure, STRING2 is entirely inside the
clipping window so we keep it and STRING1 being only partially inside the window, we reject.
This clipping method is based on characters rather than entire string. In this method if the string
is entirely inside the clipping window, then we keep it. If it is partially outside the window, then
You reject only the portion of the string being outside
If the character is on the boundary of the clipping window, then we discard only that
portion of character that is outside of the clipping window.
In a typical application, we have a rectangle made of pixels, with its natural pixel coordinates,
where an image will be displayed. This rectangle will be called the viewport. We also have a set
of geometric objects that are defined in a possibly different coordinate system, generally one that
uses real-number coordinates rather than integers. These objects make up the "scene" or "world"
that we want to view, and the coordinates that we use to define the scene are called world
coordinates.
For 2D graphics, the world lies in a plane. It's not possible to show a picture of the entire
infinite plane. We need to pick some rectangular area in the plane to display in the image. Let's
call that rectangular area the window, or view window. A coordinate transform is used to map the
window to the viewport.
𝑊 −𝑊 𝑉 −𝑉
𝑎𝑛𝑑 =
𝑊 −𝑊 𝑉 −𝑉
𝑉 −𝑉
𝑜𝑟 , 𝑉 = (𝑊 − 𝑊 )+𝑉
𝑊 −𝑊
𝑉 −𝑉
𝑉 = 𝑊 −𝑊 +𝑉
𝑊 −𝑊
The viewing transformation can be represented in terms of basic transformation as above figure.
If the composite transformation is N then
𝑉 𝑊
𝑉 =𝑁∙ 𝑊
1 1
Where 𝑁 = 𝑇 ∙ 𝑆 , 𝑠𝑦 ∙ 𝑇
𝑆𝑖𝑛𝑐𝑒 𝑉 = 𝑖 𝑉 + 𝑗𝑉
𝑉′ = 𝑖 𝑊 + 𝑗𝑊
1 0 𝑉 1 0 𝑊
𝑇 = 1 0 𝑉 , 𝑇 1 0 𝑊
0 0 1 0 0 1
and
𝑉 −𝑉
⎡𝑆 = 0 0⎤
⎢ 𝑊 −𝑊 ⎥
⎢0 𝑉 −𝑉
𝑆 = 0⎥
⎢ 𝑊 −𝑊 ⎥
⎣0 0 1⎦
For rectangular window or viewport, the aspect ratio is given by the ratio of width to height:
Example :- Find the transformation matrix that will map points contained in a window whose
lower left corner is at (2, 2) and upper right corner is at (6, 5) onto a normalized viewport that
has a lower left corner at (1/2, 1/2) and upper right corner at (1, 1).
Solution :-
=
The Shear Transformation in each case :-
Sx =1/4 0.5/4 0.5/4 1/2
Sy =1/4 0.5/4 1/ 4 ½
So that the distortion picture (sx=1/8, sy=1/4) in the third row is can be rewritten in matrix form,
the transformation matrix becomes:
2.7 SUMMARY
In this chapter, we understood the techniques of rendering primitives like straight line and circles.
The filling algorithms are quite important as they give privilege to quickly fill colours into the graphics
created by you. We have also covered the viewing areas and conditions for clipping by various
algorithms. We understood that the world is viewed through a world coordinate window, which is
mapped onto a device coordinate viewport. The unit is quite important from the point of view of
achieving realism through computer graphics. This unit contains algorithms, which are easy to
implement in any programming language.
GEOMETRICAL TRANSFORMATIONS
3.0 Objective
3.1 Two Dimensional Transformations
3.1.1 Translation
3.1.2 Rotation
3.1.3 Scaling
3.1.4 Shearing
3.1.5 Reflection
3.2 Composite Transformations
3.3 Homogeneous Coordinate Systems
3.4 Three Dimensional Transformations
3.4.1 Transformations for 3D Translation
3.4.2 Transformations for 3D Scaling
3.4.3 Transformations for 3D Rotation
3.4.4 Transformations for 3D Shearing
3.5 Co-ordinate Transformations
3.6 Summary
3.7 Questions for Exercises
3.8 Suggested Readings
3.0 OBJECTIVE
The objects are referenced by their coordinates. Changes in orientation, size and shape are
accomplished with geometric transformations that allow us to calculate the new coordinates. After
going through this unit, you should be able to:
• Describe the basic transformations for 2-D translation, rotation, scaling and shearing;
• Discuss the role of composite transformations
• Describe composite transformations for Rotation about a point and reflection about a line;
• Define and explain the use of homogeneous coordinate systems for the transformations
Describe the 3-D transformations of translation, rotation, scaling and shearing;
3.1 TWO DIMENSIONAL TRANSFORMATIONS
Geometric transformations have numerous applications in geometric modeling, e.g., manipulation
of size, shape, and location of an object. Transformations are 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.
i. Geometric Transformation
ii.Co-ordinate Transformation
i.Geometric Transformation: - Every object is assumed to be a set of points. Every object point
P is denoted by the ordered pairs known as coordinates (x, y) and so the object is the sum of
total of all the coordinates points. If any object is transform to a new position then the
or background, referred as geometric transformations and applied to each point of the object.
And while the co-ordinate system is moved relative to the object and object is held stationary
Let us look at the procedure for carrying out basic transformations, which are based on
matrix operation. 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
𝑥1 𝑦1 0
With the z-terms set to zero, the P matrix can be written as, [P] = 𝑥2 𝑦2 0
𝑥𝑛 𝑦𝑛 0
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.
3.1.1 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’).
X’ = X + tx
Y’ = Y + ty
In the matrix form
1 0 t
TV = 0 1 t
0 0 1
The pair (tx, ty) is called the translation vector or shift vector. The above equations can also be
represented using the column vectors.
P’ = P + T
If (x,y) is the original point and (x1,y1) is the transformed point, then the formula for a translation
is
x1 = x + e
y1 = y + f
where e is the number of units by which the point is moved horizontally and f is the amount by
which it is moved vertically.
Y (𝑿𝟐 , 𝒀𝟐 )
(𝑿𝟏 , 𝒀𝟏 )
(𝑿𝟐 + 𝒕𝒙 , 𝒀𝟐 + 𝒕𝒚 )
(𝑿𝟏 + 𝒕𝒙 , 𝒀𝟏 + 𝒕𝒚 )
X
Fig
3.1.2 Rotation
In rotation, we rotate the object at particular angle θ (theta) from its origin. From the following
figure, we can see that the point P(X, Y) is located at angle φ from the horizontal X coordinate
with distance r from the origin.
Let us suppose you want to rotate it at the angle θ. After rotating it to a new location, you will get
a new point P’ (X’, Y’).
Using standard trigonometric the original coordinate of point P(X, Y) can be represented as −
X=rcosϕ.................................................(1)
Y=rsinϕ..................................................(2)
Same way we can represent the point P’ (X’, Y’) as −
x′=rcos(ϕ+θ)=rcosϕcosθ−rsinϕsinθ.......(3)
y′=rsin(ϕ+θ)=rcosϕsinθ+rsinϕcosθ.......(4)
Substituting equation (1) & (2) in (3) & (4) respectively, we will get
x′=xcosθ−ysinθ x′ = xcosθ−ysinθ
y′=xsinθ+ycosθ y′ = xsinθ+ycosθ
Representing the above equation in matrix form for Anti-clockwise direction,
𝑐𝑜𝑠θ sinθ
𝑅 =
−sinθ cosθ
[𝑥 𝑐𝑜𝑠θ sinθ
𝑦 ] = [𝑥 𝑦] OR P’ = P . R
−sinθ cosθ
0
Example 2: Perform a 45 rotation of a triangle A(0,0),B(1,1),C(5,2) about the origin.
Solution: We can represent the given triangle, in matrix form, using homogeneous coordinates of
0 0 1
the vertices: 1 1 1
5 2 1
√ √
cos 45 sin 45 0 0
0
The matrix of rotation is: Rθ = R45 = − sin 45 cos 45 0 = √ √
− 0
0 0 1
0 0 1
So the new coordinates A’B’C’ of the rotated triangle ABC can be found as:
3.1.3 Scaling
In scaling transformation, the original coordinates of an object are multiplied by the given scale factor.
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.
The mathematical expression for pure scaling is
𝑥ꞌ = 𝑆 . 𝑥
𝑦ꞌ = 𝑆 . 𝑦
Where S is the scaling matrix. The scaling process is shown in the following figure.
If we provide values less than 1 to the scaling factor S, then we can reduce the size of the object.
If we provide values greater than 1, then we can increase the size of the object.
X
Fig: Scaling Transformation of a Line
3.1.4 Shearing
A transformation that slants the shape of an object is called the shear transformation. There are
two shear transformations X-Shear and Y-Shear. One shifts X coordinates values and other
shifts Y coordinate values. However; in both the cases only one coordinate changes its coordinates
and other preserves its values. Shearing is also termed as Skewing.
X-Shear
The X-Shear preserves the Y coordinate and changes are made to X coordinates, which causes
the vertical lines to tilt right or left as shown in below figure.
The transformation matrix for X-Shear about the origin by a distance can be represented as –
1 0 0
𝑎 1 1
0 0 1
X' = X + Shx . Y Y’ = Y
Y-Shear
The Y-Shear preserves the X coordinates and changes the Y coordinates which causes the
horizontal lines to transform into lines which slopes up or down as shown in the following figure.
Y’ = Y + Shy . X X’ = X
Although shears can in fact be built up out of rotations and scalings if necessary, it is not really
obvious how to do so. A shear will "tilt" objects. A horizontal shear will tilt things towards the left
(for negative shear) or right (for positive shear). A vertical shear tilts them up or down.
3.1.5 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.
The following figures show reflections with respect to X and Y axes, and about the origin
respectively.
Therefore the reflection between the point P(𝑥, 𝑦) and its image 𝑃’(𝑥, 𝑦’)
about x-axis is 𝑥’ = 𝑥, 𝑦’ = −𝑦. Obviously the transformation matrix for the reflection about
x-axis is given by
1 0
[𝑇 ] =
0 −1
𝑥′ 1 0 𝑥
=
𝑦′ 0 −1 𝑦
If 𝑥’ = −𝑦 y’ = −𝑥
x ' 0 1 x
y ' 1 0 y
0 −1
Where is the transformation matrix [𝑇 ] = −𝑋
−1 0
Thus we can infer that unlike in the case of reflection about diagonal axis y=x, in
reflections about the other diagonal y=-x, the co-ordinate values are interchanged with their
signs reversed.The changes of the vertices of triangle ABC to 𝐴’𝐵’𝐶’ are
0 1 2 1 2 3 2 1
1 0 3 2 1 2 1 2
A combined matrix −
Translation
Scaling
Shearing
Rotation
Reflection
The change in the order of transformation would lead to different results, as in general matrix
multiplication is not cumulative, that is [A] . [B] ≠ [B] . [A] and the order of multiplication. The
basic purpose of composing transformations is to gain efficiency by applying a single composed
transformation to a point, rather than applying a series of transformation, one after another.
For example, to rotate an object about an arbitrary point (Xp, Yp), we have to carry out three steps
−
Since, the rotation matrix Rθ is defined only with respect to the origin, we need a set of basic
transformations, which constitutes the composite transformation to compute the rotation about a
given arbitrary point A, denoted by Rθ,A. We can determine the transformation Rθ,A in three
steps:
1) Translate the point A(h,k) to the origin O, so that the center of rotation A is at the origin.
2) Perform the required rotation of θ degrees about the origin, and
3) Translate the origin back to the original position A(h,k).
0
Example: Perform a 45 rotation of a triangle A (0,0), B (1,1), C (5,2) about an arbitrary point
P(–1, –1).
Solution: Given triangle ABC, as show in Figure (a), can be represented in homogeneous
coordinates of vertices as:
[A B C] = 0 0 1
1 1 1
5 2 1
A rotation matrix RQ, about a given arbitrary point A (h, k) is:
cos 𝛳 sin 𝛳 1
−sin 𝛳 cos 𝛳 1
(1 − cos 𝛳) . 𝑗 + 𝑘. sin 𝛳 (1 − cos 𝛳) . 𝑘 − 𝑗. sin 𝛳 1
√ √
0
Thus, R45 = − √ √
0
−1 √2 − 1 1
So the new coordinates [A′B′C′] of the rotated triangle [ABC] can be found as:
√ √
0 −1 √2 − 1 1
[A′B′C′] = [ABC] . R45 = 0 0 1 . −√ √
0 = −1 2√2 − 1 1
1 1 1 3/2. √2 − 1 9/2. √2 − 1 1
5 2 1 −1 √2 − 1 1
The extra coordinate h is known as weight, which is homogeneously applied to the Cartesian
components.
(Here, if we take H=0, then we have point at infinity, i.e., generation of horizons).
Thus all geometric transformation equations can be represented uniformly as matrix
multiplication. Coordinates are represented with three element column, vectors and transformation
operations are written in form of 3 by 3 matrices. For translation transformation (x,y) -->
(x+tx,y+ty) in Euclidian system, where tx and ty are the translation factor in x and y direction,
respectively. Unfortunately, this way of describing translation does not use a matrix, so it cannot
be combined with other transformations by simple matrix multiplication.
Thus, for translation, we now have,
𝑥′ 1 0 𝑡𝑥
𝑦′ = 0 1 𝑡𝑦 OR (x’,y’,1) = (x,y,1) 1 0 0
1 0 0 1 0 1 1
𝑡𝑥 𝑡𝑦 1
and
x ' Sx 0 0 x
y ' 0
Sy 0 y
respectively
1 0 0 1 1
x ' a b 0 x
y ' c d 0 y
1 0 0 1 1
Such a combination would be desirable; for example, we have seen that rotation about an arbitrary
point can be done by a translation, a rotation, and another translation. We would like to be able to
combine these three transformations into a single transformation for the sake of efficiency and
elegance. One way of doing this is to use homogeneous coordinates. In homogeneous coordinates
we use 3x3 matrices instead of 2x2, introducing an additional dummy coordinate H. Instead of
(x,y), each point is represented by a triple (x,y,H) such that H≠0; In two dimensions the value of
H is usually kept at 1 for simplicity.
The advantage of introducing the matrix form of translation is that it simplifies the operations on
complex objects, i.e., we can now build complex transformations by multiplying the basic matrix
transformations.
In other words, we can say, that a sequence of transformation matrices can be concatenated into a
single matrix. This is an effective procedure as it reduces the computation because instead of
applying initial coordinate position of an object to each transformation matrix, we can obtain the
final transformed position of an object by applying composite matrix to the initial coordinate
position of an object. Matrix representation is standard method of implementing transformations
in computer graphics.
Thus, from the point of view of matrix multiplication, with the matrix of translation, the other
basic transformations such as scaling, rotation, reflection, etc., can also be expressed as 3x3
homogeneous coordinate matrices. This can be accomplished by augmenting the 2x2 matrices
with a third row (0,0,x) and a third column. That is 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.
To shorten this process, we have to use 3×3 transformation matrix instead of 2×2 transformation
matrix. To convert a 2×2 matrix to 3×3 matrix, we have to add an extra dummy coordinate W.
In this way, we can represent the point by 3 numbers instead of 2 numbers, which is
called Homogenous Coordinate system. In this system, we can represent all the transformation
equations in matrix multiplication. Any Cartesian point P(X, Y) can be converted to homogenous
coordinates by P’ (Xh, Yh, h).
Y-axis
(𝒙′ , 𝒚′ , 𝒛′)
(𝒙, 𝒚, 𝒛) X-axis
Z-axis
An object is translated in three dimensions by transforming each of the defining points of the
object. For an object represented as a set of polygon surfaces, we translate each vertex of each
surface and redraw the polygon facets in the new position.
We obtain the inverse translation matrix in the above matrix by negating the translation distances
tx, ty and tz. . This produces a translation in the opposite direction and the product of a translation
matrix and its inverse produces the identity matrix.
𝑥’ = 𝑆 . 𝑥
𝑦’ = 𝑆 . 𝑦
𝑧’ = 𝑆 . 𝑧
The equation can be written in the matrix form as:-
𝑥′ 𝑆 0 0 𝑎 𝑥
′ 0 𝑆 0 𝑏 𝑦
𝑦
= ∙
𝑧 ′ 0 0 𝑆 𝑐 𝑧
1 0 0 0 1 1
𝑆 0 0 0
0 𝑆 0 0
Where S=
0 0 𝑆 0
0 0 0 1
Scaling with respect to a selected fixed position (𝑥 , 𝑦 , 𝑧 ) can be represented
with the following transformation sequence:
(1) Translation of the fixed point to the origin.
(2) Scaling of the object related to the coordinate origin.
(3) Translation of the fixed point back to its original position.
𝑇(𝑥 , 𝑦 , 𝑧 ) . 𝑆(𝑆 , 𝑆 , 𝑆 ) . 𝑇(−𝑥 , −𝑦 , −𝑧 )
𝑆 0 0 (1 − 𝑆 )𝑥
⎡ ⎤
0 𝑆 0 (1 − 𝑆 )𝑦
=⎢ ⎥
⎢ 0 0 𝑆 (1 − 𝑆 )𝑧 ⎥
⎣ 0 0 0 1 ⎦
The following figure shows the effect of 3D scaling.
Rotation in three dimensional geometry is more complex than that of two dimensional, because
in this case we consider the angle of rotation and axis of rotation. Therefore, there may be three
cases, when we choose one of the positive 𝑥 − 𝑎𝑥𝑖𝑠 ,𝑦 − 𝑎𝑥𝑖𝑠,𝑧 − 𝑎𝑥𝑖𝑠 , as an axis of rotation.
Y
𝒓
𝜶 θ 𝒑’(𝒙’, 𝒚’𝟎)
𝑷(𝒙, 𝒚, 𝟎)
Z
From the figure : 𝑥’ = 𝑥
𝑦’ = 𝑟𝑐𝑜𝑠(𝛼 + 𝜃) = 𝑟𝑐𝑜𝑠𝛼. 𝑐𝑜𝑠𝜃 − 𝑟𝑠𝑖𝑛𝛼.
𝑠𝑖𝑛ce 𝑟 𝑐𝑜𝑠𝛼 = 𝑦
𝐚𝐧𝐝 𝑟𝑠𝑖𝑛𝛼 = 𝑧
𝐨𝐫, 𝑦 ′ = 𝑦𝑐𝑜𝑠𝜃 − 𝑧𝑠𝑖𝑛𝜃
𝑧 ′ = 𝑟𝑠𝑖𝑛(𝛼 + 𝜃) = 𝑟𝑠𝑖𝑛𝛼 ∙ 𝑐𝑜𝑠𝜃 + 𝑟𝑐𝑜𝑠𝛼 ∙ 𝑠𝑖𝑛𝜃
= 𝑧𝑐𝑜𝑠𝜃 + 𝑦𝑠𝑖𝑛𝜃
𝑥’ = 𝑥
𝐨𝐫 𝑅 , = 𝑦 ′ = 𝑦𝑐𝑜𝑠𝜃 − 𝑧𝑠𝑖𝑛𝜃
𝑧′ = 𝑦𝑠𝑖𝑛𝜃 + 𝑧𝑐𝑜𝑠𝜃
The points after rotation can be calculated by the equation
𝑃′ (𝑥 ′ , 𝑦 ′, 𝑧 ′ ) = 𝑅 , . 𝑃 (𝑥, 𝑦, 𝑧)
When 𝑥’, 𝑦’ 𝑎𝑛𝑑 𝑧’ are defined by the above equation. The above equation
can be written into matrix form as follows.
𝑥′ 1 0 0 0 𝑥
𝑦′ 0 𝑐𝑜𝑠𝜃 − 𝑠𝑖𝑛𝜃 0 𝑦
= ∙
𝑧′ 0 𝑠𝑖𝑛𝜃 𝑐𝑜𝑠𝜃 0 𝑧
1 0 0 0 1 1
b) Rotation about y-axis (i.e. y-axis is the axis of rotation):-
Y
𝑷′ (𝒙′ , 𝟎, 𝒛′)
Rotation about Y-axis
𝑷(𝒙, 𝟎, 𝒛)
θ
X
𝜶
Fig-
𝑥 ′ = 𝑥𝑐𝑜𝑠𝜃 + 𝑧𝑠𝑖𝑛𝜃
Similarly 𝑦′ = 𝑦
𝑧 ′ = −𝑥𝑠𝑖𝑛𝜃 + 𝑧𝑐𝑜𝑠𝜃
𝑐𝑜𝑠𝜃 0 𝑠𝑖𝑛𝜃
𝑅 , = 0 1 0
𝑠𝑖𝑛𝜃 0 𝑐𝑜𝑠𝜃
And the equation in the matrix form,
𝑥′ 𝑐𝑜𝑠𝜃 0 𝑠𝑖𝑛𝜃 0 𝑥
𝑦′ 0 1 0 0 𝑦
= ∙
𝑧 ′ −𝑠𝑖𝑛𝜃 0 𝑐𝑜𝑠𝜃 0 𝑧
1 0 0 0 1 1
𝑷′ (𝒙′ , 𝟎, 𝒛′)
𝑷(𝒙, 𝟎, 𝒛)
𝜽
𝜶 X
Rotation about Z-axis
Z
𝑥 ′ = 𝑥𝑐𝑜𝑠𝜃 − 𝑦𝑠𝑖𝑛𝜃
Similarly 𝑧′ = 𝑧
𝑦 ′ = 𝑧𝑠𝑖𝑛𝜃 + 𝑦𝑐𝑜𝑠𝜃
𝑐𝑜𝑠𝜃 − 𝑠𝑖𝑛𝜃 0
𝑅 , = 𝑠𝑖𝑛𝜃 𝑐𝑜𝑠𝜃 0
0 0 1
And points after rotation are given by the following equation
𝑥′ 𝑐𝑜𝑠𝜃 − 𝑠𝑖𝑛𝜃 0 0 𝑥
𝑦′ 𝑠𝑖𝑛𝜃 𝑐𝑜𝑠𝜃 0 0 𝑦
= ∙
𝑧′ 0 0 1 0 𝑧
1 0 0 0 1 1
Here direction of a positive angle of rotation has been taken in accordance with
the right handed rule with the axis of a rotation.
𝑥′ = 𝑥 + 𝑦
𝑦’ = 𝑦
𝑧’ = 𝑧 + 𝑏𝑦
3.6 SUMMARY
In this chapter, we have concluded that 2D and 3D objects are represented by points and lines that
join them. That is, Transformations can be applied only to the points defining the lines. The Unit
answers the following facts :-
a) How do we represent a geometric object in the plane?
b) How do we transform a geometric object in the plane ?
c) How can we scale an object without moving its origin ?
d) How can we rotate an object without moving its origin ?
UNIT -4
GRAPHICS STANDARDS
4.0 Objective
4.1 Introduction