Thursday, June 13, 2019

DDA line drawing algorithm in c

DDA line drawing algorithm
(Digital Differential Analyzers)

Digital Differential Analyzers is the scan conversion line algorithm , which is based on calculating del y or del x, sample of the line and unit intervals in one coordinate and determine corresponding integer values nearest the line path for the coordinates. Consider first a line with positive slope. If the slop is less then or equal to one be sample at unit. X interval
                del x = 1
     and complete each successive y value as

                                yk+1 = yk + m                         (6)

    subscript k takes integer value starting from 1 for the 1st point & the inversed by 1 unit the find end point is reached.
For lines with the positive with the positive stop that greater then 1 we reverts the role of y i.e we sample at wait y interval

del y = 1

and calculate each successive x value as

                                xk+1 = xk +  1/m                      (7)

from equation 6 and 7
are based on the assumption that lines are to be processed from left to right.
If the processing is reverse that is from right to left then be have

                                Del x = del y = -1

So ,
                                yk+1 = yk – m                         (8)
                                xk+1 = xk  -1/m                   (9)

also check this post :- line-drawing-algorithm

No comments:

Post a Comment