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

Computer Graphics 1 74

This document provides an introduction to computer graphics, covering its definition, history, applications, and essential components such as hardware and software. It outlines the objectives of understanding computer graphics, its various applications in fields like CAD, scientific visualization, and entertainment, as well as the technical aspects of graphics systems including pixels, input/output devices, and the graphics pipeline. The document serves as a foundational overview for students to grasp the significance and functionality of computer graphics in modern technology.

Uploaded by

anshul.saini1507
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)
30 views74 pages

Computer Graphics 1 74

This document provides an introduction to computer graphics, covering its definition, history, applications, and essential components such as hardware and software. It outlines the objectives of understanding computer graphics, its various applications in fields like CAD, scientific visualization, and entertainment, as well as the technical aspects of graphics systems including pixels, input/output devices, and the graphics pipeline. The document serves as a foundational overview for students to grasp the significance and functionality of computer graphics in modern technology.

Uploaded by

anshul.saini1507
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/ 74

UNIT -1 INTRODUCTION TO COMPUTER GRAPHICS

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.

1.2 HISTORY OF COMPUTER GRAPHICS

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.

YEAR DISCOVERY & FINDINGS


1950 Ben Laposky created the first graphic images, an Oscilloscope, generated by an electronic machine
UNIVAC-I: the first general purpose commercial computer, crude hardcopy devices
1951
MIT – Whirlwind computer, the first to display real time video
1960 William Fetter coins the computer graphics to describe new design methods.
1961 Steve Russel developed Spacewars, the first video/computer game
Douglas Englebart developed first mouse
1963
Ivan Sutherland developed Sketchpad, an interactive CG system
1964 William Fetter developed first computer model of a human figure
1965 Jack Bresenham designed line-drawing algorithm
Tektronix – a special CRT, the direct-view storage tube, with keyboard and mouse
1968
Ivan Sutherland developed first head-mounted display
John Warnock – area subdivision algorithm, hidden-surface algorithms
1969
Bell Labs – first framebuffer containing 3 bits per pixel
1972 Nolan Kay Bushnell – Pong, video arcade game
1973 John Whitney. Jr. and Gary Demos – “Westworld”, first film with computer graphics
Edwin Catmuff –texture mapping and Z-buffer hidden-surface algorithm
1974 James Blinn – curved surfaces, refinement of texture mapping
Phone Bui-Toung – specular highlighting
Martin Newell – famous CG teapot, using Bezier patches
1975
Benoit Mandelbrot – fractal/fractional dimension
1976 James Blinn – environment mapping
1977 Steve Wozniak -- Apple II, color graphics personal computer
1979 Roy Trubshaw and Richard Bartle – MUD, a multi-user dungeon/Zork
Steven Lisberger – “Tron”, first Disney movie which makes extensive use of 3-D graphics
Tom Brighman – “Morphing”, first film sequence plays a female character which deforms
1982 and transforms herself into the shape of a lynx.
John Walkner and Dan Drake
Jaron Lanier – “DataGlove”, a virtual reality film.
1984 Wavefron tech. – Polhemus, first 3D graphics software
Pixar Animation Studios – “Luxo Jr.”, 1989, “ Tin toy”
1985
NES – Nintendo home game system
1987 IBM – VGA, Video Graphics Array introduced
1989 Video Electronics Standards Association (VESA) – SVGA, Super VGA formed
1990 Hanrahan and Lawson – Renderman
Disney and Pixar – “Beauty and the Beast”, CGI was widely used, Renderman systems
1991
with high quality computer effects
1992 Silicon Graphics – OpenGL specification
University of Illinois -- Mosaic, first graphic Web browser
1993
Steven Spielberg – “Jurassic Park” a successful CG fiction film.
1995 Buena Vista Pictures – “Toy Story”, first full-length, computer-generated, feature film
2001 NVIDIA Corporation – GeForce 256, GeForce3
2003 ID Software – Doom3 graphics engine

Table 1 :- Development Lineage in the field of Computer Graphics

1.3 APPLICATIONS OF COMPUTER GRAPHICS


The core elements of computer graphics include the following :-
 Modeling :- Involves representation of choices, geometric processing
 Rendering :- Executes geometric transformation, visibility, implements simulation of light
 Interaction :- Synergy of input/output devices, tools
 Animation :- Simulation of lifelike characters, natural phenomena, their interactions,
surrounding environments
Computer graphics can be broadly divided into the following classes:
 Business Presentation Graphics, which refers to graphics, such as bar-charts, histograms,
pie-charts, pictograms, x-y charts, etc.
 Scientific Graphics, such as x-y plots, curve-fitting, contour plots, system or program
flowcharts etc.
 Cartography (Scaled Drawings), such as architectural representations, drawings of
buildings, bridges, and machines.
 Satellite Imaging − Geodesic images.
 Photo Enhancement − Sharpening blurred photos.
 Medical imaging − MRIs, CAT scans, etc. - Non-invasive internal examination.
 Engineering drawings − mechanical, electrical, civil, Replacing the blueprints of the past.
 Typography − The use of character images in publishing - replacing the hard type of the
past.
 Cartoons and artwork, including advertisements.
 Simulation and modeling − Replacing physical modeling and enactments
 Graphics User Interfaces (GUIs) A graphic, mouse-oriented paradigm which allows the user
to interact with a computer.The images that appear and are designed to help the user utilise
the software without having to refer to manuals or read a lot of text on the monitor.

Fig :- Some Application Areas of Computer Graphics


Computer Graphics is used for a broad spectrum of applications, on a large number of different
graphical devices and some of the main areas of its applications are :-

1.3.1 CAD and CAM processes


CAD is used to design, develop and optimize products, which can be goods used by end consumers
or intermediate goods used in other products. CAD is also extensively used in the design of tools
and machinery used in the manufacture of components, and in the drafting and design of all types
of buildings, as it enables designers to layout and develop work on screen, print it out and save it
for future editing, saving time on their drawings CAD is mainly used for detailed engineering of
3D models and/or 2D drawings of physical components, but it is also used throughout the
engineering process from conceptual design and layout of products, through strength and dynamic
analysis of assemblies to definition of manufacturing methods of components.

Fig:- The Process of Computer Aided Design

Fig :- Gear Shaft Design Bench mark Bimodal Function


A CAM or Computer-Aided Manufacturing system usually seeks to assist and control the
production process through varying degrees of automation. Because each of the many
manufacturing processes in a CAM system is computer controlled, a high degree of precision can
be achieved that is not possible with a human interface. The CAM system, for example, sets the
tool path and executes precision machine
operations based on the imported design. Another advantage of Computer Aided Manufacturing
is that it can be used to facilitate mass customization: the process of creating small batches of
products that are custom designed to suit each particular client. Without CAM, and the CAD
process that precedes it, customization would be a time-consuming, manual and costly process.
However, CAD software allows for easy customization and rapid design changes: the automatic
controls of the CAM system make it possible to adjust the machinery automatically for each
different order.

Fig :- The Computer Aided Manufacturing Process

1.3.2 Scientific Visualisation

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.

Fig : Visualization in areas of Car Crash, Jurassic Park, Volcano eruption

1.3.3 Entertainment and Photorealism

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.

1.3.4 Medical Content Creation

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 : Graphic Representation of a foetus in the womb

1.4 GRAPHICS PACKAGE


A computer graphics system is a computer system which must have all the components of a
general-purpose computer system. Considering the high-level view of a graphics system, there are
six major elements in the Graphics system:
1. Input devices
2. Central Processing Unit
3. Graphics Processing Unit
4. Memory
5. Frame buffer
6. Output devices
This model is general enough to include workstations and personal computers, interactive game
systems, mobile phones, GPS systems, and sophisticated image generation systems. Although
most of the components are present in a standard computer, it is the way each element is specialized
for computer graphics that characterizes this diagram as a portrait of a graphics system.

Fig : A Graphics System


1.4.1 Pixels and the Frame Buffer
Virtually all modern graphics systems are raster based. The image we see on the output device is
an array—the raster—of picture elements, or pixels, produced by the graphics system.
An image that is presented on the computer screen is made up of pixels. The screen consists of a
rectangular grid of pixels, arranged in rows and columns. The pixels are small enough that they
are not easy to see individually. At a given time, each pixel can show only one color. Most screens
these days use 24-bit color, where a color can be specified by three 8-bit numbers, giving the levels
of red, green, and blue in the color. Any color that can be shown on the screen is made up of some
combination of these three “primary” colors. Other formats are possible, such as grayscale, where
each pixel is some shade of gray and the pixel color is given by one number that specifies the level
of gray on a black-to-white scale. Typically, 256 shades of gray are used. Early computer screens
used indexed color, where only a small set of colors, usually 16 or 256, could be displayed. The
color values for all the pixels on the screen are stored in a large block of memory known as a frame
buffer. Changing the image on the screen requires changing color values that are stored in the
frame buffer. The screen is redrawn many times per second, so that almost immediately after the
color values are changed in the frame buffer, the colors of the pixels on the screen will be changed
to match, and the displayed image will change. Its resolution—the number of pixels in the frame
buffer—determines the detail that you can see in the image. The depth, or precision, of the frame
buffer, defined as the number of bits that are used for each pixel, determines properties such as
how many colors can be represented on a given system. For example, a 1-bit-deep frame buffer
allows only two colors, whereas an 8-bit-deep frame buffer allows 28 (256) colors. In full-color
systems, there are 24 (or more) bits per pixel. Such systems can display sufficient colors to
represent most images realistically. They are also called true-color systems, or RGB-color
systems, because individual groups of bits in each pixel are assigned to each of the three primary
colors—red, green, and blue—used in most displays. High dynamic range (HDR) systems use
12
or more bits for each color component. Until recently, frame buffers stored colors in integer
formats. Recent frame buffers use floating point and thus support HDR colors more easily.
Fig :- The Relation between Resolution, Pixels and Aspect Ratio of a Graphical Device

1.4.2 Input Devices


Most graphics systems provide a keyboard and at least one other input device. The most common
input devices are the mouse, the joystick, and the data tablet. Each provides positional information
to the system, and each usually is equipped with one or more buttons to provide signals to the
processor. Often called pointing devices, these devices allow a user to indicate a particular
location on the display. Some commercial input devices used in Graphics System are
• 2D mice
• Scanners
• Light Pens
• Digitizers
• Digital Camera
• Video Camera
• Touch-sensitive screens
• Joysticks
• Trackballs
• Thumb wheels
• Microphones (voice data entry)
• Touch Panels
The keyboard device is a device that returns character codes. We use the American Standard Code
for Information Interchange (ASCII) in our examples. ASCII assigns a single unsigned byte to
each character. However in Internet applications, multiple bytes were used for each character, thus
allowing for a much richer set of supported characters.
Touch Panels allow displayed object or screen positions to be selected with the touch of the finger
and is also known as Touch Sensitive Screens (TSS). A typical application of touch panels is for
the selection of processing options that are represented with graphical icons. Touch input can be
recorded using optical electrical or acoustical methods.
Optical touch panels employ a line of intra red LEDS (light emitting diodes) along one vertical
edge and along one horizontal edge of frame. The opposite vertical and horizontal edges contain
light detection which are used to record the beams that may have been interrupted when the panel
was touched.
An electrical touch panel is constructed with two transparent plates separated by a short distance.
One of the plates is coated with a conducting material and the other is resistive material. When the
outer plate is touched, it is forced into contact with the inner plate. The contact creates a voltage
drop that is converted to a coordinate value of the selected screen position. They are not too reliable
or accurate, but are easy to use.

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.

1.4.3 Output Devices


One of the common physical output devices for display (or monitor) was the cathode-ray tube
(CRT). A simplified picture of a CRT is shown in figure below which shows the working principle
of CRT. When electrons strike the phosphor coating on the tube, light is emitted. The direction of
the beam is controlled by two pairs of deflection plates. The output of the computer is converted,
by digital to-analog converters, to voltages across the x and y deflection plates. Light appears on
the surface of the CRT when a sufficiently intense beam of electrons is directed at the phosphor.

Fig : The Working Principle of a Cathode Ray Tube


A computer screen used in this way is the basic model of raster graphics. The term “raster”
technically refers to the mechanism used on older vacuum tube computer monitors: An electron
beam would move along the rows of pixels, making them glow. The beam was moved across the
screen by powerful magnets that would deflect the path of the electrons. The stronger the beam,
the brighter the glow of the pixel, so the brightness of the pixels could be controlled by modulating
the intensity of the electron beam. The color values stored in the frame buffer were used to
determine the intensity of the electron beam. The idea of an image consisting of a grid of pixels,
with numerical color values for each pixel, defines raster graphics in a modern flat screen too.

The performance parameters of a monitor are:


 Luminance, measured in candelas per square metre (cd/m²).
 Size, measured diagonally. For CRT the viewable size is one inch (25 mm) smaller than the
tube itself.
 Dot pitch,describes the distance between pixels of the same color in millimetres. In general, the
lower the dot pitch (e.g. 0.24 mm, which is also 240 micrometres), the sharper the picture.
 Response time. The amount of time a pixel in an LCD monitor takes to go from active (black)
to inactive (white) and back to active (black) again. It is measured in milliseconds (ms). Lower
numbers mean faster transitions and therefore fewer visible image artifacts.
 Refresh rate. The number of times in a second that a display is illuminated.
 Power consumption, measured in watts (W).
 Aspect ratio, which is the horizontal size compared to the vertical size, e.g. 4:3 is the standard
aspect ratio, so that a screen with a width of 1024 pixels will have a height of 768 pixels.
Display resolution. The number of distinct pixels in each dimension that can be displayed.

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)

Display systems use either random or raster scan:


Random scan displays, often termed vector displays, came first and are still used in some
applications. Here the electron gun of a CRT illuminates points and/or straight lines in any order.
The display processor repeatedly reads a variable 'display file' defining a sequence of X,Y
coordinate pairs and brightness or colour values, and converts these to voltages controlling the
electron gun. In a Random Scan System, the Display buffer stores the picture information.
Further, the device is capable of producing pictures made up of lines but not of curves. Thus, it is
also known as “Vector display device or Line display device or Calligraphic display device”.

Fig : A Random Scan Display (……. Beam off;____ Beam on)

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.

Fig :- Horizontal and Vertical Retrace in a non-Interlaced Raster Display


Color CRTs have three different colored phosphors (red, green, and blue), arranged in small groups
like in triangular groups called triads, each triad consisting of three phosphors. In the shadow-
mask CRT , a metal screen with small holes—the shadow mask—ensures that an electron beam
excites only phosphors of the proper color.
Fig :- A Shadow-Mask CRT
Although CRTs are still common display devices, they are rapidly being replaced by flat-screen
technologies. Flat-panel monitors are inherently raster based. Although there are multiple
technologies available, including light-emitting diodes (LEDs), liquid-crystal displays (LCDs),
and plasma panels, all use a two-dimensional grid to address individual light-emitting elements.
The two outside plates each contain parallel grids of wires that are oriented perpendicular to each
other. By sending electrical signals to the proper wire in each grid, the electrical field at a location,
determined by the intersection of two wires, can be made strong enough to control the
corresponding element in the middle plate. The middle plate in an LED panel contains light-
emitting diodes that can be turned on and off by the electrical signals sent to the grid. In an LCD
display, the electrical field controls the polarization of the liquid crystals in the middle panel, thus
turning on and off the light passing through the panel. A plasma panel uses the voltages on the
grids to energize gases embedded between the glass panels holding the grids. The energized gas
becomes a glowing plasma.

Fig :- A Generic Flat-Panel Display


Plotter: A plotter is a vector graphics-printing device that connects to a computer. Now-a-days,
we use the plotter right from the field of engineering, to media and advertising. Even in our day-
to-day lives we see a large number of computer designed hoardings and kiosks as publicity
material. This fine output is achieved byusing plotters with computers.
Fig : A Drum Plotter

1.4.4 The CPU and the GPU

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.

Fig : The Graphic Processor Architecture


1.4.5 The Graphics Pipeline

Fig :- The :Pipeline Architecture of Graphics Package

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:

1) Graphics Image Processing: Software used : Photoshop.


• Most common image processing software.
• Focuses on creating a pretty picture.
• Usually limited to popular graphics formats such as: TIFF, JPEG, GIF
• Best suited for working with RGB (3-band) images.
• Does not treat an image as a “map”.

2) Geographic Information Systems (GIS): Software used : ArcMap


• Works within a geographic context.
• Great for overlaying multiple vector and raster layers.
• More common than remote sensing software.

3) Remote Sensing Packages: Software used: ERDAS


• Best suited for satellite imagery.
• Uses geo-spatial information.
• Easily works with multi-spectral data.
• Provides analysis functions commonly used for remote sensing applications.
• Often easy to use but it helps to be familiar with remote sensing.

4) Numerical Analysis Packages: Software used: Matlab.
• Focus usually on numeric processing.
• Programming or mathematical skills usually helpful.
• Used to build more user-friendly applications.

5) Web-based Services: Software used : Protected Area Archive.


• Image display, roam, zoom.
• Image enhancement.
• Simple image processing.
• Distance and area measurement.
• Comparison of old and new images.
• Image annotation (adding text, lines, etc).
• Overlaying vector layers.

6) Computer Aided Design and Drafting (CADD): Software used: AutoCad,SolidWorks


CAD/CAM software uses CAD drawing tools to describe geometries used by the CAM portion of
the program to define a tool path that will direct the motion of a machine tool to machine the exact
shape that is to be drawn on the computer. Now-a-days many new machine tools incorporate CNC
technologies. These tools are used in every conceivable manufacturing sector, like CNC
technology is related to Computer Integrated Manufacturing (CIM), Computer Aided Process
Planning (CAPP) and other technologies such as Group Technology (GT) and Cellular
Manufacturing. Flexible Manufacturing Systems (FMS) and Just-In- Time Production (JIT) are
made possible by Numerically-Controlled Machines.

1.5 NUMERICAL EXAMPLES


1. Consider a raster system with resolution 1280 x 1024 and 2560 x 2048. What size frame
buffer (in bytes) is needed for the system to store 12 bits/pixel? How much storage is
required for each system if 24 bits per pixel are to be stored?
Solution :
Frame-buffer size for the system is
1280 × 1024 × 12 bits ÷ 8 bits per byte = 1920 KB
2560 × 2048 × 12 bits ÷ 8 bits per byte = 7680 KB
For 24 bits of storage per pixel, each of the above values is doubled.
2. Consider a raster system with the resolution of 1024 x 768 pixels and the color palette calls
for 65,536 colors. What is the minimum amount of video RAM that the computer must have
to support the above-mentioned resolution and number of colors?
Solution :-
Recall that the color of each pixel on a display is represented with some number of bits.
Hence, a display capable of showing up to 256 colors is using 8 bits per pixels (i.e. “8-bit
color”). Notice first that the color palette calls for 65,536 colors. This number is but 216 ,
which implies that 16 bits are being used to represent the color of each pixel on the display.
The display’s resolution is 1024 by 768 pixels, which implies that there is a total of 786,432
(1024 × 768) pixels on the display. Hence, the total number of bits required to display any
of 65,536 colors on each of the screen’s 786,432 pixels is 12,582,912 (786,432 × 16).
Dividing this value by 8 yields an answer of 1,572,864 bytes. Dividing that value by 1,024
yields an answer of 1,536 KB. Dividing that value by 1,024 yields an answer of 1.5 MB.

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

1.7 QUESTIONS FOR EXERCISE


1) Discuss about the application of computer graphics in entertainment.
2) Discuss about the application of computer graphics in visualization.
3) What do you mean by interactive computer Graphics?
4) Define persistence,Resolution, Aspect Ratio,Frame Buffer.
5) What do you mean by retracing? Define horizontal as well as vertical retracing?
6) Consider three different raster systems with resolutions of 640 x 480, 1280 x 1024 and
2560 x 2048. What size is frame buffer (in bytes) for each of these systems to store 12 bits per
pixel? How many pixels could be accessed per second in each of these systems by a display
controller that refreshes the screen at a rate of 60 frames per second?
Hint : 640 x 480 x 12 bits / 8 = 450KB ; (640 x 480) * 60 = 1.8432 x 107 pixels/second.
7) What is the size of a pixel on a 21-inch diagonal screen with physical aspect ratio 8:5
operating in 1152 x 800 mode?

1.8 SUGGESTED READINGS


William M. Newman, Robert F. Sproull, “Principles of InteractiveComputer Graphics”, Tata-
McGraw Hill, 2000
Donald Hearn, M. Pauline Baker, “Computer Graphics – C Version”, Pearson Education, 2007
Chapter 1, 2, 3 of ISRD Group, “Computer Graphics”, McGraw Hill, 2006

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

UNIT -2 GRAPHICS TECHNIQUES


UNIT STRUCTURE

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

Fig :- Pixel representation of point primitive


Primitive operations involved in C or OpenGL are :
• setpixel(x, y, color) : Sets the pixel at position (x, y) to the given color.
• getpixel(x, y) :Gets the color at the pixel at position (x, y).

2.2 Line Drawing


A line connects two points.Line drawing is accomplished by calculating the intermediate point
coordinates along the line path between two given end points. Since, screen pixels are referred
with integer values, plotted positions may only approximate the calculated coordinates – i.e., pixels
which are intensified are those which lie very close to the line path if not exactly on the line path
which is in the case of perfectly horizontal, vertical or 45° lines only. Standard algorithms are
available to determine which pixels provide the best approximation to the desired line.
The explicit equation for a line is y = mx + b.
The Basic Line Drawing Algorithm involves the following steps
Step 1 : Set the color of pixels to approximate the appearance of a line from (x0, y0) to (x1,
y1).

Step 2 : Subtract y0 from y1 to solve for m = (y1-y0)/(x1-x0) and b = y0 − mx0.


Step 3 : Substituting in the value for b, this equation can be written as y = m(x − x0) + y0.
Fig : Slope m of the Straight line < 1

2.2.1 Digital Differential Analyzer


Digital Differential Analyzer (DDA) algorithm is the simple line generation algorithm which is
explained step by step here.

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.

if (absolute(dx) > absolute(dy))


Steps = absolute(dx);
else
Steps = absolute(dy);

Step 4 − Calculate the increment in x coordinate and y coordinate.

Xincrement = dx / (float) steps;


Yincrement = dy / (float) steps;

Step 5 − Put the pixel by successfully incrementing x and y coordinates accordingly and complete
the drawing of the line.

for(int v=0; v < Steps; v++)


{
x = x + Xincrement;
y = y + Yincrement;
putpixel(Round(x), Round(y));
}

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

= 5/7 i.e., 0 < m < 1


Thus updated pixel values are :- xi + 1 = xi + 1 yi + 1 = yi + m
given (x0, y0) = (2, 4)
1) x1 = x0 + 1 = 3 and y1 = y0 + m = 4 + 5/7 = 4.71
So, put pixel (x1, round( y1), colour)
i.e., put on (3, 5)
2) x2 = x1 + 1 = 3 + 1 = 4
y2 = y1 + m = (33/7) + 5/7 = 38/7=5.428
i.e. put on (4, 5)
Similarly go on till (9, 9) is reached.
Drawbacks of DDA :
 Floating point values (m,y)
 Round operation
 Special cases m = 0 or infinity

2.2.2 Bresenham’s Line Generation


The Bresenham algorithm is another incremental scan conversion algorithm. It is an accurate and
efficient raster line generation algorithm. This algorithm scan converts lines using only
incremental integer calculations which is a big advantage of this algorithm and these calculations
can also be adopted to display circles and other curves moving across the x axis in unit intervals
and at each step choose between two different y coordinates.

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

2.3 Circle Drawing Algorithm

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).

Fig :- Circle Generation Algorithm with polar coordinates


By calculating the polar coordinates r and θ where
x = xc + r cos θ
y = yc + r sin θ
Thus, an efficient approach based on incremental calculations of decision parameter is employed
for circle generation. . There are two popular algorithms for generating a circle − Bresenham’s
Algorithm and Midpoint Circle Algorithm. These algorithms are based on the idea of
determining the subsequent points required to draw the circle. For a given radius and center
position (x, y,) we first setup our algorithm to calculate pixel position around the path of circle
centered at coordinate origin (0, 0) i.e., we translate
(xc, yc) → (0, 0) and after the generation we do inverse translation (0, 0) → (xc, yc)
hence each calculated position (x, y) of circumference is moved to its proper screen position by
adding xc to x and yc to y.

2.3.1 Bresenham’s Circle Generation


Here, the decision parameter d is used to rasterize the next point on the circle.
 If d <= 0, then N(X+1, Y) is to be chosen as next pixel.
 If d > 0, then S(X+1, Y-1) is to be chosen as the next pixel.
Step 1 − Get the coordinates of the center of the circle and radius, and store them in x, y, and R
respectively. Set P=0 and Q=R.
Step 2 − Set decision parameter D = 3 – 2R.
Step 3 − Repeat through step-8 while X < Y.
Step 4 − Call Draw Circle (X, Y, P, Q).
Step 5 − Increment the value of P.
Step 6 − If D < 0 then D = D + 4x + 6.
Step 7 − Else Set Y = Y + 1, D = D + 4(X-Y) + 10.
Step 8 − Call Draw Circle (X, Y, P, Q).

Figure : Quadrant end-points of drawing the circle


Draw Circle Method(X, Y, P, Q).
Call Putpixel (X + P, Y + Q).
Call Putpixel (X - P, Y + Q).
Call Putpixel (X + P, Y - Q).
Call Putpixel (X - P, Y - Q).
Call Putpixel (X + Q, Y + X).
Call Putpixel (X - Q, Y + X).
Call Putpixel (X + Q, Y - X).
Call Putpixel (X - Q, Y - X).

2.3.2 Mid-Point Circle Generation


Step 1 − Input radius r and circle center (xc,yc) and obtain the first point on the circumference of
the circle centered on the origin as

(x0, y0) = (0, r)

Step 2 − Calculate the initial value of decision parameter as


P0P0 = 5/4 – r (See the following description for simplification of this equation.)

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

Let di = f(xi - 1/2, yi + 1) = -2(xi - 1/2)e - e2


Thus,
If e < 0 then di > 0 so choose point S = (xi - 1, yi + 1).
di+1 = f(xi - 1 - 1/2, yi + 1 + 1) = ((xi - 1/2) - 1)2 + ((yi + 1) + 1)2 - r2
= di - 2(xi - 1) + 2(yi + 1) + 1
= di + 2(yi + 1 - xi + 1) + 1

If e >= 0 then di <= 0 so choose point T = (xi, yi + 1)


di+1 = f(xi - 1/2, yi + 1 + 1)
= di + 2yi+1 + 1

The initial value of di is


d0 = f(r - 1/2, 0 + 1) = (r - 1/2)2 + 12 - r2
= 5/4 - r {1-r can be used if r is an integer}

When point S = (xi - 1, yi + 1) is chosen then


di+1 = di + -2xi+1 + 2yi+1 + 1

When point T = (xi, yi + 1) is chosen then


di+1 = di + 2yi+1 + 1

Step 3 − At each XK position starting at K=0, perform the following test −

If PK < 0 then next point on circle (0,0) is (XK+1,YK) and


PK+1 = PK + 2XK+1 + 1
Else
PK+1 = PK + 2XK+1 + 1 – 2YK+1

Where, 2XK+1 = 2XK+2 and 2YK+1 = 2YK-2.

Step 4 − Determine the symmetry points in other seven octants.


Step 5 − Move each calculate pixel position (X, Y) onto the circular path centered on (XC,YC)
and plot the coordinate values.

X = X + XC, Y = Y + YC

Step 6 − Repeat step-3 through 5 until X >= Y.

2.4 Polygon Filling Techniques


Polygon A polygon can be defined as an ordered list of vertices that is formed by line segments
that are placed end to end, creating a continuous closed path. Polygons can be divided into three
basic types: convex, concave, and complex.
Types of Polygons
Regular - all angles are equal and all sides are the same length. Regular polygons are both
equiangular and equilateral.
Equiangular - all angles are equal.
Equilateral - all sides are the same length.
Convex - a straight line drawn through a convex polygon crosses at most two sides. Every interior
angle is less than 180°. Convex polygons are the simplest type of polygon to fill.
Concave - you can draw at least one straight line through a concave polygon that crosses more
than two sides. At least one interior angle is more than 180°.
Polygon Formulas
(N = # of sides and S = length from center to a corner)
Area of a regular polygon = (1/2) N sin(360°/N) S2
Sum of the interior angles of a polygon = (N - 2) x 180°
The number of diagonals in a polygon = 1/2 N *(N-3)
In order to fill a polygon, we do not want to have to determine the type of polygon that we are filling.
The easiest way to avoid this situation is to use an algorithm that works for all three types of polygons.
Since both convex and concave polygons are subsets of the complex type, using an algorithm that will
work for complex polygon filling should be sufficient for all three types.
For filling polygons with particular colors, you need to determine the pixels falling on the border
of the polygon and those which fall inside the polygon. There are two basic approaches to filling
on raster systems. One way is Line Filling approach which is adopted later in area filling method
by drawing straight lines between the edges of polygon called scan-line polygon filling. Second
way is to start from an interior point and paint outward from this point till we reach the boundary
called boundary-fill. A slight variation of this technique is used to fill an area specified by cluster
(having no specific boundary). The technique is called flood-fill and having almost same strategy
that is to start from an interior point and start painting outward from this point till the end of cluster.
Now having an idea we will try to see each of these one by one, starting from scan-line polygon
filling.

2.4.1 Scan Line Algorithm


What is a scan-line?
A scan-line is a line of constant y value, i.e., y=c, where c lies within our drawing
region, e.g., the window on our computer screen.
This algorithm works by intersecting scanline with polygon edges and fills the polygon between
pairs of intersections. The following steps depict how this algorithm works.
Step 1 − Find out the Ymin and Ymax from the given polygon.

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.

2.4.2 Boundary Fill Algorithm


Another important class of area-filling algorithms starts at a point known to be inside a figure and
starts filling in the figure outward from the point. Using these algorithms a graphic artist may
sketch the outline of a figure and then select a color or pattern with which to fill it. The actual
filling process begins when a point inside the figure is selected. These routines are like the paint-
scan function seen in common interactive paint packages.
The boundary-fill method requires the coordinates of a starting point, a fill color, and a boundary
color as arguments.
The Boundary fill algorithm performs the following steps:
Check the pixel for boundary color
Check the pixel for fill color
Set the pixel in fill color
Run the process for neighbors Process of Boundary Fill Algorithm
BOUNDARY FILL PSEUDOCODE:-
boundaryFill (x, y, fillColor, boundaryColor)
if ((x < 0) || (x >= width)) return
if ((y < 0) || (y >= height)) return

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.

2.4.3 Flood Fill Algorithm


Sometimes we come across an object where we want to fill the area and its boundary with
different colors. We can paint such objects with a specified interior color instead of searching for
particular boundary color as in boundary filling algorithm.
Instead of relying on the boundary of the object, it relies on the fill color. In other words, it
replaces the interior color of the object with the fill color. When no more pixels of the original
interior color exist, the algorithm is completed.
Once again, this algorithm relies on the Four-connect or Eight-connect method of filling in the
pixels. But instead of looking for the boundary color, it is looking for all adjacent pixels that are
a part of the interior.
In this algorithm, we assume that color of the boundary is same for the entire object. The boundary
fill algorithm can be implemented by 4-connected pixels or 8-connected pixels.
4-Connected Polygon
In this technique 4-connected pixels are used as shown in the figure. We are putting the pixels
above, below, to the right, and to the left side of the current pixels and this process will continue
until we find a boundary with different color.

4- Connected Boundary Fill Algorithm


Step 1 − Initialize the value of seed point (seedx, seedy), fcolor and dcol.
Step 2 − Define the boundary values of the polygon.
Step 3 − Check if the current seed point is of default color, then repeat the steps 4 and 5 till the
boundary pixels reached.

If getpixel(x, y) = dcol then repeat step 4 and 5

Step 4 − Change the default color with the fill color at the seed point.

setPixel(seedx, seedy, fcol)


Step 5 − Recursively follow the procedure with four neighborhood points.

FloodFill (seedx – 1, seedy, fcol, dcol)


FloodFill (seedx + 1, seedy, fcol, dcol)
FloodFill (seedx, seedy - 1, fcol, dcol)
FloodFill (seedx – 1, seedy + 1, fcol, dcol)

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.

8- Connected Boundary Fill Algorithm


Step 1 − Initialize the value of seed point (seedx, seedy), fcolor and dcol.
Step 2 − Define the boundary values of the polygon.
Step 3 − Check if the current seed point is of default color then repeat the steps 4 and 5 till the
boundary pixels reached

If getpixel(x,y) = dcol then repeat step 4 and 5

Step 4 − Change the default color with the fill color at the seed point.

setPixel(seedx, seedy, fcol)

Step 5 − Recursively follow the procedure with four neighbourhood points

FloodFill (seedx – 1, seedy, fcol, dcol)


FloodFill (seedx + 1, seedy, fcol, dcol)
FloodFill (seedx, seedy - 1, fcol, dcol)
FloodFill (seedx, seedy + 1, fcol, dcol)
FloodFill (seedx – 1, seedy + 1, fcol, dcol)
FloodFill (seedx + 1, seedy + 1, fcol, dcol)
FloodFill (seedx + 1, seedy - 1, fcol, dcol)
FloodFill (seedx – 1, seedy - 1, fcol, dcol)

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.

2.5 Clipping Methods

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

2.5.1 Cohen Sutherland Line Clipping


The clipping problem is simplified by dividing the area surrounding the window region into four
segments Up, Down, Left, Right (U,D,L,R) and assignment of number 1 and 0 to respective
segments helps in positioning the region surrounding the window. How this positioning of regions
is performed can be well understood by considering the Figure below.

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.

There are 3 possibilities for the line −

 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 − Else you need clipping.

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.

Step 4 − Repeat step 1 for other lines.

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.

2.5.2 Cyrus-Beck Line Clipping Algorithm

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.

Parametric equation of line is −

P0P1:P(t) = P0 + t(P1 - P0)

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.

The point P(t) is inside if Ni.[P(t) – PEi] < 0


The point P(t) is outside if Ni.[P(t) – PEi] > 0

The point P(t) is on the edge if Ni.[P(t) – PEi] = 0 (Intersection point)

Ni.[P(t) – PEi] = 0

Ni.[ P0 + t(P1 - P0) – PEi] = 0 (Replacing P(t) with P0 + t(P1 - P0))

Ni.[P0 – PEi] + Ni.t[P1 - P0] = 0

Ni.[P0 – PEi] + Ni∙tD = 0 (substituting D for [P1 - P0])

Ni.[P0 – PEi] = - Ni∙tD

The equation for t becomes,

t=Ni.[Po−PEi]−Ni.Dt=Ni.[Po−PEi]−Ni.D

It is valid for the following conditions −

 Ni ≠ 0 (error cannot happen)

 D ≠ 0 (P1 ≠ P0)

 Ni∙D ≠ 0 (P0P1 not parallel to Ei)

2.5.3 Polygon Clipping (Sutherland Hodgman Algorithm)

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 −

 All or none string clipping

 All or none character clipping

 Text clipping

The following figure shows all or none string 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.

The following figure shows all or none character clipping −

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.

2.6 Windowport-to-Viewport mapping

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.

A window-to-viewport mapping can be expressed by the following relationships,


based on elements shown
Any window can be specified by any four co-ordinates i.e. Wxmin, Wxmax, Wymin and Wymax
and similarly a viewport can be represented by four normalized co-ordinates i.e. Vxmin, Vxmax,
Vymin and Vymax viewing transformation of any point let W(Wx, Wy), can be implemented
using following equation. If normalized co-ordinates are V(Vx, Vy)
then =

𝑊 −𝑊 𝑉 −𝑉
𝑎𝑛𝑑 =
𝑊 −𝑊 𝑉 −𝑉
𝑉 −𝑉
𝑜𝑟 , 𝑉 = (𝑊 − 𝑊 )+𝑉
𝑊 −𝑊
𝑉 −𝑉
𝑉 = 𝑊 −𝑊 +𝑉
𝑊 −𝑊
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.

2.8 QUESTIONS FOR EXERCISE


1) Compare Bresenham line generation with DDA line generation.
2) Illustrate the Bresenham line generation algorithm by digitising the line with end points
(15, 5) and (25,13).
3) Given a circle radius r = 5 determine positions along the circle octants in 1st Quadrant from
x = 0 to x = y?
4) Distinguish between Scan line polygon fill and Seed fill or Flood fill algorithm?
5) A clipping window is given by P0(10,10), P1(20,10), P2(10,20), P3(20,20). Using Cyrus Beck
algorithm clip the line A(0,0) and B(15,25)
6) Compare Cohen Sutherland Line clipping with Cyrus Beck Line clipping algorithm?
7) For a window A(100, 10), B(160, 10, C(160, 40), D(100, 40). Using Sutherland-Cohen clipping
algorithm find the visible portion of the line segments EF, GH and P1P2. E(50,0),
F(70,80), G(120, 20), H(140, 80), P1(120, 5), P2(180, 30).
2.9 SUGGESTED READINGS
 Computer Graphics: Principles and Practice, 4th Edition
 Computer Graphics, C Version, 2nd Edition Fundamentals of Computer Graphics, 3rd Edition
 Interactive Computer Graphics: A Top-Down Approach with Shader-Based OpenGL, 6th ed.
 3D Computer Graphics: A Mathematical Introduction with OpenG
UNIT -3

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.

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:
• 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
The appearance of the generated surface depends on the number of instances of the transformation.
Basically there are two categories of transformation:-

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

coordinates of new position can be obtained by the application of Geometric Transformation.

ii.Co-ordinate Transformation:- When object itself relative to a stationary co-ordinate system

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

then this process is termed as co-ordinate transformation.

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’).

From the above figure, you can write that −

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=[X][Y]P=[X][Y] P' = [X′][Y′] and T = [tx][ty]


We can write it as −

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

Translation of a line in X and Y-direction

Example1: Translate a square ABCD with the coordinates A(0,0),B(5,0),C(5,5),D(0,5) by 2


units in x-direction and 3 units in y-direction.
Hint : We can represent the given square, in matrix form, using homogeneous coordinates of
vertices as :-
𝑥1 𝑦1 1 0 0 1
𝑥2 𝑦2 1 = 5 0 1
𝑥3 𝑦3 1 5 5 1

The translation factors are, tx=2, ty=3


The transformation matrix for translation :
1 0 0 1 0 0
Tx = 0 1 0 = 0 1 0
𝑡𝑥 𝑡𝑦 1 2 3 1
New object point coordinates are:
[A’B’C’D’] = [ABCD].Tx

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θ

Where R is the rotation matrix

The rotation angle can be positive and negative.


For positive rotation angle, we can use the above rotation matrix. However, for negative angle
rotation, that is for Clockwise rotation we have to put θ = – θ, thus the rotation matrix Rθ

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

𝑥ꞌ = 𝑆 . 𝑥

𝑦ꞌ = 𝑆 . 𝑦

Matrix equation of a non-uniform scaling has the form:


𝑥 𝑆 0 𝑥
⇨ = 0 𝑆 𝑦
𝑦′
where, sx, sy are the scale factors for the x and y coordinates of the object.
That is, if a point (x,y) is scaled by a factor of a in the x direction and by a factor of d in the y
direction, then the resulting point (x1,y1) is given by
x1 = a * x
y1 = d * y
If you apply this transform to a shape that is centered at the origin, it will stretch the shape by a
factor of a horizontally and d vertically.

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.

Y Pꞌꞌ (16, 20)


P (4, 5) Pꞌ (8, 10)

Q (4, 2) Qꞌ (8, 4) Qꞌ(16, 8)

X
Fig: Scaling Transformation of a Line

Line PQ be scaled to PꞌQꞌ when Sx=Sy=0.5 and to PꞌꞌQꞌꞌ when Sx=Sy=2


Obviously
1
0
𝑥 2 8 4
= =
𝑦 1 4 2
0
2
Thus 𝑄ꞌ = (4, 2)
Similarly 𝑃ꞌ = (4, 5)
when 𝑆 = 𝑆 = 0.5

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.

The Y-Shear can be represented in matrix from as –


1 𝑏 0
0 1 1
0 0 1

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

And the transformation is represented as

𝑥′ 1 0 𝑥
=
𝑦′ 0 −1 𝑦

i.e. [𝒙′] = [𝑻𝒎 ]y=0 [𝒙]

A reflection about y-axis flips x coordinates while y coordinates remains the


same.
Reflection about the Straight line Y= -X
Fig-3.21

If 𝑥’ = −𝑦 y’ = −𝑥

This can be represented by

 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 
    

3.2 Composite Transformation


We have seen the basic matrix transformations for translation, rotation, reflection, scaling and
shearing with respect to the origin of the coordinate system. By multiplying these basic matrix
transformations, we can build complex transformations, such as rotation about an arbitrary point,
mirror reflection about a line etc. This process is called concatenation of matrices and the resulting
matrix is often referred to as the composite transformation matrix. Inverse transformations play
an important role when you are dealing with composite transformation. They come to the rescue
of basic transformations by making them applicable during the construction of composite
transformation. You can observed that the Inverse transformations for translation, rotation,
reflection, scaling and shearing have the following relations, and v, θ, a, b, sx, sy, sz are all
parameter involved in the transformations. If a transformation of the plane T1 is followed by a
second plane transformation T2, then the result itself may be represented by a single
transformation T which is the composition of T1 and T2 taken in that order. This is written as T
= T1∙T2.

Composite transformation can be achieved by concatenation of transformation matrices to obtain


a combined transformation matrix.

A combined matrix −

[T][X] = [X] [T1] [T2] [T3] [T4] …. [Tn]

Where [Ti] is any combination of

 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

 Translate point (Xp, Yp) to the origin.

 Rotate it about the origin.

 Finally, translate the center of rotation back where it belonged.


Example : Given a 2-D point P(x,y), which we want to rotate, with respect to an arbitrary
point A(h,k).Let P’(x’y’) be the result of anticlockwise rotation of point P by angle θ about A

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

3.3 Homogenous Coordinate Systems


Let P(x,y) be any point in 2-D Euclidean (Cartesian) system. In Homogeneous Coordinate system,
we add a third coordinate to a point. Instead of (x,y), each point is represented by a triple (x,y,H)
such that H≠0; with the condition that
(x1,y1,H1)=(x2,y2,H2) ↔ x1/H1 = x2/H2 ; y1/H1 = y2/H2.
𝑥 𝑥ℎ
If we multiply 𝑦 with a non zero scalar ‘h’ Then the matrix it forms is 𝑦ℎ
1 ℎ
𝑥 𝑥
𝑥
In 2D Plane. 𝑦 → 𝑦 =ℎ∙ 𝑦
ℎ 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

or, Symbolically [𝑋’] = [𝑇 ][𝑋]


Equations of Relation and Scaling With respect to coordinate origin may be modified as

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


 y '   sin  cos  0   y 
  
1   0 0 1  1 

and

x ' Sx 0 0 x 
 y '    0
 Sy 0   y 
 respectively
 1   0 0 1   1 

Similarly the modified General expression for reflection may be

 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).

3.4 Three Dimensional Transformations


Transformations in 3 dimensional space are analogous to those in two dimensional
space in many ways. Transformation matrix is the basic tool for 3-D transformation as was for 2-
D. A matrix with n x m dimensions is multiplied with the coordinate of objects. Usually 3 x 3 or
4 x 4 matrices are used for transformation

3.4.1 Transformations for 3-D Translation


In a three dimensional homogeneous co-ordinate representation a point is
translated from position 𝑷(𝒙, 𝒚, 𝒛) to position 𝑷’(𝒙’, 𝒚’, 𝒛’) with the matrix operation.
𝑥′ 1 0 0 𝑡 𝑥
𝑦′ 0 1 0 𝑡 𝑦
= ∙
𝑧 ′ 0 0 1 𝑡 𝑧
1 0 0 0 1 1
Or 𝑃’ = 𝑇. 𝑃
Parameters tx, ty and tz specifying translation distances for the co-ordinate
directions x, y and z are assigned any real values. The above matrix representation is equivalent
to the three equations. 𝑥’ = 𝑥 + 𝑡
𝑦’ = 𝑦 + 𝑡
𝑧’ = 𝑧 + 𝑡

Y-axis
(𝒙′ , 𝒚′ , 𝒛′)
(𝒙, 𝒚, 𝒛) X-axis
Z-axis

Fig : Translating an object with translation vector 𝑻 = 𝒕𝒙 , 𝒕𝒚 , 𝒕𝒛

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.

3.4.2 Transformations for 3-D Scaling


The process of compressing and expanding any object is called Scaling. Thus scaling alters the
size of an object if scale factors. Scaling can be achieved by multiplying the original coordinates
of the object with the scaling factor to get the desired result.
𝑆 = 𝑆 = 𝑆 = 𝑆 > 1 The scaling is called magnification.
And if 𝑆 = 𝑆 = 𝑆 = 𝑆 < 1 the scaling is termed as reduction.
The points after scaling with respect to origin can be calculated
by the following relation
𝑃’(𝑥’, 𝑦’, 𝑧’) = 𝑆. 𝑃 (𝑥, 𝑦, 𝑧)

𝑥’ = 𝑆 . 𝑥
𝑦’ = 𝑆 . 𝑦
𝑧’ = 𝑆 . 𝑧
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.

Fig :- Three Dimensional Scaling

3.4.3 Transformations for 3-D Rotation

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.

(a) Rotation about x-axis (i.e. axis of rotation is x):


X

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

c) Rotation about Z-axis (i.e. Z-axis is the axis of rotation):-


Y

𝑷′ (𝒙′ , 𝟎, 𝒛′)

𝑷(𝒙, 𝟎, 𝒛)
𝜽
𝜶 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.4.4 Transformations for 3-D Shearing


Shear along any pair of axes is proportional to the third axes for instance, to shear along
Z in 3D, x and y values are altered by an amount proportional to the value of Z, leaving
unchanged. Let 𝑆ℎ , 𝑆ℎ Is the shear due to 𝒁 along 𝒙 𝑎𝑛𝑑 𝒚 directions respectively and are
real values. Then the matrix representation is
1 0 0 0
0 1 0 0
𝑆ℎ 𝑆ℎ 1 0
0 0 0 1
Shear for 𝑥, 𝑦 axis is similar to that of Z. The general form of shear is given by
1 𝑆ℎ 𝑆ℎ 0
⎡ ⎤
⎢ 0 1 𝑆ℎ 0⎥
⎢ 𝑆ℎ 𝑆ℎ 1 0⎥
⎣ 𝑆ℎ 0 0 1⎦
In 2- D shear transformation we discussed shear transformations relative to the x or, y-axis to
produce distortions in the shapes of planer objects. In the 3D we can also generate shears relative
to z-axis and the result is change of volume and the 3-D shape of any object.
Fig :- Resultant of 3D Shearing

Example for shear along Z- axis


𝑥 ′ = 𝑥 + 𝑎𝑧
𝑦 ′ = 𝑦 + 𝑏𝑧
𝑧′ = 𝑧

The corresponding transformation matrix


1 0 𝑎 0
0 1 𝑏 0
[𝑇 ] =
0 0 1 0
1 0 0 1
The effect of this transformation matrix is to alter x and y coordinate values by an amount that
is proportional to Z value, while leaving the Z-coordinate unchanged.
3D shearing transformation can be carried out about the other two principal axes as well.
An X-axis 3D shear can be expressed as,
𝑥’ = 𝑥
𝑦’ = 𝑦 + 𝑎𝑥
𝑧’ = 𝑧 + 𝑏𝑥
The corresponding transformation matrix is,
1 0 0 0
𝑎 1 0 0
[𝑇 ] =
𝑏 0 1 0
0 0 0 1
Similarly Y-axis 3D shear can be expressed as,

𝑥′ = 𝑥 + 𝑦

𝑦’ = 𝑦

𝑧’ = 𝑧 + 𝑏𝑦

The corresponding transformation matrix is,


1 𝑎 0 0
𝑎 1 0 0
[𝑇 ] =
𝑏 𝑏 1 0
0 0 0 1

3.5 Co-ordinate Transformations :-


A co-ordinate transformation is a mathematical operation which transforms the co-
ordinates of a point in one system to the co-ordinate of the same point in another co-ordinate
system. Also there exist on inverse transformation to get back to the first co-ordinate system by
suitable mathematical operations. Co-ordinate transformations are frequently used in geodesy,
surveying, photogrammetric and related branches. In general, the effect of a transformation of
2D or 3D object varies from a simple change of location and orientation, without any change in
shape or size.
Affine Transformation
A co-ordinate system of the form
𝑥′ = 𝐴 𝑥 + 𝐵 𝑦 + 𝐶
𝑦′ = 𝐴 𝑥 + 𝐵 𝑦 + 𝐶
Where 𝐴 , 𝐵 , 𝐶 are parameters fixed for a given transformation is called affine transformation.
Obviously each of the transformed co-ordinates 𝑥’ and 𝑦’ is a linear function of the original co-
ordinates x and y. Affine transformations have general properties that parallel lines and finite
points map to finite points. An affine transformation that involves Translation, Rotation and
Reflection preserve the length of an angle between two lines.
Most general transformation model is the affine transformation. It changes the position,
size and shape of a network. The escape factor of such transformation depends on the orientation
but not only position within the net. Here the lengths of all lines in a certain direction are
multiplied by the same scalar. 3d affine transformations have been widely used as computer
vision and particularly in the area of model based object recognition. Different numbers of
parameters may be involved in this transformation.
i. 8-Parameters Affine transformation (two translation, three rotations, two
scale factors and skew distortion within image space) to describe a model that
transform 3D object space to 2D space.
ii. 9-Parameter Affine Transformation (three translations, three rotations, three
scales) can be used in reconstructing the relief and evaluating the geometric features
of the original documentation of the cultural heritage by 3D modeling.
iii. 12-Parameter Affine transformation (3D translation, 3D rotation, different
scale factor along each axis and 3D skew) used to define relationship between two
3D image volumes. For instance, in medical image computing, the transformation
model is part of different software programmes that compute fully automatically
the spatial transformation that maps points in one 3D image volume into their
geometrically corresponding points in another related 3D image.

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 ?

e) . Rigid transformation:– Translation + Rotation (distance preserving).


• Similarity transformation:– Translation + Rotation + uniform Scale (angle preserving).
• Affine transformation:– Translation + Rotation + Scale + Shear (parallelism preserving).
f) In Composite Transformation :- A sequence of transformations can be collapsed into a single
matrix.
g) Homogeneous Coordinates is a mapping from Rn to Rn+1 Dimension.
h) Affine Transformations

3.7 QUESTIONS FOR EXERCISE


1) A square consists of vertices A(0,0),B(0,1),C(1,1),D(1,0). After the translation C is found to
be at the new location (6,7). Determine the new location of other vertices.
2) A square ABCD is given with vertices A(0,0),B(1,0),C(1,1), and D(0,1). Illustrate the effect of
a) x-shear b) y-shear c) xy-shear on the given square, when a=2 and b=3
3) Find the new coordinates of a triangle A(0,0),B(1,1),C(5,2) after it has been (a) magnified to
twice its size and (b) reduced to half its size.
4) A point P(3,3) makes a rotating of 450 about the origin and then translating in the direction of
vector v=5I+6J. Find the new location of P.
5) Show that the order in which transformations are performed is important by applying the
transformation of the triangle ABC by:
(i) Rotating by 45o about the origin and then translating in the direction of the vector (1,0), and
(ii) Translating first in the direction of the vector (1,0), and then rotating by 45o about the origin,
where A = (1, 0) B = (0 ,1) and C = (1, 1).
6) Give a single 3x3 homogeneous coordinate transformation matrix, which will have the same
effect as each of the following transformation sequences.
a) Scale the image to be twice as large and then translate it 1 unit to the left.
b) Scale the x direction to be one-half as large and then rotate counterclockwise by 900 about the
origin.
c) Rotate counterclockwise about the origin by 900 and then scale the x direction to be one-half as
large.
d) Translate down ½ unit, right ½ unit, and then rotate counterclockwise by 450.

3.8 SUGGESTED READINGS


Donald Hearn, M. Pauline Baker, “Computer Graphics – C Version”, Pearson Education, 2007
Study Of Geometric Transformations In Computer Graphics- 2017 By Dr. Vijay Kumar Singh
Ch-2 Lecture Notes © by R. B. Agarwal Computer Aided Design in Mechanical Engineering
William M. Newman, Robert F. Sproull, “Principles of Interactive Computer Graphics”, Tata-
McGraw Hill, 2000
J.D. Foley, A.Dam, S.K. Feiner, J.F. Hughes, “Computer Graphics – principles and practice”,
Addison-Wesley, 1997
Harrington,S. "Computer Graphics - a programming approach." McGraw-Hill

UNIT -4

GRAPHICS STANDARDS
4.0 Objective
4.1 Introduction

You might also like