0% found this document useful (0 votes)
28 views5 pages

Line Drawing Algorithm

The document discusses line drawing algorithms used in computer graphics. It describes the Digital Differential Analyzer (DDA) algorithm and Bresenham's line algorithm. The DDA algorithm uses incremental integer calculations at each step. Bresenham's algorithm is also based on integer calculations and is faster than DDA. It selects pixels that are closest to the true line to draw it, in an efficient way using addition, subtraction and multiplication operations.

Uploaded by

Sneha Martin
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)
28 views5 pages

Line Drawing Algorithm

The document discusses line drawing algorithms used in computer graphics. It describes the Digital Differential Analyzer (DDA) algorithm and Bresenham's line algorithm. The DDA algorithm uses incremental integer calculations at each step. Bresenham's algorithm is also based on integer calculations and is faster than DDA. It selects pixels that are closest to the true line to draw it, in an efficient way using addition, subtraction and multiplication operations.

Uploaded by

Sneha Martin
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/ 5

Line drawing algorithm

In computer graphics, a line drawing algorithm is an algorithm for approximating a line


segment on discrete graphical media, such as pixel-based displays and printers.

On such media, line drawing requires an approximation (in nontrivial cases). Basic


algorithms rasterize lines in one color. A better representation with multiple color gradations requires
an advanced process, spatial anti-aliasing.

The formula for a slope line interception is:

Y = mx + b

In this formula, m is the slope line and b is the line’s intercept of y. Two endpoints
for the line segment are supplied in coordinates (x1, y1) and (x2, y2).
Properties of a Line Drawing Algorithm
These Algorithm has the following characteristics.

 Input: At least one or more inputs must be accept a good algorithm.


 Output: At least one output must produced an algorithm.
 An algorithm should be precise: The algorithm’s each step must well-define.
 Finiteness: Finiteness is require in an algorithm. It signifies that the algorithm will
come to a halt once all of the steps have been complete.
 Correctness: An algorithm must implemented correctly.
 Uniqueness: The result of an algorithm should be based on the given input, and all
steps of the algorithm should be clearly and uniquely defined.
 Effectiveness: An algorithm’s steps must be correct and efficient.
 Easy to understand: Learners must be able to understand the solution in a more
natural way thanks to an algorithm.

Types of Line Drawing Algorithm


For drawing a line, the following algorithms are use:

 DDA (Digital Differential Analyzer) Line Drawing Algorithm

 Bresenham’s Line Drawing Algorithm

Digital Differential Algorithm ( DDA)


A DDA Algorithm, also known as a Digital Differential Algorithm, is an incremental
conversion method. Moreover, The usage of the results from the preceding stage in
each calculation distinguishes this method.
Advantages of Digital Differential Analyzer
 Firstly, It’s a straightforward algorithm to implement.

 The direct line equation is a slower algorithm.

 In the Digital Differential Analyzer, we are unable to apply the multiplication


approach.

 When a point changes its location, the Digital Differential Analyzer method alerts us
about the overflow.

DDA Algorithm Limitations


 Firstly, It takes a long time to do floating point arithmetic and rounding points.

 A round-off mistake may cause the measured pixel location to deviate from the true
long-line segment path.

Bresenham's Line Algorithm


This algorithm is used for scan converting a line. It was developed by Bresenham. It is
an efficient method because it involves only integer addition, subtractions, and
multiplication operations. These operations can be performed very rapidly so lines can
be generated quickly.

The Bresenham Line Algorithm 


In 1962, “Jack Elton Bresenham” proposed this algorithm. This algorithm aids in the
conversion of a line’s scan. It’s a strong, useful, and precise method. Furthermore, To
draw a line, we employ incremental integer calculations. Addition, subtraction, and
multiplication are among the integer calculations.
In addition, We must determine the slope (m) between the starting point and the final
point in Bresenham’s Line Drawing procedure.

Advantages of Bresenham’s Line Drawing


Algorithm
The following are the benefits of the Bresenham line algorithm:

 An incremental algorithm that is quick.

 Only integer computations are use in this.

Disadvantages of Bresenham’s Line Drawing


Algorithm
 Bresenham’s Line Drawing Algorithm only aids in the creation of fundamental lines.

 The drawn line is not smooth as a result.

In this method, next pixel selected is that one who has the least distance from true
line.

The method works as follows:

Assume a pixel P1'(x1',y1'),then select subsequent pixels as we work our may to the
night, one pixel position at a time in the horizontal direction toward P 2'(x2',y2').

Once a pixel in choose at any step

The next pixel is

1. Either the one to its right (lower-bound for the line)


2. One top its right and up (upper-bound for the line)

The line is best approximated by those pixels that fall the least distance from the path
between P1',P2'.

You might also like