Digital Differential Analyzer (DDA) Algorithm in Computer Graphics

Slide Note
Embed
Share

In computer graphics, the Digital Differential Analyzer (DDA) Algorithm is utilized as the basic line drawing algorithm. This method involves interpolation of variables between two endpoints to rasterize lines, triangles, and polygons efficiently. The algorithm requires inputting coordinates of two endpoints, calculating increments, and plotting pixels along the line. With advantages such as simplicity and speed, it serves as a fundamental tool for graphics rendering.


Uploaded on Jul 29, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. DDA Line Algorithm Dr. Snehlata Barde Profesor & HoD, MSIT MATS University,Raipur

  2. DIGITAL DIFFERENTIAL ANALYZER (DDA) ALGORITHM. In Computer Graphics the first basic line drawing algorithm is Digital Differential Analyzer (DDA) Algorithm. A line connects two points. It is a basic element in graphics. To draw a line, you need two points between which you can draw a line. In computer graphics, a digital differential analyzer (DDA) is hardware or software used for interpolation of variables over an interval between start and end point. DDAs are used for rasterization of lines, triangles and polygons.

  3. COMPUTER HAS TO TAKE CARE OF 2 THINGS: Pixels - Which pixels to plot. Computations - Computations required to calculate pixel positions

  4. SLOPE INTERCEPT LINEEQ: y = mx + b m = slope b = is the y intercept, is called as slope interceptline equation. Therefore Slope(m) = dy/dx Slope(m) = ??+1-?? /??+1-??

  5. (DDA)ALGORITHM Step 1 Input the coordinates of the Two end points A(x1, y1) and B(x2, y2) for the line AB respectively. Note that points A and B are not equal. (If they are equal, then it is a point. Plot the point and return.) Step 2: [Calculate dx and dy] dx = (x2 x1) and dy = (y2 y1) Step 3: [Calculate the length L] If (abs (x2 x1) >abs (y2 yl)) then L = abs(x2 x1) Else L = abs (y2 y1)

  6. (DDA) ALGORITHM Step 4: [Calculate the increment factor] x = (x2 x1)/L and y = (y2 y1)/L This step makes either x or y equal to 1, because L is either |x2 - x1| or |y2 y1| Therefore, a step increment in x or y direction is equal to 1. Step 5: [Initialize the initial point on the line and plot] xnew=x1 + 0.5 and ynew= ?1+ 0.5 Plot (Integer (????), Integer (????)) The values are rounded using the factor of 0.5 rather than truncating, so that the central pixel addressing is handled correctly. Moreover, the sign function given makes the algorithm work in all the quadrants.

  7. (DDA) ALGORITHM step 6: [Obtain the new pixel on the line and plot the same] Initialize i to 1 While (i<= L){ xnew = xnew+ x ????= ????+ y Plot (Integer(????), Integer(????)) i = i + 1} Step 7: Finish

  8. ADVANTAGES 1. It is the simplest algorithm and it does not require special skills for implementation. 2. It is a faster method for calculating pixel positions than the direct use of equation y=mx + b. It eliminates the multiplication in the equation by making use of raster characteristics, so that appropriate increments are applied in the x or y direction to find the pixel positions along the line path.

  9. DISVANTANGES 1. Floating point arithmetic in DDA algorithm is still time-consuming. 2. The algorithm is orientation dependent. Hence end point accuracy is poor.

More Related Content