0% found this document useful (0 votes)
25 views10 pages

Comp Graphics

The document discusses various topics related to computer graphics including: 1. Four application areas of computer graphics - computer aided design, computer art, image processing, and entertainment. 2. Definitions of output primitives and rasterization. 3. The role of computer graphics in increasing computer usage through graphical user interfaces, scientific/medical visualization, and revolutionizing entertainment. 4. Descriptions of four raster display technologies - CRT, LCD, LED, and OLED.

Uploaded by

klli234ad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views10 pages

Comp Graphics

The document discusses various topics related to computer graphics including: 1. Four application areas of computer graphics - computer aided design, computer art, image processing, and entertainment. 2. Definitions of output primitives and rasterization. 3. The role of computer graphics in increasing computer usage through graphical user interfaces, scientific/medical visualization, and revolutionizing entertainment. 4. Descriptions of four raster display technologies - CRT, LCD, LED, and OLED.

Uploaded by

klli234ad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

QUESTION 1

a(i) Explain any four application areas of computer graphics (8 Marks)

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

 A computer simulation - is a computer program, or network of computers, that attempts to


simulate an abstract model of a particular system

 Visualization - is any technique for creating images, diagrams, or animations to communicate a


message. Visualization through visual imagery has been an effective way to communicate both
abstract and concrete ideas since the dawn of man.
(ii) Define
1) Output primitives are the basic geometric shapes or objects that can be displayed on a computer
screen, such as points, lines, circles, polygons, etc. They are also called graphical primitives or graphical
elements.
2) Rasterization is the process of converting vector graphics or geometric primitives into raster graphics
or pixel-based images. It involves scanning the outline of each primitive and filling the interior pixels
with a specified color or pattern.

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

 Step 3: If x < y, then increment x by 1 and update d as follows:


o If d < 0, then d = d + 2x + 3

o If d >= 0, then decrement y by 1 and d = d + 2x - 2y + 5

 Step 4: Repeat step 2 and step 3 until x >= y.


QUESTION 2
a) Six parameters that can be used to measure the performance of computer monitors are:
 Resolution: It is the number of pixels that can be displayed on the screen, usually expressed as
width x height, such as 1920 x 1080. Higher resolution means more details and clarity, but also
more power consumption and cost.
 Refresh rate: It is the number of times the screen is updated per second, usually expressed in
hertz (Hz), such as 60 Hz. Higher refresh rate means smoother motion and less flicker, but also
more bandwidth and power consumption.
 Response time: It is the time it takes for a pixel to change its color, usually expressed in
milliseconds (ms), such as 5 ms. Lower response time means faster transitions and less ghosting,
but also more power consumption and cost.
 Contrast ratio: It is the ratio of the brightness of the brightest white to the darkest black that the
screen can produce, such as 1000:1. Higher contrast ratio means more vivid and realistic colors,
but also more power consumption and cost..
 Viewing angle: It is the angle at which the screen can be viewed without significant loss of color
and brightness, usually expressed in degrees, such as 178°. Wider viewing angle means more
flexibility and comfort, but also more power consumption and cost.
 Color gamut: It is the range of colors that the screen can display, usually expressed as a
percentage of a standard color space, such as sRGB or Adobe RGB, such as 99% sRGB. Larger
color gamut means more accurate and diverse colors, but also more power consumption and
cost.
b) Clipping is the process of removing the parts of an object or a line that are outside a specified region,
such as a window or a viewport. Clipping can be achieved by using the following methods:
 Point clipping: It is the simplest form of clipping, where a point is clipped if it lies outside the
clipping region. A point can be tested by comparing its coordinates with the boundaries of the
clipping region. If the point is inside the region, it is displayed; otherwise, it is discarded.
 Line clipping: It is the process of clipping a line segment by finding the intersection points of the
line with the boundaries of the clipping region. A line segment can be clipped by using various
algorithms, such as Cohen-Sutherland, Liang-Barsky, Nicholl-Lee-Nicholl, etc. These algorithms
use different techniques, such as bit codes, parametric equations, slope comparisons, etc., to clip
the line efficiently and accurately.
QUESTION 3
a) Differentiate between the following terms in regard to computer monitor: - (8 Marks)
 Aspect ratio and display size: Aspect ratio: The aspect ratio of a computer monitor is the ratio
of its width to its height. For example, a monitor with a 16:9 aspect ratio has a width that is 16
times its height. Display size: The display size of a computer monitor is the diagonal
measurement of its screen, in inches. For example, a 24-inch monitor has a diagonal measurement
of 24 inches.
 Pillarboxing and letterboxing: Pillarboxing refers to the black bars that appear on the sides of
the screen when a widescreen video or image is displayed on a standard 4:3 screen. The black
bars resemble two pillars on either side of the screen. Letterboxing refers to the black bars that
appear on the top and bottom of the screen when a standard 4:3 video or image is displayed on a
widescreen screen. The black bars resemble two horizontal lines that look like a letterbox.
o Pillarboxing and letterboxing are two types of black bars that appear on the screen when
a video or image does not fit the screen ratio. Pillarboxing and letterboxing are used to
preserve the original aspect ratio of the video or image, without cropping or stretching
it.

b) Briefly explain the following OpenGL libraries? (12 Marks)


 GLUT (Graphics Library Utility Toolkit): GLUT is a free library that provides a simple and
portable way to create OpenGL applications. It provides functions for creating
windows, managing events, and drawing graphics.
 GLX (OpenGL in the X Window System): GLX is an extension to the X Window System that
allows OpenGL applications to be displayed in X windows. It provides functions for creating
OpenGL contexts and sharing them between multiple windows.
 GLU (OpenGL Utility Library): GLU is a library that provides a set of utility functions for
OpenGL. It includes functions for creating and manipulating geometric objects, transforming
coordinates, and generating textures.
 DRI (Direct Rendering Infrastructure): DRI is an architecture that provides direct access to the
graphics hardware from OpenGL applications. It bypasses the X Window System and allows
OpenGL applications to run more efficiently.
QUESTION 4
a) State and explain three types of transformation using appropriate diagram. (9 Marks)
 Translation: Translation is the process of moving an object from one place to another without
changing its orientation, shape or size.
 Rotation: Rotation is the process of turning an object around a fixed point by certain angle.
 Scaling: Scaling is the process of increasing or decreasing the size of an object by a certain
factor.
o Uniform scaling is a linear transformation that enlarges (increases) or shrinks
(diminishes) objects by a scale factor that is the same in all directions
o Non-uniform scaling is obtained when at least one of the scaling factors is different from
the others; a special case is directional scaling or stretching (in one direction).

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 Set the radii of the ellipse to rx and ry.

o Set the decision parameters to dx = 2rx and dy = 0.

o Set the error term to E = ry2 - rx2 + rx.

o Set the current coordinates to (x, y) = (0, ry).

2. Draw the current pixel:


o Plot the pixel (x0 + x, y0 + y).

3. Update the parameters:


o Increment x by 1: x = x + 1.

o Calculate the new error term: E = E - 2ry.

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;

// Loop until x >= y


while (x < y) {
// Increment x by 1
x++;

// Check the value of p


if (p < 0) {
// The next point is (x, y)
// Update p by adding 2 * x + 1
p = p + 2 * x + 1;
} else {
// The next point is (x, y - 1)
// Decrement y by 1
y--;

// Update p by adding 2 * x + 1 - 2 * y
p = p + 2 * x + 1 - 2 * y;
}

// Plot the symmetry points in the other seven octants


plot(x, y, xc, yc);
plot(-x, y, xc, yc);
plot(x, -y, xc, yc);
plot(-x, -y, xc, yc);
plot(y, x, xc, yc);
plot(-y, x, xc, yc);
plot(y, -x, xc, yc);
plot(-y, -x, xc, yc);
}
}

// A main function to test the code


int main() {
// Input the radius and the center of the circle
int r, xc, yc;
cout << "Enter the radius of the circle: ";
cin >> r;
cout << "Enter the x-coordinate of the center: ";
cin >> xc;
cout << "Enter the y-coordinate of the center: ";
cin >> yc;

// Draw the circle using the mid-point algorithm


midPointCircle(r, xc, yc);

// Return 0 to indicate successful execution


return 0;
}

You might also like