0% found this document useful (0 votes)
33 views12 pages

Graphics

The document describes the DDA (Digital Differential Analyzer) line drawing algorithm. It includes sections on the algorithm, pseudocode, advantages, and disadvantages. The key points are: - DDA is used for rasterization of lines, triangles, and polygons in computer graphics. It calculates intermediate coordinate points to draw a line between two given points. - The pseudocode shows the steps: calculate change in x and y, set pixel at starting point, increment x and y by change amounts in a loop until the end point is reached. - Advantages are it is faster than direct line equations and uses only additions. Disadvantages include rounding errors accumulating and being orientation dependent.

Uploaded by

HARSH ANAND
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views12 pages

Graphics

The document describes the DDA (Digital Differential Analyzer) line drawing algorithm. It includes sections on the algorithm, pseudocode, advantages, and disadvantages. The key points are: - DDA is used for rasterization of lines, triangles, and polygons in computer graphics. It calculates intermediate coordinate points to draw a line between two given points. - The pseudocode shows the steps: calculate change in x and y, set pixel at starting point, increment x and y by change amounts in a loop until the end point is reached. - Advantages are it is faster than direct line equations and uses only additions. Disadvantages include rounding errors accumulating and being orientation dependent.

Uploaded by

HARSH ANAND
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

DDA Line Drawing

Algorithm

• Ankit Kumar (14)


Group Members:
• Anurag Ranjan (17)
• Jyoti Prakash Maurya (47)
Contents
1.Introduction
2.Algorithms
3.Pseudo code of DDA
4.Advantage of DDA
5.Disadvantes of DDA
6.Conclusion
7.Acknowledgement
Introduction

Digital differential analyzer (graphics


algorithm) ... 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.
Algorithm

In any 2-Dimensional plane if we connect two


points (x0, y0) and (x1, y1), we get a line
segment. But in the case of computer graphics
we can not directly join any two coordinate
points, for that we should calculate
intermediate point’s coordinate and put a pixel
for each intermediate point.
Continue….

Step1:  Start Algorithm


Step2:  Declare x1,y1,x2,y2,dx,dy,x,y as integer variables.
Step3:  Enter value of x1,y1,x2,y2.
Step4:  Calculate dx = x2-x1
Step5:  Calculate dy = y2-y1
Step6:  If ABS (dx) > ABS (dy)
            Then step = abs (dx)
            Else
Step7:  xinc=dx/step
            yinc=dy/step
            assign x = x1
            assign y = y1
Step8:  Set pixel (x, y)
Step9:  x = x + xinc
            y = y + yinc
            Set pixels (Round (x), Round (y))
Step10: Repeat step 9 until x = x2
Pseudo Code
#include<graphics.h>  
#include<conio.h>  
#include<stdio.h>  
void main()  
{  
    intgd = DETECT ,gm, i;  
 float x, y,dx,dy,steps;  
    int x0, x1, y0, y1;  
    initgraph(&gd, &gm, "C:\\TC\\BGI");  
    setbkcolor(WHITE);  
    x0 = 100 , y0 = 200, x1 = 500, y1 = 300;  
    dx = (float)(x1 - x0);  
    dy = (float)(y1 - y0);  
    
Continue..

if(dx>=dy)  
           {   steps = dx;  }  
    else  
           {  steps = dy;  }  
    dx = dx/steps;  
    dy = dy/steps;  
    x = x0;  y = y0;  
    i = 1;  
    while(i<= steps)  
    {  putpixel(x, y, RED);  
        x += dx;  
        y += dy;  
        i=i+1; }  
     getch();  
     closegraph();  
}  
Advantage of DDA

1. It is a faster method than method of using direct use


of line equation.
2. This method does not use multiplication theorem.
3. It allows us to detect the change in the value of x
and y ,so plotting of same point twice is not possible.
4. This method gives overflow indication when a point
is repositioned.
5. It is an easy method because each step involves just
two additions.
Disadvantage of DDA

1. It involves floating point additions rounding off is


done. Accumulations of round off error cause
accumulation of error.
2. Rounding off operations and floating point
operations consumes a lot of time.
3. It is more suitable for generating line using the
software. But it is less suited for hardware
implementation.
4. The algorithm is Orientation Dependent, hence its
end point accuracy is poor.
Conclusion
Acknowledgement

You might also like