Tribhuwan University

Institute of Science and Technology

2079

Bachelor Level / Third Year / Fifth Semester / Science

Bachelors in Information Technology (BIT304)

(Computer Graphics)

Full Marks: 60

Pass Marks: 24

Time: 3 Hours

Candidates are required to give their answers in their own words as for as practicable.

The figures in the margin indicate full marks.

Section A

Long Answers Questions

Attempt any TWO questions.
[2*10=20]
1.
List the major differences between DDA and Bresenham's algorithm. Illustrate the Bresenham's algorithm to the line with end points(10, 6) and (12, 1).[10]

DDA vs Bresenham's Algorithm & Numerical Illustration


Major Differences between DDA and Bresenham's Algorithm

Feature DDA Algorithm Bresenham's Algorithm
Computation Uses floating-point arithmetic Uses only integer arithmetic
Speed Slower due to floating-point operations Faster due to integer operations only
Rounding Requires rounding off at each step No rounding needed
Accuracy Less accurate due to rounding errors More accurate
Operations Uses multiplication and division Uses only addition and subtraction
Decision Parameter No decision parameter used Uses a decision parameter ($p_k$)
Efficiency Less efficient More efficient
Cost More expensive in computation Less expensive
Complexity Simpler to implement Slightly more complex logic
Hardware Difficult to implement in hardware Easy to implement in hardware

Bresenham's Line Algorithm: From (10, 6) to (12, 1)

Given: (x1,y1)=(10,6)(x_1, y_1) = (10, 6) and (x2,y2)=(12,1)(x_2, y_2) = (12, 1)

Step A: Calculate parameters

  • dx=x2x1=1210=2dx = x_2 - x_1 = 12 - 10 = 2
  • dy=y2y1=16=5dy = y_2 - y_1 = 1 - 6 = -5
  • dx=2|dx| = 2, dy=5|dy| = 5

Since dy>dx|dy| > |dx|, the slope is steep (|m| > 1). We drive the algorithm along the y-axis (y is incremented each step).

Here, y decreases (from 6 to 1), so y steps by -1 each iteration. We need to decide whether x increments or stays same at each step.

Step B: Reformulate for steep line (driving along y-axis)

  • Steps = dy=5|dy| = 5
  • dx=2dx = 2 (x increases since $x_2 > x_1$)
  • dy=5|dy| = 5

Initial decision parameter:

p0=2dxdy=2(2)5=1p_0 = 2|dx| - |dy| = 2(2) - 5 = -1

Decision rule (driving along y-axis):

  • If pk<0p_k < 0: next point (xk,yk+1)(x_k, y_{k+1}), and pk+1=pk+2dxp_{k+1} = p_k + 2|dx|
  • If pk0p_k \geq 0: next point (xk+1,yk+1)(x_k + 1, y_{k+1}), and pk+1=pk+2dx2dyp_{k+1} = p_k + 2|dx| - 2|dy|

Where yk+1=yk1y_{k+1} = y_k - 1 (since y is decreasing)

Constants:

  • 2dx=42|dx| = 4
  • 2dx2dy=410=62|dx| - 2|dy| = 4 - 10 = -6

Step C: Iteration Table

Step kk pkp_k Condition Point (x,y)(x, y) Next pk+1p_{k+1}
0 -1 p0<0p_0 < 0 (10, 6) 1+4=3-1 + 4 = 3
1 3 p10p_1 \geq 0 (11, 5) 3+(6)=33 + (-6) = -3
2 -3 p2<0p_2 < 0 (11, 4) 3+4=1-3 + 4 = 1
3 1 p30p_3 \geq 0 (12, 3) 1+(6)=51 + (-6) = -5
4 -5 p4<0p_4 < 0 (12, 2) 5+4=1-5 + 4 = -1
5 (12, 1)

Step D: Final Plotted Points

The pixels plotted are:

  • (10, 6)(11, 5)(11, 4)(12, 3)(12, 2)(12, 1)

Conclusion

Bresenham's algorithm is superior to DDA as it avoids floating-point arithmetic entirely, making it faster and more suitable for hardware implementation. The algorithm efficiently determines the closest pixel positions using only integer addition and a simple decision parameter.

2.
How decision parameter can be used to draw circle? Calculate the points to draw a circle having radius 5 and center as (10, 5).[10]
3.
Draw the block diagram of vector and raster graphics display architecture and write the advantages and disadvantage of both display architecture.[10]
Section B

Short Answers Questions

Attempt any Eight questions.
[8*5=40]
4.
Discuss the use of computer graphics in different areas. [5]
5.
Describe polygon, vertex and edge table of a polygon. [5]
6.
What is boundary representation technique? Explain. [5]
7.
Explain the Phong illumination model for specular reflection. [5]
8.
Write short notes on: a. Shearing and Scaling b. Line Clipping [5]
9.
Explain how can line method detects the visible surface with example. [5]
10.
Differentiate Phong Shading with Gouraud Shading method. [5]
11.
Explain Cohen-Sutherland line clipping Algorithm. [5]
12.
What is Bezier curve? Describe its properties. [5]