Comp Graphics
Comp Graphics
Computer Aided Design - also known as computer-aided design and drafting (CADD) , is the
use of computer technology for the process of design and design-documentation. Computer Aided
Drafting describes the process of drafting with a computer. CADD software, or environments,
provides the user with input-tools for the purpose of streamlining design processes; drafting,
documentation, and manufacturing processes.
Computer art - is any art in which computers play a role in production or display of the artwork.
Such art can be an image, sound, animation, video, CD-ROM, DVD-ROM, videogame, web site,
algorithm, performance or gallery installation.
Image processing - in computer science, image processing is any form of signal processing for
which the input is an image, such as a photograph or video frame; the output of image processing
may be either an image or, a set of characteristics or parameters related to the image
Entertainment – Computer graphics are now used in creating motion pictures, music videos and
television shows. Sometimes the graphics scenes are displayed by themselves and sometimes
graphics objects are combined with actors and live scenes.
Rasterization is the conversion of both geometric and pixel data into fragments. Each fragment
square corresponds to a pixel in the framebuffer. Line and polygon stipples, line width, point
size, shading model, and coverage calculations to support antialiasing are taken into
consideration as vertices are connected into lines or the interior pixels are calculated for a filled
polygon. Color and depth values are assigned for each fragment square.
(iii) Discuss the role of computer graphics in the growth of computer usage in the world
Computer graphics has made computers more accessible and user-friendly, by providing
graphical user interfaces (GUIs) that allow users to interact with computers using icons, menus,
windows, and other visual elements. GUIs were first developed at Xerox PARC in the 1970s1 and
popularized by Apple and Microsoft in the 1980s and 1990s.
Computer graphics has enhanced the fields of science, engineering, medicine, and education, by
allowing researchers and professionals to visualize complex data, models, simulations, and
phenomena that are otherwise difficult or impossible to comprehend. For example, computer
graphics can help astronomers study the structure and evolution of the universe, engineers design
and test new products and systems, doctors diagnose and treat diseases, and teachers explain and
demonstrate concepts and principles to students.
Computer graphics has revolutionized the entertainment industry, by enabling the creation of
realistic and immersive graphics for movies, video games, animation, and virtual reality.
Computer graphics can also enhance the artistic expression and creativity of filmmakers, game
developers, animators, and artists, by giving them more tools and techniques to produce stunning
and original works. Some of the pioneers of computer graphics in entertainment include Edwin
Catmull, who co-founded Pixar and Disney Animation Studios1, and George Lucas, who founded
Industrial Light and Magic and Lucasfilm1.
Computer graphics has facilitated the communication and collaboration among people, by
enabling the sharing and exchange of information, ideas, and opinions through various media and
platforms. Computer graphics can help people create and present documents, reports,
presentations, and web pages that are more attractive and informative. Computer graphics can
also help people connect and interact with each other through social media, online communities,
and video conferencing.
b) Some raster display technologies are:
Cathode ray tube (CRT): It uses an electron beam that scans the phosphor-coated screen and
excites the phosphor dots to emit light. The phosphor dots are arranged in a rectangular grid of
red, green, and blue colors. The resolution and color depth of a CRT monitor depend on the
number and size of the phosphor dots.
Liquid crystal display (LCD): It uses a thin layer of liquid crystals sandwiched between two
polarizing filters. The liquid crystals can change their orientation when an electric field is applied,
and thus modulate the amount of light passing through the filters. The light source can be either a
backlight or a reflective surface. The liquid crystals are arranged in a matrix of sub-pixels, each
with a red, green, or blue filter. The resolution and color depth of an LCD monitor depend on the
number and size of the sub-pixels.
Light-emitting diode (LED): It uses a panel of light-emitting diodes (LEDs) as the light source
for an LCD monitor. The LEDs can be either placed behind the LCD panel (backlit LED) or
along the edges of the panel (edge-lit LED). The LEDs can produce brighter and more uniform
light than the conventional backlight, and also consume less power and have a longer lifespan.
c) Some application areas of computer graphics are:
Computer-aided design (CAD): It involves using computer graphics to create, modify, analyze,
and optimize the design of various products, such as buildings, machines, vehicles, etc. CAD
software can provide realistic rendering, simulation, animation, and interactive manipulation of
the design models.
Computer games: It involves using computer graphics to create immersive and engaging virtual
environments, characters, and effects for entertainment purposes. Computer games can use
various techniques, such as 3D modeling, texture mapping, lighting, shading, shadowing,
collision detection, physics, etc., to achieve realistic and interactive graphics.
Scientific visualization: It involves using computer graphics to represent and explore complex
and large-scale data sets, such as physical phenomena, biological structures, geographical
information, etc. Scientific visualization can use various methods, such as color mapping,
contouring, volume rendering, surface rendering, etc., to enhance the understanding and
communication of the data.
Education and training: It involves using computer graphics to create interactive and effective
learning materials, such as simulations, animations, diagrams, etc., for various domains, such as
mathematics, physics, chemistry, biology, etc. Education and training can use computer graphics
to enhance the motivation, engagement, and retention of the learners.
b) Briefly Discuss any Four raster display technologies (12 Marks)
Cathode ray tube (CRT): This is the oldest and most common type of raster display
technology. It uses an electron beam that scans across a phosphor-coated screen, creating a
pattern of illuminated dots. The brightness and color of each dot depends on the intensity and
frequency of the electron beam. CRT displays have high resolution, contrast, and color fidelity,
but they are bulky, heavy, and consume a lot of power.
Liquid crystal display (LCD): This is a thin and flat type of raster display technology that uses
liquid crystals to modulate the light passing through them. LCD displays have two layers of
polarized glass, with liquid crystals sandwiched between them. When an electric current is
applied, the crystals change their orientation, allowing or blocking the light. LCD displays are
lightweight, energy-efficient, and have a wide viewing angle, but they have lower contrast,
brightness, and color accuracy than CRT displays.
Light-emitting diode (LED): This is a type of raster display technology that uses light-emitting
diodes to produce light. LED displays have a matrix of small LEDs, each of which can emit red,
green, or blue light. By varying the intensity of each LED, different colors and brightness can be
achieved. LED displays are bright, colorful, and have a long lifespan, but they are expensive,
consume more power, and generate more heat than LCD displays’
Organic light-emitting diode (OLED): This is a type of raster display technology that uses
organic materials to emit light. OLED displays have a layer of organic molecules that emit light
when an electric current is applied. Unlike LED displays, OLED displays do not require a
backlight, which makes them thinner, lighter, and more flexible. OLED displays also have higher
contrast, brightness, and color gamut than LED displays, but they are more prone to degradation,
burn-in, and power consumption.
d) The steps of the midpoint circle drawing algorithm are:
Step 1: Initialize the variables x = 0, y = r, and d = 1 - r, where r is the radius of the circle.
Step 2: Plot the initial point (x, y) and its eight symmetric points on the circle using the following
equations:
o (x, y)
o (y, x)
o (-x, y)
o (-y, x)
o (x, -y)
o (y, -x)
o (-x, -y)
o (-y, -x)
b) List the steps of the midpoint ellipse drawing algorithm including all the formulae for calculating
the decision parameters (11 Marks)
The midpoint ellipse drawing algorithm is a method for drawing ellipses on computer graphics
displays. It is based on the concept of incremental drawing, which means that the ellipse is drawn one
pixel at a time.
The steps of the algorithm are as follows:
1. Initialize the parameters:
o Set the center of the ellipse to (x0, y0).
o If E < 0:
Decrement y by 1: y = y - 1.
Calculate the new error term: E = E + 2rx - 2ry + ry2.
o Go to step 2.
QUESTION 5
a) What are the problems of Digital Differential Analyzer line drawing algorithm (4 Marks)
Floating-point arithmetic: The DDA algorithm uses floating-point arithmetic, which can be
slow on some systems.
Rounding error: The DDA algorithm is susceptible to rounding error, which can cause the line
to appear jagged.
b) What are the Advantages of Bresenham’s line drawing algorithm (4 Marks)
Integer arithmetic: Bresenham's line drawing algorithm uses integer arithmetic, which is faster
than floating-point arithmetic.
Accurate lines: Bresenham's line drawing algorithm produces accurate lines with no rounding
error.
c) Discuss the following line clipping algorithms (12 Marks)
Cohen-Sutherland line clipping algorithm: The Cohen-Sutherland line clipping algorithm is a
two-stage algorithm that clips lines against a rectangular clipping window. The first stage
determines which portions of the line lie inside the clipping window. The second stage clips the
line to the edges of the clipping window.
The algorithm divides a 2D space into 9 regions, of which only the middle part
(viewport) is visible. In 1967, flight simulation work by Danny Cohen led to the
development of the Cohen–Sutherland computer graphics two- and three-dimensional
line clipping algorithms, created with Ivan Sutherland.
The algorithm includes, excludes or partially includes the line based on where:
Both endpoints are in the viewport region (bitwise OR of endpoints == 0): trivial accept.
Both endpoints are on the same non-visible region (bitwise AND of endpoints! = 0):
trivial reject.
Both endpoints are in different regions: In case of this non trivial situation the algorithm
finds one of the two points that is outside the viewport region (there will be at least one
point outside). The intersection of the outpoint and extended viewport border is then
calculated (i.e. with the parametric equation for the line) and this new point replaces the
outpoint. The algorithm repeats until a trivial accept or reject occurs.
The numbers in the figure below are called outcodes. An outcode is computed for each of
the two points in the line. The first bit is set to 1 if the point is above the viewport. The
bits in the outcode represent: Top, Bottom, Right, Left. For example, the outcode 1010
represents a point that is top-right of the viewport. Note that the outcodes for endpoints
must be recalculated on each iteration after the clipping occurs.
Nicholl–Lee–Nicholl line clipping algorithm: The Nicholl–Lee–Nicholl line clipping algorithm
is a one-stage algorithm that clips lines against a rectangular clipping window. It is similar to the
Cohen-Sutherland algorithm, but it is slightly faster and simpler.
Using the Nicholl–Lee–Nicholl algorithm, the area around the clipping window is
divided into a number of different areas, depending on the position of the initial point of
the line to be clipped. This initial point should be in three predetermined areas; thus the
line may have to be translated and/or rotated to bring it into the desired region. The line
segment may then be re-translated and/or re-rotated to bring it to the original position.
After that, straight line segments are drawn from the line end point, passing through the
corners of the clipping window. These areas are then designated as L, LT, LB, or TR,
depending on the location of the initial point. Then the other end point of the line is
checked against these areas. If a line starts in the L area and finishes in the LT area then
the algorithm concludes that the line should be clipped at xw (max). Thus the number of
clipping points is reduced to one, compared to other algorithms that may require two or
more clipping points
d) List the steps of the Bresenham line drawing Algorithm including all the formulae for
The steps of the Bresenham line drawing algorithm are as follows:
Step 1: Input the coordinates of the two end points of the line, (x1, y1) and (x2, y2). Assume that
x1 < x2 and y1 < y2, and that the slope of the line is between 0 and 1. If these assumptions are not
true, the algorithm can be modified accordingly.
Step 2: Calculate the constants dx = x2 - x1, dy = y2 - y1, and 2dy and 2dx. Initialize the variable
x to x1 and y to y1, and plot the point (x, y) on the screen.
Step 3: Calculate the initial value of the decision parameter p as p = 2dy - dx. This value
represents the difference between the actual y-coordinate of the line and the midpoint of the two
candidate pixels in the next column.
Step 4: Repeat the following steps until x = x2:
Step 4.1: Increment x by 1, i.e., x = x + 1.
Step 4.2: If p < 0, then the lower pixel is closer to the line, and y remains the same. The new
value of p is p = p + 2dy.
Step 4.3: If p >= 0, then the upper pixel is closer to the line, and y is incremented by 1, i.e., y = y
+ 1. The new value of p is p = p + 2dy - 2dx.
Step 4.4: Plot the point (x, y) on the screen.
Step 5: The algorithm ends when x reaches x2.
g) Write the C++ code implementing the following mid-point circle drawing algorithm
Step 1:Input radius r and circle center(Xc, Yc)and obtain the first point on the circumference of a
circle centered on the origin as (X0, Y0) = (0, r)
Step 2: Calculate the initial values of the decision parameter as P0 = 5/4 – r
Step 3: At each position starting at k perform the following test:
If Pk < 0, the next point to plot is (Xk+1, Yk) and Pk+1 = Pk+2 Xk+1 + 1
Otherwise the next point is (Xk+1, Yk-1) and Pk+1 = Pk+2 Xk+1 + 1- 2Yk+1
where 2Xk+1=2Xk+2 and 2Yk+1=2Yk-2
Step 4: Determine symmetry points in the other seven octants
Step 5: Move each pixel position(X, Y) onto the circular path centered on(Xc, Yc) and plot the
coordinate values as
X = X + Xc Y = Y + Yc
Step 6: Repeat steps 3 through until X>=Y
#include <iostream>
using namespace std;
// A function to plot a pixel on the screen
void plot(int x, int y, int xc, int yc) {
// Add your code to plot the pixel at (x + xc, y + yc)
// You can use any graphics library or API you prefer
// For example, you can use the putpixel function from graphics.h
// putpixel(x + xc, y + yc, 15); // 15 is the color code for white
}
// A function to implement the mid-point circle drawing algorithm
void midPointCircle(int r, int xc, int yc) {
// Initialize the first point on the circle
int x = 0;
int y = r;
// Plot the first point
plot(x, y, xc, yc);
// Calculate the initial value of the decision parameter
int p = 5 / 4 - r;
// Update p by adding 2 * x + 1 - 2 * y
p = p + 2 * x + 1 - 2 * y;
}