Page 30 - Computer Graphics
P. 30

29

               Digital Differential Analyzer Algorithm


                                      {
                                                    dx=x2 - x1

                                                    dy=y2 - y1

                                           if(abs(dx) > abs(dy))

                                                  step abs(dx)

                                                         else

                                                  step abs(dy)

                                                x inc = dx/step

                                                y inc = dy/step

                                        for(i=1 ; i<=step ; i++)

                                             put pixel (x1 , y1)

                                                  x1=x1 + x inc

                                                  y1=x1 + y inc


                           }


                   1.  The DDA algorithm is a faster method for calculating pixel positions
                   2.  Appropriate increments are applied in the x or y direction to step to pixel
                       positions along the line path
                   3.  We consider more general scan-line procedures that can be applied to both

                       lines and curves
   25   26   27   28   29   30   31   32   33   34   35