Page 29 - Computer Graphics
P. 29

28

               Line Drawing Algorithms



               Slope-intercept equation for a straight line
               y=mx+c
               Where m represents the slope of the line and c as the y intercept

               Given that the two endpoints of a line segment are steadied at positions (x1 , y1)
               and (x2 , y2)

               Determine the values of the slope m and y intercept c with the help of this formula
               c=y1 - m.x1 > m= (y2-y1)  (x2-x1)

                   1.  slope magnitudes m < 1 dx can be set proportional to a small horizontal
                       deflection voltage
                   2.  slope  magnitudes  m >  1  dy  can be set proportional  to  a small  vertical
                       deflection voltage
                   3.  slope magnitudes m = 1 , dx=dy can be set proportional to a horizontal and
                       vertical deflection voltage equal



                                                x1
                                                x2


                                                         x1   x2


               Digital differential analyser algorithm (DDA)
               The digital differential analyser (DDA) is a scan-conversion line algorithm based
               on calculating either dy , (dy = dx/m) or dx , (dx = dy/m) using We sample the
               line  at  unit  in  terrals  in  one  coordinate  and  determine  corresponding  integer
               values nearest the line path for the other coordinate.

                   1.  Slope is less than or equal to 1 (m≥1), we sample at unit x intervals (dx =

                       1) and compute each successive y value.
                       Yk+1 = Yk+ m
                   2.  Subscript k takes integer values starting from 1, for the first point, and

                       increases by 1 until the final endpoint is reached.
                   3.  m can be any real number between 0 to 1.
                   4.  y values must be rounded to the net integer.

                          1.  When slope is greater than 1 (m > 1) .
                          2.  Then calculate each succeeding x value

               Xk+1 = Xk + 1/m
   24   25   26   27   28   29   30   31   32   33   34