DDA Line drawing Algorithm with solved example is covered here.
Size: 981.06 KB
Language: en
Added: Feb 07, 2024
Slides: 18 pages
Slide Content
LINE DRAWING ALGORITHM Prof. Sujata L. Sonawane Assistant Professor Department of Artificial Intelligence and Machine Learning P.E.S. Modern College of Engineering, Pune .
Basic Concepts in Line Drawing Requirements specify the desired characteristics of line: Line should appear as straight lines and should start and end accurately. should be displayed with constant brightness along its length independent of its length and orientation should be drawn rapidly.
Complex calculations are required to provide the equal brightness along lines of varying length and orientation. To draw lines rapidly some compromises are made such as Calculate only an approximate line length. Reduce the calculations using simple integer arithmetic. Implement the result in hardware or firmware.
Digital Differential Analyzer (DDA) WITH SOLVED EXAMPLE
The line (vector) generation algorithms which determine the pixels that should be turned ON are called as digital differential analyzer (DDA). It is one of the technique for obtaining a rasterized straight line. This algorithm can be used to draw the line in all the quadrants. DDA LINE DRAWING ALGORITHM
DDA ALGORITHM
Example Δ x = |x 2 -x 1 | = |4-0| = 4 Δ y = |y 2 -y 1 | = |6-0| = 6
Put x and y values in table as given below
x = x + Δ x y = y + Δ y = 0.5 + (4/6) = 0.5 + (1) = 1.167 = 1.5 Similarly find the values of x and y till i <=length
Plot the points.
It shows that the rasterized line lies to both sides of actual line, .i.e. the algorithm is orientation dependent.
Advantages and Disadvantages of DDA Advantages : Simplest line drawing algorithm No special skills required for its implementation DDA draws the line faster than drawing the line by directly using the line equation. Disadvantages : It dependents on orientation which makes the end point accuracy poor. It requires floating point addition to determine each successive point which is time consuming. Error due to limited precision in floating point representation may cause calculated points to shift away from their actual position when the line is relatively long.
Solve Consider the line segment from A(-2,-1) to B(6,3). Use the DDA line Drawing algorithm to rasterize this line. Consider the line from (0,0) to (-6,-6). Use the simple DDA algorithm to rasterize this line. Consider a line from A (5,7) to B (10, 15). Use DDA line drawing algorithm to rasterize the line from A to B. Draw the pixel wise rasterization of Line.