Question

Write the DDA algorithm and Bresenham Line generation Algorithm. Compare the line generation mechanism of DDA algorithm with Bresenham Line generation Algorithm while drawing a line segment from (1, 0) and (9, 8). Show step by step execution of both Line Generation algorithm, though a Graph.

16 Sep 2022
Answer :
Word Count : 1820

DDA Algorithm:
The Digital Differential Analyzer (DDA) algorithm is a simple line drawing algorithm that works by dividing the line into equal parts and calculating the coordinates of each point in the line using the slope of the line.

Here's the pseudocode for the DDA algorithm:


Inputs: (x1, y1) and (x2, y2), the endpoints of the line
Output: The coordinates of all the pixels that fall on the line between (x1, y1) and (x2, y2)

slope = (y2 - y1) / (x2 - x1)
x = x1
y = y1

while (x <= x2):
    plot(x, round(y))
    x = x + 1
    y = y + slope
In the algorithm, we first calculate the slope of the line, which tells us how much y changes for every x increment. Then, we start at the first endpoint of the line (x1, y1) and increment x by 1 each time, calculating the corresponding y coordinate using the slope. We then plot the pixel at (x, round(y)), where round(y) is the nearest integer to y. We continue this process until we reach the second endpoint of the line (x2, y2).

Bresenham Line Generation Algorithm:
The Bresenham line drawing algorithm is a more efficient algorithm for drawing lines than the DDA algorithm. It works by incrementally calculating the best pixel to draw at each step, based on the difference between the actual slope of the line and the slope of a hypothetical "ideal" line.

Here's the pseudocode for the Bresenham line drawing algorithm:


Inputs: (x1, y1) and (x2, y2), the endpoints of the line
Output: The coordinates of all the pixels that fall on the line between (x1, y1) and (x2, y2)

dx = abs(x2 - x1)
dy = abs(y2 - y1)

if (x1 < x2):
    sx = 1
else:
    sx = -1

if (y1 < y2):
    sy = 1
else:
    sy = -1

err = dx - dy

while (x1 != x2) or (y1 != y2):
    plot(x1, y1)
    e2 = 2 * err
    if (e2 > -dy):
        err = err - dy
        x1 = x1 + sx
   

_____ _______ ____ _____ _______ ________ ____ _______ ________.
___ ____ ______ _________ _____ ________.
___ ___ ___ _________ _________ _____ _______ ______ __________ _____.
___ ______ ________ ___ _______ ____ _________ _______ ___ ______.
______ _______ ______ _________ _____ _______ ____ _____ ______ __________ _________ _____.
______ ______ __________ _________ ___ ________ ____ __________ _________.
____ _______ ________ __________ __________ ________ ____ __________.
____ ___ _________ _________ __________ ________ __________ __________ _______ ______ _______ ___.
________ ________ ______ _____ _________ ________ ___ _________.
________ ____ ________ ___ ___.
_____ ____ ______ _____ _____ ________ __________ _________ _______.
_____ ____ _______ _____ ________ ____ _______.
____ _________ _____ ________ ______.
______ _____ ______ _______ ____ ____ _______ _______ _________.
_______ ____ ____ _______ _______.
____ ______ ____ ___ ____.
________ ______ __________ _____ _________ ________ _______ _____ _______ ______ _____.
___ ____ ________ ___ _________ _____ ______ ___ __________ ________ ______.
__________ __________ __________ ____ ___ ______ _______ _______ _________ _________ ___.
________ ___ _________ _______ ________ ______ _________ ________ ______.
___ ______ ________ ______ _____ ______ _______.
_________ ___ __________ ____ _____ _____ _______ _____ _____ ____.
______ ___ ____ __________ __________ _____ ____ _______ _______ _______ ________.
_______ __________ ___ ___ __________ __________ ____ ______ ___ _______ ________ ____.
____ _____ __________ _____ _____ _____.
___ _______ ___ _______ _________.
__________ _________ ________ ________ ____ _________ ____ ______.
________ ___ _______ ___ _______ __________ __________ __________ ___ ____ __________ ____.
_____ ____ ______ ________ _______ ___ _______ ________ __________ ______.
_________ ____ _____ _____ ________ _______ ________ _____.
____ ____ ________ _________ _________ ___ ______ ________ ____ _________.
_________ _________ _______ _____ __________ _____ ____ __________ ______.
__________ ______ _________ _____ _________ _____ ______ ________.
______ _____ ________ _________ _________ ___ _________ ______ __________.
_____ ______ _________ ________ ______ _____.
_________ ___ ______ _________ ____ ______.
_______ ______ __________ ______ _________ ________ ______ ________ _______ _______ ______.
____ _______ ________ ____ _____ ______ ____ ____ ____ _________ _______ _______.
_____ ___ _______ _______ ______ ________ ____ ________ _________ _____ _________.
__________ _______ _______ _________ __________ ______ ________.
________ _________ ____ _________ ________.
____ ________ ___ __________ _________ _______.
_____ ______ _________ ______ _________ ________ ______ ______ __________ _______ _____.
_______ _____ ___ _______ _______ ______.
________ __________ _____ _______ _____ ____ ___ ___ __________ __________ _______ ________.
______ __________ __________ __________ ________.
_____ _____ ______ __________ ________ _____ ___.
______ ____ _____ ________ ____ _______ _______ _______ ______ ________ _________ ____.
__________ ________ _____ ______ ____ ________.
__________ _________ _____ ____ _________ _______.
______ ________ ________ _______ __________ ________ ___ ____.
____ ____ _______ ___ ______ ____ _________ _______.
_________ ___ __________ ________ _____ ______ ___ _______ __________ __________ ________ _____.
__________ ________ ____ __________ ___.
_______ ______ __________ ________ _____ _________ __________ ________ ______ _______.
______ _______ _______ _______ ________ ____ _____ ________ _______ _____.
______ ________ ___ _______ ___ _________ ___ __________ ________ ___ ___ ________.
_______ ________ _________ _______ _______ _______ ________ ______ _________.
____ _______ ______ ______ ____ _______ _____ _____.
________ ______ ________ _______ ________ ________ _________ _____ ____.
_______ ___ __________ ________ ________ _______.
_______ _________ _______ _______ ________.
_______ __________ _________ _________ _____ __________ ________ _____ ___ _________ ______.
__________ _______ _______ ______ __________ ______ _______.
______ _____ ______ ________ ________ ________ ___ __________ _________ _____.
________ ______ ____ _______ __________ ____ ____.
_______ ____ _________ _______ _______ ________ ___ ________ ___ _____.
________ ______ _______ __________ _________ __________ ____ _________ ____ ______ _________.
___ _________ _____ ____ _______ ________ ___ __________ _______ ___.
______ ____ ___ ______ ____ ______ _______ ______ _____.
___ ____ ______ ___ _______ __________ ____ __________ _________ ____ ____ ____.
_________ __________ ____ _____ __________ ____ _________ _________.
____ _______ ______ ___ ______ _________ ___ ______ __________ ______ __________ ____.
_____ _____ _______ ___ ______ _____ _______.
_______ __________ ________ ______ _____ ______ _______ ________ ______ ___.
________ ________ ______ ________ ________ ____ __________ ________ ________ ___ ____ _______.
___ ______ __________ __________ ___ _____ _______ ________ _______.
______ ___ __________ ________ _________ _________ _________ ________.
______ __________ ___ __________ _____ _____ _________ _________ __________.
_____ __________ _________ _______ ____ __________ ____.
_______ ____ ___ _________ _________ _________ _________ ____ __________ _______.
_____ ___ ___ ___ ___ ____ _______ ________ __________ ______ _____.
__________ __________ ____ _____ _______ _________.
________ ___ ___ _____ ____ _____.
_______ _______ __________ ________ ____ ____ ___.
________ ______ ________ _________ ___ ________ ___ ______ _____ ___ _________ ________.
____ ______ _______ ______ ________ ____ ______ _________ _________.
____ _______ _________ ___ __________ __________ __________ ______ _______ _____ __________ ________.
_____ _______ ____ _____ _______ ________ ________ _________ ______ ___ _______.
_________ ____ _______ ____ _________ _________ ______ __________ ___ ______.
______ __________ ____ _______ ______ _________ ____ ____ __________ ______.
__________ ________ ___ ___ _________ ________.
____ ___ ______ __________ ______.
___ ________ _____ __________ __________.
______ ____ _______ ___ ______ ___.
___ _________ ______ ___ _________.
____ ____ ___ ___ _____ ____ ________ ______ ________.
___ _____ ____ __________ ____ ______ __________ _________.
______ ________ ________ ____ _______ ________ _______ _________ __________ __________.
__________ _______ _______ _______ _______ ________.
__________ ____ ___ ______ _________ ____.
________ ___ _______ _________ _____.
_________ _______ ______ _______ _____.
_______ _________ ____ ____ ____ __________ ____ ___ _______.
_______ _____ ________ _________ _________ ________ __________ ___ _________.
_________ __________ ____ _____ _____ _________ _____.
___ _______ ___ _______ ______.
_________ __________ ___ __________ ____ _______ ________ ______ ____ ___ ________ ______.
_______ __________ ___ _______ _________ _____.
____ ____ __________ ______ ______ _______ ____ ______ _________ _______ ______.
________ _______ ______ _____ _____ ______ ___ ________ __________ ______ _____.
_____ __________ ____ _____ _______ ____ _______ __________ ____ _______ _______ ________.
___ ___ ____ _________ ____.
_____ _________ ____ _____ _________ __________ ________ ___ ________ ___ ______ ___.
______ __________ ________ ________ ______.
_________ ____ ____ ________ _____ ______ __________ _____ _____ ____ _____ ________.
_______ ____ ________ _______ _____ _____ _______ ___ ___ ___ _______ ___.
____ ____ ____ ______ __________.
_______ _________ __________ ________ ___ __________ ___ ______ ______ ________ _____ __________.
_________ ________ ________ __________ ___ ___ _______ ____ ______ ____ _____.
________ ______ _____ __________ _________.
___ ________ ___ __________ _______ ________ ____ ________ _____.
_______ ______ ____ ______ ________ ____ ____ _____.
_____ ______ __________ ____ _______ ______ ____ _________ ________ _______ __________ ______.
_________ ____ _____ _______ _______ _____ ________ ______ ____.
_______ _______ _____ ____ ____ __________ _________ ___ __________.
_____ ___ ________ _____ ____ _____ _________ __________ _____ ___.
______ _____ ____ ____ ________ ________ ____ ___.
_____ ___ ________ _______ __________ ________ ______ ______ ________ ______.
___ _________ _________ _______ ______ _________ ______ __________.
___ ___ ________ _______ _____ __________ ________ ________ __________.
__________ _____ ________ ______ _______ ___ _______ _________ ___.
_________ ____ _____ ________ ____ ________ ___ _________ ____ _________ _______ ______.
______ _______ ________ _________ ____ _________ _____.
______ _______ _____ __________ _______ ____ ____ _______ __________ ____ ______.
__________ ___ ____ ______ ________ ______ _______ __________ ____ _________.
_________ __________ __________ _______ ____ _____ _____.
___ ________ _________ ____ __________ _______ _________ _____.
______ _____ ______ __________ ___.
___ ________ ________ ___ _____ ________ _________ ____ __________ ________ __________.
___ _______ _______ _________ ________ ___ ______ ____ _____ _______.
__________ ________ _____ _____ ______ _______ _________ ___ ______ _______ _____.
____ __________ ________ ________ __________ __________ ____ __________ _____ __________ _____.
______ _________ ___ _______ ________ ______ ________.
_____ _____ _________ __________ ______.
___ ____ _____ ______ _______ __________.
________ ___ ___ _____ ___ __________ ___ ____ ______.
________ ________ ______ __________ _______ ____ ____.
______ _____ ____ ___ _____ _____ _________ ___ ______ ______.
_______ ___ _________ ________ _____ ______ ______ _________ _______ ______ ____.
_________ __________ _________ ___ _____ _____ ___ ________ ___.
_______ ____ ________ ____ _______ _______ _________ __________ ____ ____ ________ __________.
___ ________ ____ ______ _______ ______ _______ _______ _________ ___.
___ __________ ________ _______ ____ ___ ___ ______.
____ ________ ______ _________ ________ _________ _____ __________ ___ ________ ________ _________.
___ _______ ______ ________ ______ __________.
____ __________ _____ _________ _______.
______ ___ _____ ___ ____ ______ ________ ____ ___ _________ _________ _______.
__________ __________ ______ _______ ___.
______ ___ ________ _____ ______ ______ ________ _____.
____ _____ ___ _________ ________ _________ ______ ______ _________ ____ ______.
_________ __________ __________ _______ _________ _________ ______ _________ __________.
____ __________ ________ ___ ___ __________ _________.
____ __________ _______ _____ _______.
___ ________ __________ ______ _________.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU MCS 53 2022 2023 - Write the DDA algorithm and Bresenham Line generation Algorithm. Compa | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→