KEMBAR78
Computer Graphics | PDF | Liquid Crystal Display | Rendering (Computer Graphics)
0% found this document useful (0 votes)
9 views45 pages

Computer Graphics

Uploaded by

graj200026
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)
9 views45 pages

Computer Graphics

Uploaded by

graj200026
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/ 45

Computer Graphics – Detailed Notes

Prepared for BSc/MCA/BTech Students

June 30, 2025

Contents
1 Unit 1: Introduction to Computer Graphics 3
1.1 Video-Display Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Raster-Scan and Random-Scan Systems . . . . . . . . . . . . . . . . . . 3
1.3 Graphics Monitors and Input Devices . . . . . . . . . . . . . . . . . . . . 4
1.4 Points and Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.5 Line Drawing Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.5.1 DDA (Digital Differential Analyzer) Algorithm . . . . . . . . . . 4
1.5.2 Bresenham’s Line Algorithm . . . . . . . . . . . . . . . . . . . . . 5
1.6 Circle and Ellipse Drawing Algorithms . . . . . . . . . . . . . . . . . . . 6
1.6.1 Mid-Point Circle Algorithm . . . . . . . . . . . . . . . . . . . . . 6
1.6.2 Mid-Point Ellipse Algorithm . . . . . . . . . . . . . . . . . . . . . 7
1.7 Area Filling Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.7.1 Scan Line Polygon Fill . . . . . . . . . . . . . . . . . . . . . . . . 8
1.7.2 Boundary Fill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.7.3 Flood Fill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2 Unit 2: 2D Geometric Transformations and Viewing 12


2.1 Basic Transformations...............................................................................................12
2.1.1 Translation....................................................................................................12
2.1.2 Scaling..........................................................................................................12
2.1.3 Rotation.........................................................................................................12
2.1.4 Reflection......................................................................................................13
2.1.5 Shear.............................................................................................................13
2.2 Matrix Representations and Homogeneous Coordinates.......................................14
2.3 Composite Transforms.............................................................................................14
2.4 Viewing Concepts.....................................................................................................15
2.4.1 Viewing Pipeline..........................................................................................15
2.4.2 Window to Viewport Transformation.........................................................15
2.5 Clipping Algorithms.................................................................................................15
2.5.1 Cohen-Sutherland Line Clipping................................................................15
2.5.2 Liang-Barsky Line Clipping........................................................................16
2.5.3 Sutherland-Hodgman Polygon Clipping....................................................17

1
2.6 Exercises....................................................................................................................17

3 Unit 3: 3D Graphics and Advanced Topics 19


3.1 3D Object Representations.......................................................................................19
3.1.1 Polygon Surfaces..........................................................................................19
3.1.2 Quadric Surfaces..........................................................................................20
3.1.3 Spline Representations.................................................................................20
3.2 Illumination Models.................................................................................................20
3.2.1 Ambient, Diffuse, Specular.........................................................................20
3.2.2 Polygon Rendering Methods.......................................................................21
3.3 3D Viewing Pipeline and Coordinate Systems......................................................21
3.4 General Projection Transformations........................................................................21
3.4.1 Perspective and Orthographic.....................................................................21
3.5 3D Clipping Algorithms...........................................................................................22
3.6 Exercises....................................................................................................................22

4 Practice Questions 24

2
1 Unit 1: Introduction to Computer Graphics
1.1 Video-Display Devices
Video-display devices render graphical content on screens, essential for computer graphics
visualization.

Types:

• Cathode Ray Tube (CRT): Uses electron beams to excite phosphors,


producing images. High refresh rates but bulky.

• Liquid Crystal Display (LCD): Modulates light through liquid crystals,


offering thin, energy-efficient displays.

• LED Displays: Use light-emitting diodes for vibrant colors and better contrast.

Use Cases:

• CRT: Legacy monitors, oscilloscopes.

• LCD/LED: Modern monitors, TVs, mobile devices.

Summary: Video-display devices (CRT, LCD, LED) vary in technology and appli-
cation. LCD and LED dominate due to efficiency and quality.

1.2 Raster-Scan and Random-Scan Systems


Raster-scan displays images as a pixel grid, scanned row-by-row, while random-scan draws
vectors directly.

Mathematical Basis:

• Raster-Scan: Represents image as a matrix I(x, y), where each element is a pixel
intensity.

• Random-Scan: Uses parametric equations, e.g., line from (x0, y0) to (x1, y1).

Algorithm (Raster-Scan Display):

1. Initialize frame buffer with pixel intensities.

2. Scan each row, updating pixel values.

3. Refresh display at fixed intervals (e.g., 60 Hz).

Use Cases:

• Raster-Scan: TVs, monitors, digital imaging.

• Random-Scan: CAD systems, vector-based graphics.

3
Table 1: Comparison of Raster-Scan and Random-Scan Systems
Feature Raster-Scan Random-Scan
Display Method Pixel grid Vector paths
Image Quality Smooth for filled areas Sharp for lines
Applications General-purpose displays CAD, vector graphics

Summary: Raster-scan excels in filled, complex images; random-scan is ideal for


precise line drawings.

1.3 Graphics Monitors and Input Devices


Graphics monitors display rendered images, while input devices enable interaction.

Types:

• Monitors: High-resolution displays (e.g., 4K LED) for detailed rendering.

• Input Devices: Mouse, keyboard, graphic tablets, touchscreens.

Use Cases:

• Monitors: Gaming, design, scientific visualization.

• Input Devices: 3D modeling, animation, interactive applications.

Summary: Monitors and input devices bridge user interaction and graphical output,
critical for graphics applications.

1.4 Points and Lines


Points are coordinates (x, y), and lines connect two points, approximated on raster dis-
plays using pixel grids.

Mathematical Representation:

• Point: (x, y) in 2D space.


−y0
• Line: Equation y = mx + c, where m =x y1 .
1 0
−x

1.5 Line Drawing Algorithms


1.5.1 DDA (Digital Differential Analyzer) Algorithm
DDA calculates pixel positions for a line between two points using coordinate differences.

Mathematical Formula:
∆x = x1 − x0, ∆y = y1 − y0

4
Steps = max(|∆x|, |∆y|)
∆x ∆y
xinc = , yinc =
Steps Steps

Algorithm:

1. Compute ∆x, ∆y, and steps.

2. Calculate increments xinc, yinc.

3. Start at (x0, y0), plot pixel.

4. Increment x+ = xinc, y+ = yinc, plot rounded coordinates.

5. Repeat for steps.


1 void DDA(int x0 , int y0 , int x1 , int y1) {
2
int dx = x1 - x0 , dy = y1 - y0;
3
int steps = abs(dx) > abs(dy) ? abs(dx) : abs(dy);
float xInc = dx / (float)steps, yInc = dy / (float)steps;
4
float x = x0 , y = y0;
5
for (int i = 0; i <= steps; i++) {
6 plot(round(x), round(y));
7 x += xInc;
8 y += yInc;
9
}
}
10

11

Example: Draw line from (2, 3) to (6, 5). Steps = 4, xinc = 1, yinc = 0.5. Plot (2, 3),
(3, 3.5), (4, 4), (5, 4.5), (6, 5).

Summary: DDA uses floating-point arithmetic for smooth line drawing, suitable for
raster displays.

1.5.2 Bresenham’s Line Algorithm


Bresenham’s algorithm uses integer arithmetic to select optimal pixels for a line.

Mathematical Formula:
∆x = |x1 − x0|, ∆y = |y1 − y0|
Error = ∆x − ∆y
If 2 · Error > −∆y, update x; else, update y

Algorithm:

1. Compute ∆x, ∆y, and signs (sx, sy).

2. Initialize error = ∆x − ∆y.


5
3. Plot (x0, y0).

4. Update error and coordinates based on decision parameter.

5. Repeat until reaching (x1, y1).


1 void Bresenham(int x0 , int y0 , int x1 , int y1) {
2
int dx = abs(x1 - x0), dy = abs(y1 - y0);
3
int sx = x0 < x1 ? 1 : -1, sy = y0 < y1 ? 1 : -1;
int err = dx - dy;
4
while (true) {
5
plot(x0 , y0);
6 if (x0 == x1 && y0 == y1) break;
7 int e2 = 2 * err;
8 if (e2 > -dy) { err -= dy; x0 += sx; }
9
if (e2 < dx) { err += dx; y0 += sy; }
}
10
}
11

12

Example: Line from (1, 1) to (4, 3). ∆x = 3, ∆y = 2. Plot (1, 1), (2, 1), (3, 2), (4, 3).

Summary: Bresenham’s algorithm is efficient due to integer operations, widely used


in graphics hardware.

1.6 Circle and Ellipse Drawing Algorithms


1.6.1 Mid-Point Circle Algorithm
Draws a circle by selecting pixels closest to the circle’s boundary using symmetry.

Mathematical Formula:
x2 + y2 = r2
Decision parameter: d = 1 − r
If d < 0, update d+ = 2x + 3; else, d+ = 2(x − y) + 5, y − −

Algorithm:

1. Initialize x = 0, y = r, d = 1 − r.

2. Plot 8 symmetric points for each (x, y).

3. Update x, y, and d based on decision parameter.

4. Repeat until x ≤ y.
1 void MidPointCircle(int xc, int yc, int r) {
2 int x = 0, y = r;
3 int d = 1 - r;
4
while (x <= y) {
plot(xc + x, yc + y); plot(xc - x, yc + y);
6
5

7
6 plot(xc + x, yc - y); plot(xc - x, yc - y);
7 plot(xc + y, yc + x); plot(xc - y, yc + x);
8 plot(xc + y, yc - x); plot(xc - y, yc - x);
9 if (d < 0) d += 2 * x + 3;
10 else { d += 2 * (x - y) + 5; y--; }
11 x++;
12 }
13 }

Diagram:

(xc, yc + r)

(xc − r, yc) (xc, yc) (xc + r, yc)

(xc, yc − r)

Example: Circle at (0, 0) with radius 3. Plot symmetric points like (0, 3), (3, 0), etc.

Summary: Mid-point circle algorithm leverages symmetry for efficient circle draw-
ing.

1.6.2 Mid-Point Ellipse Algorithm


Extends circle algorithm for ellipses with two radii.

Mathematical Formula:
x2 y2
+ =1
r2x r2y
d1 = r2 − r2ry + 0.25r2
y x x

If d1 < 0, update x; else, update x, y

Algorithm:
1. Initialize x = 0, y = ry, d1 = r2 − r2ry + 0.25r2.
y x x

2. Plot 4 symmetric points.

3. Update x, y, and decision parameter for two regions.

4. Repeat until regions converge.

8
1 void MidPointEllipse(int xc, int yc, int rx, int ry) {
2
int x = 0, y = ry;
3
int d1 = ry*ry - rx*rx*ry + 0.25* rx*rx;
int dx = 2*ry*ry*x, dy = 2*rx*rx*y;
4
while (dx < dy) {
5
plot(xc + x, yc + y); plot(xc - x, yc + y);
6 plot(xc + x, yc - y); plot(xc - x, yc - y);
7 if (d1 < 0) { dx += 2*ry*ry; d1 += dx + ry*ry; }
8 else { dx += 2*ry*ry; dy -= 2*rx*rx; d1 += dx - dy + ry*ry;
9
y--; }
x++;
}
10
// Region 2 code omitted for brevity
11
}
12

13

Example: Ellipse at (0, 0) with rx = 4, ry = 3. Plot symmetric points like (0, 3), (4, 0).

Summary: Mid-point ellipse algorithm adapts circle drawing for ellipses, handling
dual radii.

1.7 Area Filling Algorithms


1.7.1 Scan Line Polygon Fill
Fills polygons by processing scan lines and filling between intersection points.

Algorithm:

1. Create edge table with sorted edges.

2. For each scan line, find intersections with edges.

3. Sort intersections and fill pixels between pairs.

Example: Fill a triangle with vertices (0, 0), (4, 4), (8, 0). Scan lines intersect edges,
filling between points.

Summary: Scan line fill is efficient for complex polygons, processing scan lines in-
dependently.

1.7.2 Boundary Fill


Recursively fills an area until a boundary color is reached.

Algorithm:

1. Check if current pixel is not boundary or fill color.

9
2. Plot pixel with fill color.

10
3. Recursively call for neighboring pixels.
1 void BoundaryFill(int x, int y, int fillColor , int boundaryColor) {
2
if ( getPixel(x, y) != boundaryColor && getPixel(x, y) !=
fillColor) {
plot(x, y, fillColor);
3
BoundaryFill(x + 1, y, fillColor ,
4
boundaryColor); BoundaryFill(x - 1, y, fillColor
5 , boundaryColor); BoundaryFill(x, y + 1,
6 fillColor , boundaryColor); BoundaryFill(x, y -
7 1, fillColor , boundaryColor);
8
}
}
9

Example: Fill a square with boundary color black and fill color red from seed point (2, 2).

Summary: Boundary fill is simple but slow for large areas due to recursion.

1.7.3 Flood Fill


Replaces a specified color with a new color starting from a seed point.

Algorithm:

1. Check if current pixel matches old color.

2. Plot pixel with fill color.

3. Recursively call for neighbors.


1 void FloodFill(int x, int y, int fillColor , int oldColor) {
2
if ( getPixel(x, y) == oldColor) {
3
plot(x, y, fillColor);
FloodFill(x + 1, y, fillColor , oldColor);
4
FloodFill(x - 1, y, fillColor ,
5
oldColor); FloodFill(x, y + 1, fillColor
6 , oldColor); FloodFill(x, y - 1,
7 fillColor , oldColor);
8 }
9
}

Example: Replace white with blue in a region starting at (3, 3).

Summary: Flood fill is effective for uniform color regions but risks stack overflow.

1.8 Exercises
1. Which factor determines the number of steps in the DDA algorithm?

11
A. Minimum of ∆x, ∆y

12
B. Maximum of |∆x|, |∆y|

C. Sum of ∆x, ∆y

D. Product of ∆x, ∆y

Answer: B. Explanation: DDA uses the maximum of absolute differences to


ensure smooth pixel progression.

2. In Bresenham’s algorithm, the error term is initialized as:

A. ∆x + ∆y

B. ∆x − ∆y
C. 2∆x − ∆y
D. ∆y − ∆x

Answer: B. Explanation: The error term balances ∆x and ∆y for pixel


selection.

3. For a circle with radius 5, the initial decision parameter in the mid-point algorithm
is:

A. 1 − r
B. r − 1

C. r2

D. 0

Answer: A. Explanation: The mid-point circle algorithm initializes d = 1 − r.

4. Which algorithm is most suitable for filling a polygon with many vertices?

A. Boundary Fill

B. Flood Fill

C. Scan Line

D. Mid-Point

Answer: C. Explanation: Scan line is efficient for complex polygons, processing


scan lines systematically.

5. The mid-point ellipse algorithm processes how many regions?

A. 1

B. 2

13
C. 4

D. 8

Answer: B. Explanation: The algorithm divides the ellipse into two regions
based on slope.

6. In boundary fill, recursion stops when:

A. Pixel is outside the screen

B. Pixel is the boundary color

C. Pixel is the fill color

D. Both B and C

Answer: D. Explanation: Recursion stops at boundary or already filled pixels.

7. For a line from (0, 0) to (4, 6), how many pixels are plotted by Bresenham’s
algorithm (including endpoints)?

A. 5

B. 6

C. 7

D. 8

Answer: C. Explanation: Maximum of |∆x| = 4, |∆y| = 6 is 6, plus starting


pixel.

8. Which display system is best for vector graphics?

A. Raster-Scan

B. Random-Scan

C. Both

D. Neither

Answer: B. Explanation: Random-scan draws precise vectors, ideal for CAD.

9. The DDA algorithm uses:

A. Integer arithmetic

B. Floating-point arithmetic

C. Both

14
D. None

Answer: B. Explanation: DDA relies on floating-point for smooth increments.

10. Flood fill is inefficient for large areas due to:

A. High memory usage

B. Stack overflow

C. Complex calculations

D. Pixel overlap

Answer: B. Explanation: Recursive calls can exhaust stack space in large regions.

2 Unit 2: 2D Geometric Transformations and


View- ing
2.1 Basic Transformations
Transformations modify object position, size, or orientation in 2D space.

2.1.1 Translation
Moves an object by adding offsets.

Mathematical Formula:
(x′, y′) = (x + tx, y + ty)

Example: Translate (2, 3) by tx = 1, ty = 2 to (3, 5).

Summary: Translation shifts objects without altering shape or orientation.

2.1.2 Scaling
Resizes an object relative to a fixed point.

Mathematical Formula:
(x′, y′) = (x · sx, y · sy)

Example: Scale (2, 3) by sx = 2, sy = 3 to (4, 9).

Summary: Scaling changes size; uniform scaling (sx = sy) preserves shape.

2.1.3 Rotation
Rotates an object around the origin by angle θ.

15
Mathematical Formula:

(x′, y′) = (x cos θ − y sin θ, x sin θ + y cos θ)

Diagram:

(x′, y′(x,
)
y)
θ x

Example: Rotate (2, 0) by 90° to (0, 2).

Summary: Rotation changes orientation using trigonometric functions.

2.1.4 Reflection
Mirrors an object over an axis.

Mathematical Formula:
X-axis: (x′, y′) = (x, −y)
Y-axis: (x′, y′) = (−x, y)

Example: Reflect (2, 3) over x-axis to (2, -3).

Summary: Reflection flips objects across an axis, preserving size.

2.1.5 Shear
Distorts an object along an axis.

Mathematical Formula:

X-shear: (x′, y′) = (x + shx · y, y)


Y-shear: (x′, y′) = (x, y + shy · x)

Example: X-shear (2, 3) with shx = 1 to (5, 3).

16
Summary: Shear creates slanted distortions for visual effects.

2.2 Matrix Representations and Homogeneous


Coordinates
Homogeneous coordinates (x, y, 1) unify transformations as matrix operations.

Mathematical Formulas:
 
1 0 tx
Translation:  0 1 ty 
0 0 1
 
sx 0 0
Scaling:  0 sy 0
0 0 1
 
cos θ − sin θ 0
Rotation:  sin θ cos θ 0
0 0 1

Example: Combine translation (2, 3) and scale (2, 2):


 
2 0 2
 0 2 3
0 0 1

Summary: Homogeneous coordinates simplify transformation computations via ma-


trices.

2.3 Composite Transforms


Combines multiple transformations by matrix multiplication.

Mathematical Formula:
M = M1 · M2 · . . . · Mn

Example: Rotate by 90° then translate by (1, 1):


 
0 −1 1
 1 0 1
0 0 1

Summary: Composite transforms enable complex manipulations through matrix


multiplication.

17
2.4 Viewing Concepts
2.4.1 Viewing Pipeline
Maps objects from world to screen coordinates through transformations.

Algorithm:

1. Model objects in world coordinates.

2. Apply viewing transformations.

3. Project to 2D screen space.

4. Map to viewport.

Summary: The viewing pipeline transforms objects for display on screen.

2.4.2 Window to Viewport Transformation


Maps a window in world coordinates to a viewport in screen coordinates.

Mathematical Formula:
(xw − xwmin)(xvmax − xvmin)
x = + xvmin
v xwmax − xwmin
(yw − ywmin)(yvmax − yvmin)
y = + yvmin
ywmax − ywmin
v

Example: Map (5, 5) from window [0, 10] × [0, 10] to viewport [0, 100] × [0, 100] yields
(50, 50).

Summary: Window to viewport transformation scales and shifts coordinates for


display.

2.5 Clipping Algorithms


2.5.1 Cohen-Sutherland Line Clipping
Clips lines against a rectangular window using region codes.

Algorithm:

1. Assign 4-bit region codes to endpoints (left, right, top, bottom).

2. If both codes are 0000, accept line.

3. If codes ANDed are non-zero, reject line.

4. Clip line to window boundaries iteratively.

18
1 void CohenSutherland(float x0 , float y0 , float x1 , float y1 , float
xmin , float ymin , float xmax , float ymax) {
2
int code0 = computeCode(x0 , y0 , xmin , ymin , xmax , ymax);
int code1 = computeCode(x1 , y1 , xmin , ymin , xmax , ymax);
3

while (true) {
if (!( code0 | code1 )) { accept(); break; }
if (code0 & code1 ) { reject(); break; }
// Clip and update endpoints
}
}

Diagram
:
0001

1001 0000 1000

0100

Summary: Cohen-Sutherland uses region codes for efficient line clipping.

2.5.2 Liang-Barsky Line Clipping


Clips lines using parametric equations.

Mathematical Formula:

x = x0 + t(x1 − x0), y = y0 + t(y1 − y0)


tenter, texit computed for window boundaries

Algorithm
:

1. Parameterize line: x = x0 + t∆x, y = y0 + t∆y.

2. Compute t values for intersections with window edges.

3. Accept line segment within t ∈ [0, 1].


Summary: Liang-Barsky is efficient for parametric line clipping.

19
2.5.3 Sutherland-Hodgman Polygon Clipping
Clips polygons against convex clip windows.

Algorithm:

1. Process each polygon edge against a clip boundary.

2. Output vertices within boundary, adding intersection points.

3. Repeat for all boundaries.

Summary: Sutherland-Hodgman handles polygon clipping sequentially per bound-


ary.

2.6 Exercises
1. The homogeneous coordinate for point (2, 3) is:

A. (2, 3, 0)

B. (2, 3, 1)

C. (1, 2, 3)

D. (3, 2, 1)

Answer: B. Explanation: Homogeneous coordinates use (x, y, 1) for 2D points.

2. Rotating (1, 0) by 90° counterclockwise yields:

A. (0, 1)

B. (0, -1)

C. (-1, 0)

D. (1, 0)

Answer: A. Explanation: x′ = cos 90◦−0·sin 90◦ = 0, y′ = sin 90◦+0·cos 90◦ = 1.

3. The order of composite transformations affects the result because:

A. Matrices are non-commutative

B. Matrices are singular

C. Matrices are orthogonal

D. Matrices are commutative

20
Answer: A. Explanation: Matrix multiplication is non-commutative (AB ̸=
BA).

4. For window [0, 10] × [0, 10] and viewport [0, 100] × [0, 100], point (5, 5) maps to:

A. (50, 50)

B. (5, 5)

C. (100, 100)

D. (25, 25)
(5−0)(100−0)
Answer: A. Explanation: Linear mapping yields xv = 10−
= 50.
0
5. Cohen-Sutherland rejects a line if:

A. Both endpoints have code 0000

B. Endpoint codes ANDed are non-zero

C. Endpoint codes ORed are zero

D. Both endpoints are inside

Answer: B. Explanation: Non-zero AND indicates both points are outside same
boundary.

6. Liang-Barsky clipping uses:

A. Region codes

B. Parametric equations

C. Vertex lists

D. Edge tables

Answer: B. Explanation: Parametric equations define line segments for clipping.

7. Sutherland-Hodgman clips against:

A. Concave windows

B. Convex windows

C. Circular windows

D. Any shape

Answer: B. Explanation: Algorithm assumes convex clip regions for simplicity.

21
8. A shear transformation can:

A. Rotate objects

B. Distort shapes

C. Scale uniformly

D. Reflect objects

Answer: B. Explanation: Shear distorts by slanting along an axis.

9. The matrix for reflection over y-axis is:


 
−1 0 0
A.  0 1 0
0 0 1
 
1 0 0
B.  0 −1 0
0 0 1
 
0 1 0
C.  1 0 0
0 0 1
 
1 0 0
D.  0 1 0 
0 0 −1

Answer: A. Explanation: Negates x-coordinate for y-axis reflection.

10. The viewing pipeline includes:

A. Modeling, viewing, projection

B. Clipping, scaling, rotation

C. Translation, reflection

D. None of the above

Answer: A. Explanation: The pipeline maps 3D to 2D through these stages.

3 Unit 3: 3D Graphics and Advanced Topics


3.1 3D Object Representations
3.1.1 Polygon Surfaces
Represent 3D objects as meshes of polygons (e.g., triangles).

22
Example: A cube defined by 8 vertices and 12 triangular faces.

Summary: Polygon surfaces are simple and hardware-optimized for rendering.

3.1.2 Quadric Surfaces


Defined by quadratic equations, e.g., sphere: x2 + y2 + z2 = r2.

Example: A sphere for modeling planets in simulations.

Summary: Quadric surfaces model smooth, curved objects efficiently.

3.1.3 Spline Representations


Curves and surfaces defined by control points, e.g., Bezier, B-Spline.

Mathematical Formula (Bezier Curve):

n ( )
P (t) = ∑ n ti(1 − t)n−i
Bi,n(t)Pi, Bi,n(t) =
i
i=0

Example: Bezier curve for smooth car body design in CAD.

Summary: Splines provide smooth, flexible representations for curves and surfaces.

3.2 Illumination Models


3.2.1 Ambient, Diffuse, Specular
Combines lighting effects for realism.

Mathematical Formulas:
Iambient = kaIa
Idiffuse = kdId(N · L)
Ispecular = ksIs(R ·
V)n
Diagram
:

Surface L
23
Example: Lighting a 3D model with ambient for base, diffuse for shading, specular for
highlights.

24
Summary: Illumination models combine ambient, diffuse, and specular for realistic
lighting.

3.2.2 Polygon Rendering Methods

• Flat Shading: Uniform color per polygon.

• Gouraud Shading: Interpolates vertex colors.

• Phong Shading: Interpolates normals for smooth lighting.

Example: Phong shading for realistic character rendering in games.

Summary: Rendering methods balance realism and computational cost.

3.3 3D Viewing Pipeline and Coordinate Systems


Maps 3D objects to 2D screen through transformations.

Algorithm:

1. Model in world coordinates.

2. Transform to view coordinates.

3. Apply projection (perspective/orthographic).

4. Map to viewport.

Summary: The 3D viewing pipeline transforms objects to screen space.

3.4 General Projection Transformations


3.4.1 Perspective and Orthographic
x·d y·d
• Perspective: x′ = , y′ = , simulates depth.
z z

• Orthographic: x′ = x, y′ = y, preserves parallel lines.

Diagram:

Perspective
Orthographic

Example: Perspective for games, orthographic for CAD.

25
Summary: Perspective adds realism; orthographic suits technical drawings.

3.5 3D Clipping Algorithms


Clips objects against a view frustum.

Algorithm:

1. Define view frustum planes.

2. Test objects against planes.

3. Clip vertices and regenerate polygons.

Summary: 3D clipping ensures only visible parts are rendered.

3.6 Exercises
1. The equation for a sphere is:

A. x2 + y2 = r2

B. x2 + y2 + z2 = r2

C. x + y + z = r

D. x2 + y2 = z

Answer: B. Explanation: A sphere is defined by a quadratic equation in 3D.

2. Bezier curves are defined by:

A. Control points

B. Edge tables

C. Region codes

D. Parametric lines

Answer: A. Explanation: Bezier curves use control points for smooth interpola-
tion.

3. Specular lighting depends on:

A. Surface normal and light direction

B. Viewer direction and reflection vector

26
C. Ambient intensity

D. Diffuse coefficient

Answer: B. Explanation: Specular highlights depend on viewer and reflection


angles.

4. Phong shading interpolates:

A. Vertex colors

B. Surface normals

C. Pixel intensities

D. Edge coordinates

Answer: B. Explanation: Phong interpolates normals for smooth lighting.

5. Perspective projection matrix includes:

A. z-division

B. Uniform scaling

C. Orthogonal vectors

D. Shear components

Answer: A. Explanation: Perspective divides by z for depth effect.

6. 3D clipping occurs in:

A. World coordinates

B. View frustum

C. Screen coordinates

D. Viewport

Answer: B. Explanation: Clipping uses the view frustum in view space.

7. B-Splines differ from Bezier curves by:

A. Local control

B. Global control

C. Linear interpolation

D. Fixed endpoints

27
Answer: A. Explanation: B-Splines allow local modifications.

8. The 3D viewing pipeline includes:

A. Modeling, viewing, projection

B. Clipping, scaling, rotation

C. Translation, reflection

D. None of the above

Answer: A. Explanation: These stages map 3D to 2D.

9. Diffuse lighting depends on:

A. N · V
B. N · L
C. R · V
D. L · R

Answer: B. Explanation: Diffuse uses normal and light direction dot product.

10. Orthographic projection preserves:

A. Depth

B. Parallel lines

C. Angles

D. Curvature

Answer: B. Explanation: Orthographic maintains parallel lines without


distor- tion.

4 Practice Questions
The following 100 multiple-choice questions are designed to test your understanding of
computer graphics concepts. Attempt these to reinforce your knowledge.

1. What is the primary advantage of LED displays over CRT?

A. Higher resolution

B. Energy efficiency

C. Faster refresh rate

28
D. Larger size

2. Which display system scans row-by-row?

A. Random-Scan

B. Raster-Scan

C. Vector-Scan

D. None

3. Which input device is best for precise drawing in graphics?

A. Keyboard

B. Mouse

C. Graphic tablet

D. Joystick

4. The slope of a line from (1, 2) to (5, 6) is:

A. 0.5

B. 1

C. 2

D. 4

5. In DDA, the increment step size depends on:

A. Line length

B. Maximum coordinate difference

C. Minimum coordinate difference

D. Pixel density

6. Bresenham’s algorithm is optimized for:

A. Floating-point arithmetic

B. Integer arithmetic

C. Complex numbers

D. Matrix operations

29
7. The mid-point circle algorithm uses how many symmetric points?

A. 4

B. 6

C. 8

D. 12

8. The initial decision parameter for an ellipse depends on:

A. rx + ry
B. r2 + r2
x y

C. r2 − r2ry
y x

D. r − r2
2
x y

9. Scan line polygon fill requires:

A. Edge table

B. Vertex colors

C. Boundary colors

D. Seed points

10. Boundary fill is best suited for:

A. Large areas

B. Small, enclosed areas

C. Complex polygons

D. Non-convex shapes

11. Flood fill replaces:

A. Boundary color

B. Specified color

C. Edge pixels

D. Vertex colors

12. Which algorithm minimizes floating-point operations?

30
A. DDA

B. Bresenham

C. Mid-Point Circle

D. Scan Line

13. The mid-point circle algorithm is based on:

A. Parametric equations

B. Decision parameters

C. Edge intersections

D. Vertex normals

14. Which display is best for high-resolution images?

A. CRT

B. LCD

C. LED

D. Plasma

15. The DDA algorithm is less efficient than Bresenham’s due to:

A. Integer calculations

B. Floating-point calculations

C. Memory usage

D. Recursion

16. In mid-point ellipse, the number of regions processed is:

A. 1

B. 2

C. 3

D. 4

17. Scan line fill is efficient because it:

A. Uses recursion

31
B. Processes scan lines independently

C. Requires seed points

D. Uses floating-point

18. Boundary fill may cause:

A. Stack overflow

B. Memory leaks

C. Pixel overlap

D. Edge artifacts

19. Random-scan systems are best for:

A. Filled shapes

B. Vector graphics

C. Raster images

D. 3D rendering

20. The line equation y = mx + c is used in:

A. DDA

B. Bresenham

C. Both

D. Neither

21. Translation affects:

A. Size

B. Orientation

C. Position

D. Shape

22. Scaling by sx = sy is called:

A. Non-uniform scaling

B. Uniform scaling

32
C. Shear scaling

D. Reflective scaling

23. Rotation by 180° maps (1, 0) to:

A. (0, 1)

B. (-1, 0)

C. (0, -1)

D. (1, 0)

24. Reflection over the line y = x uses matrix:


 
0 1 0
A.  1 0 0
0 0 1
 
−1 0 0
B.  0 1 0
0 0 1
 
1 0 0
C.  0 −1 0
0 0 1
 
1 0 0
D.  0 1 0 
0 0 −1
25. X-shear affects:

A. X-coordinate based on y

B. Y-coordinate based on x

C. Both coordinates

D. Neither coordinate

26. Homogeneous coordinates allow:

A. Translation as matrix operation

B. Scaling only

C. Rotation only

D. Clipping

33
27. The composite transform M1 · M2 is equivalent to:
A. M2 · M1

B. Applying M2 then M1

C. Applying M1 then M2

D. Inverse of M1

28. The viewing pipeline starts with:

A. Projection

B. Modeling

C. Clipping

D. Viewport mapping

29. Window to viewport transformation involves:

A. Rotation

B. Scaling and translation

C. Reflection

D. Shear

30. Cohen-Sutherland uses how many bits for region codes?

A. 2

B. 4

C. 6

D. 8

31. Liang-Barsky is faster than Cohen-Sutherland for:

A. Complex polygons

B. Short lines

C. Parametric lines

D. Curved lines

32. Sutherland-Hodgman outputs:

34
A. Clipped lines

B. Clipped polygons

C. Clipped points

D. Clipped curves

33. The matrix for scaling by (2, 3) is:


 
2 0 0
A.  0 3 0
0 0 1
 
3 0 0
B.  0 2 0
0 0 1
 
2 3 0
C.  0 1 0
0 0 1
 
1 0 0
D.  0 1 0
2 3 1

34. Translation by (1, 2) followed by rotation by 90° is:

A. Commutative

B. Non-commutative

C. Singular

D. Orthogonal

35. The region code for a point left of the window is:

A. 0001

B. 0010

C. 0100

D. 1000

36. The viewing coordinate reference frame defines:

A. Object position

B. Camera position

35
C. Screen position

D. Viewport size

37. Clipping is performed before:

A. Modeling

B. Projection

C. Viewport mapping

D. Rotation

38. Homogeneous coordinates have dimension:

A. 2

B. 3

C. 4

D. 5

39. The inverse of a translation matrix is:

A. Same matrix

B. Negative offsets

C. Zero offsets

D. Identity matrix

40. Window to viewport mapping preserves:

A. Angles

B. Distances

C. Relative positions

D. Shapes

41. Polygon surfaces are best for:

A. Smooth curves

B. Hardware rendering

C. Parametric surfaces

36
D. Fractal shapes

42. A quadric surface is defined by:

A. Linear equations

B. Quadratic equations

C. Cubic equations

D. Parametric equations

43. Bezier curves use:

A. Global control

B. Local control

C. Vertex normals

D. Edge tables

44. Ambient lighting is:

A. Direction-dependent

B. Uniform

C. Specular

D. Diffuse

45. Diffuse lighting depends on:

A. Viewer direction

B. Light direction

C. Reflection vector

D. Surface color

46. Phong shading is computationally:

A. Less intensive than flat

B. More intensive than Gouraud

C. Equal to Gouraud

D. Less intensive than Gouraud

37
47. Perspective projection simulates:

A. Parallel lines

B. Depth

C. Uniform scaling

D. Orthogonal views

48. Orthographic projection is used in:

A. Games

B. CAD

C. Animation

D. Virtual reality

49. 3D clipping involves:

A. View frustum

B. Screen boundaries

C. World coordinates

D. Viewport edges

50. B-Splines are preferred for:

A. Fixed endpoints

B. Local modifications

C. Global control

D. Linear paths

51. The 3D viewing pipeline ends with:

A. Modeling

B. Projection

C. Viewport mapping

D. Clipping

52. Specular highlights are brightest when:

38
A. N · L = 1
B. R · V = 1
C. N · V = 1
D. L · R = 1

53. Flat shading applies:

A. Interpolated normals

B. Uniform color

C. Vertex colors

D. Pixel intensities

54. A cylinder is an example of:

A. Polygon surface

B. Quadric surface

C. Spline surface

D. Bezier curve

55. The degree of a cubic Bezier curve is:

A. 2

B. 3

C. 4

D. 5

56. 3D clipping requires how many planes for a frustum?

A. 4

B. 5

C. 6

D. 8

57. The frame buffer in raster-scan stores:

A. Vertex coordinates

39
B. Pixel intensities

C. Edge lists

D. Normal vectors

58. Random-scan systems are less suitable for:

A. Line drawings

B. Filled shapes

C. Vector graphics

D. CAD designs

59. The DDA algorithm plots pixels based on:

A. Integer steps

B. Floating-point increments

C. Decision parameters

D. Region codes

60. Bresenham’s algorithm handles lines with slope:

A. |m| < 1
B. |m| > 1

C. Any slope

D. m = 0

61. Mid-point circle algorithm reduces calculations using:

A. Symmetry

B. Recursion

C. Edge tables

D. Parametric equations

62. Scan line fill sorts intersections by:

A. Y-coordinate

B. X-coordinate

40
C. Z-coordinate

D. Color value

63. Boundary fill uses how many neighboring pixels?

A. 2

B. 4

C. 6

D. 8

64. Flood fill is similar to boundary fill but:

A. Uses edge tables

B. Replaces a specific color

C. Requires boundary color

D. Is non-recursive

65. Translation matrix in homogeneous coordinates is:

A. 2x2

B. 2x3

C. 3x3

D. 3x2

66. Scaling affects:

A. Position

B. Orientation

C. Size

D. Color

67. Rotation matrix is:

A. Singular

B. Orthogonal

C. Diagonal

41
D. Skew-symmetric

68. Cohen-Sutherland region codes are based on:

A. Vertex positions

B. Window boundaries

C. Parametric equations

D. Edge intersections

69. Liang-Barsky computes:

A. Region codes

B. Intersection parameters

C. Vertex lists

D. Edge tables

70. Sutherland-Hodgman processes:

A. One vertex at a time

B. One edge at a time

C. One polygon at a time

D. One plane at a time

71. Polygon surfaces are composed of:

A. Curves

B. Triangles or quads

C. Splines

D. Quadrics

72. Ambient lighting requires:

A. Surface normal

B. Light direction

C. No direction

D. Viewer position

42
73. Gouraud shading interpolates:

A. Normals

B. Colors

C. Textures

D. Coordinates

74. Perspective projection matrix is:

A. 3x3

B. 4x4

C. 3x4

D. 4x3

75. Orthographic projection ignores:

A. X-coordinate

B. Y-coordinate

C. Z-coordinate

D. W-coordinate

76. 3D clipping is performed in:

A. World space

B. View space

C. Screen space

D. Model space

77. Bezier surfaces are defined by:

A. Single control point

B. Grid of control points

C. Edge lists

D. Vertex normals

78. The shininess parameter in specular lighting is:

43
A. ka

B. kd

C. ks

D. n

79. The 3D viewing pipeline transforms from:

A. Screen to world

B. World to screen

C. Viewport to model

D. Model to viewport

80. A quadric surface example is:

A. Cube

B. Sphere

C. Triangle mesh

D. Bezier curve

81. B-Spline curves ensure:

A. Global continuity

B. Local continuity

C. No continuity

D. Endpoint interpolation

82. The view frustum is defined by:

A. 4 planes

B. 6 planes

C. 8 planes

D. 10 planes

83. Diffuse lighting is proportional to:

A. Cosine of angle between normal and light

44
B. Sine of angle between normal and viewer

C. Cosine of angle between viewer and reflection

D. Sine of angle between light and reflection

84. Phong shading improves over Gouraud by:

A. Interpolating colors

B. Interpolating normals

C. Using flat shading

D. Reducing calculations

85. Perspective projection converges lines to:

A. Origin

B. Vanishing point

C. Viewport center

D. Infinity

86. Orthographic projection is suitable for:

A. Realistic rendering

B. Technical drawings

C. Animation

D. Games

45

You might also like