0% found this document useful (0 votes)
34 views11 pages

CGM Unit 2 Question Bank

The document provides information about various computer graphics algorithms including: - The DDA line drawing algorithm which incrementally calculates the next point along a line using the slope and initial coordinates. - Bresenham's line drawing algorithm which uses integer rounding to determine the next point along the line. - Midpoint circle drawing algorithm which generates points on a circle by calculating the midpoint between each pair of points. - Bresenham's circle drawing algorithm which approximates a circle by plotting pixels around a circumference using integer rounding similar to the line algorithm. - Questions are provided asking to apply these algorithms to draw lines, circles, and ellipses given different starting/end points and radii. Worked examples

Uploaded by

Abhishek Kumar
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)
34 views11 pages

CGM Unit 2 Question Bank

The document provides information about various computer graphics algorithms including: - The DDA line drawing algorithm which incrementally calculates the next point along a line using the slope and initial coordinates. - Bresenham's line drawing algorithm which uses integer rounding to determine the next point along the line. - Midpoint circle drawing algorithm which generates points on a circle by calculating the midpoint between each pair of points. - Bresenham's circle drawing algorithm which approximates a circle by plotting pixels around a circumference using integer rounding similar to the line algorithm. - Questions are provided asking to apply these algorithms to draw lines, circles, and ellipses given different starting/end points and radii. Worked examples

Uploaded by

Abhishek Kumar
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/ 11

2160323: Computer Graphics and Multimedia

Question Bank
1. Describe in detail about the DDA line scan conversion algorithm.
The incremental technique is used in this algorithm.
 It means that we can find the next coordinates by using past coordinates as a guide.
 In this method, the difference of pixel point is analyzed and according to the analysis, the
line can be drawn.

We’ll start with the initial position and work our way to the ending position by looking for
intermediate places. The slope of the line will be the ratio of difference of y-coordinates and
the difference of x-coordinates.

Δy = ( y2 -y1 ), Δx = (x2 - x1)


where, (x1, y1) and (x2, y2) are the endpoints.
The Digital Differential Analyzer algorithm is based on the values of Δx and Δy.

Δy = m * Δx , Δx = Δy / m
The value of the slope will be either positive or negative. If the value of the slope is positive then
the values of Δx and Δy are increased otherwise their values are decreased.

(i). If (m < 1): xN = x1 + 1 , yN = y1 + m


(ii). If (m > 1): xN = x1 + 1 / m , yN = y1 +1
(iii). If (m = 1): xN = x1 + 1 , yN = y1 + 1
2. Write down and explain the midpoint circle drawing algorithm.
3. Write Mid-point Ellipse generation Algorithm.

4. Write Generalized Bresenham’s line generating algorithm.


5. Explain in detail about Bresenham’s circle generating algorithm. Give example.
Step7: Plot eight points by using concepts of eight-way symmetry.
The center is at (xc, yc).
Current active pixel is (x, y).
putpixel (x+xc, y+yc)
putpixel (y+xc, x+yc)
putpixel (-y+xc, x+yc)
putpixel (-x+xc, y+yc)
putpixel (-x+xc, -y+yc)
putpixel (-y+xc, -x+yc)
putpixel (y+xc, -x+yc)
putpixel (x+xc, -y+yc)
6. Explain in detail about Bresenham’s line generating algorithm. Give example.

7. Digitize a line from (10, 12) to (15,15) on a raster screen using Bresenham’s straight
line algorithm.

To illustrate the algorithm, we digitize the line with endpoints (20, 10) and (30, 18)

This line has a slope of 0.8, with

dx =10, dy =8

The initial decision parameter has the value: p = 20dy – dx = 6 and the increments for calculating

successive decision parameters are 20dy = 16, 2dy – 2dx = -4

We plot the initial point = (20, 10), and determine successive pixel positions along the line path from the

decision parameter as:

8. Using the DDA algorithm digitize a line with end points (10,15) and (15,30).

9. Digitize a line with end points (20, 10) and (30, 18) using DDA line drawing Algorithm.

10. Implement the DDA algorithm to draw a line from (0,0) to (6,6).

Let us first calculate the slope of the given line


m = (6-0)/(6-0) = 1
Since the slope of the line is 1, we will sample the points at unit x intervals i.e. dx=1
then the next point on y axis corresponding to the previous point plotted will be
y(k+1) = y(k) + m
The table below shows the points to be plotted
(x,y)
(0,0)
(1,1)
(2,2)
(3,3)
(4,4)
(5,5)
(6,6)

11. Draw the line using simple DDA and point of line are (8,5) and (13,12).
Certainly! Here's how to solve the problem of drawing a line using the DDA algorithm with points (8, 5) and
(13, 12), along with the mathematical explanation:

1. Calculate dx and dy:


 dx = x2 - x1 = 13 - 8 = 5
 dy = y2 - y1 = 12 - 5 = 7
2. Determine the number of steps:
 Steps = max(|dx|, |dy|) = max(5, 7) = 7
3. Calculate the step size for x and y:
 Δx = dx / steps = 5 / 7 ≈ 0.714
 Δy = dy / steps = 7 / 7 = 1
4. Initialize variables:
 x = x1 = 8
 y = y1 = 5
5. Iterate through each step:
 For i = 0 to steps:
o Plot the point (x, y)
o Calculate the next point using DDA formula:
 x_next = x + Δx
 y_next = y + Δy
o Update x and y for the next iteration:
 x = x_next
 y = y_next
6. Plot the last point:
 Plot the point (x, y) after the final iteration.
Mathematical explanation:

The DDA algorithm leverages the concept of incremental steps to trace a line between two points. In each
step, we move a small distance in both x and y directions based on their relative changes (dx and dy). The
step size is determined by the larger change in x or y to ensure we reach the endpoint in equal steps.

The DDA formula for calculating the next point coordinates is:

 x_next = x + Δx
 y_next = y + Δy
This formula essentially adds the step size in x and y directions to the current coordinates to reach the next
point along the line.

Points generated:

By following these steps, you'll calculate the following points along the line:

(8, 5), (8.71, 6), (9.43, 7), (10.14, 8), (10.86, 9), (11.57, 10), (12.29, 11), (13, 12)

This set of points represents the discrete approximation of the line segment between (8, 5) and (13, 12).

12. Draw the line using simple DDA and point of line are (0,0) and (10,5).
Solving the line drawing using DDA algorithm for points (0, 0) and (10, 5):

Here's the solution for drawing the line using the DDA algorithm with points (0, 0) and (10, 5):

1. Calculate dx and dy:


 dx = x2 - x1 = 10 - 0 = 10
 dy = y2 - y1 = 5 - 0 = 5
2. Determine the number of steps:
 Steps = max(|dx|, |dy|) = max(10, 5) = 10
3. Calculate the step size for x and y:
 Δx = dx / steps = 10 / 10 = 1
 Δy = dy / steps = 5 / 10 = 0.5
4. Initialize variables:
 x = x1 = 0
 y = y1 = 0
5. Iterate through each step:
 For i = 0 to steps:
o Plot the point (x, y)
o Calculate the next point using DDA formula:
 x_next = x + Δx = x + 1
 y_next = y + Δy = y + 0.5
o Update x and y for the next iteration:
 x = x_next
 y = y_next
6. Plot the last point:
 Plot the point (x, y) after the final iteration.
Points generated:

By following these steps, you'll calculate the following points along the line:

(0, 0), (1, 0.5), (2, 1), (3, 1.5), (4, 2), (5, 2.5), (6, 3), (7, 3.5), (8, 4), (9, 4.5), (10, 5)

These points represent the discrete approximation of the line segment between (0, 0) and (10, 5) using the
DDA algorithm.

13. Consider the line from (5,5) and (13,9). Use the Bresenham’s algorithm to rasterize the line.

14. Consider the line from (0,0) and (6,7). Use the Bresenham’s algorithm to rasterize the line.

15. Consider the line from (1,2) and (3,10). Use the Generalized Bresenham’s algorithm
torasterize the line.

16. Consider the line from (-3,3) and (4,-4). Use the Generalized Bresenham’s algorithm
torasterize the line.

29. Consider the line from (0,0) and (-6,6). Use the Bresenham’s algorithm to rasterize the line.

30. Find the pixel position approximating the first octant of a circle having a center (2,3) and
aradius of 2 units, using bresenhams circle algorithm.

31. Plot a circle at (5,5) having a radius of 5 units using mid-point circle algorithm.

32. Plot a circle at (2,5) having a radius of 7 units using mid-point circle algorithm.

33. Find the pixel position approximating the first octant of a circle having a center (2,3) and
aradius of 2 units, using Bresenhams circle algorithm.

34. Find the pixel position approximating the first octant of a circle having a center (10,13)
anda radius of 5 units, using Bresenhams circle algorithm.
35. Apply DDA circle algorithm plot a circle on origin whose radius 10 units.

You might also like