[go: up one dir, main page]

0% found this document useful (0 votes)
24 views15 pages

4.3 DDA Algorithm

The document discusses the DDA (Digital Differential Analyzer) line drawing algorithm used in computer graphics to approximate line segments on discrete graphical media. It explains the concepts of lines, line equations, and slope conditions, along with examples of drawing horizontal, vertical, and diagonal lines. Additionally, it outlines the limitations of the DDA algorithm, such as lack of decimal points in the coordinate system and potential time consumption due to floating number generation.

Uploaded by

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

4.3 DDA Algorithm

The document discusses the DDA (Digital Differential Analyzer) line drawing algorithm used in computer graphics to approximate line segments on discrete graphical media. It explains the concepts of lines, line equations, and slope conditions, along with examples of drawing horizontal, vertical, and diagonal lines. Additionally, it outlines the limitations of the DDA algorithm, such as lack of decimal points in the coordinate system and potential time consumption due to floating number generation.

Uploaded by

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

UNIT - 1

Computer Graphics andVisualization

DDA Line Drawing


Algorithm

By
Miss. T. Sarah Jeba Jency, M.Sc., M.Phil., B.Ed.,
Talk Sequence:
• What isLine
• Line Equation
• Slope of Line
• Examples of DrawingLine
• DDA
DDA Line DrawingAlgorithm

• DDA stands for Digital Differential Analyzer


• A line drawing algorithm is a graphical algorithm for approximating a line
segment ondiscrete graphical media.
• This algorithm is used to draw a line on computer pixels.
What is aLine?
• A line in Computer graphics typically refers to line segment, which is a
portion of straight line that extends indefinitely in opposite direction.
• It is defined by its two end points & the slope intercept equation for a line:
y = mx +b
where, m = Slope of the line
b = the y intercept of a line
• The two endpoints of a line segment are specified at positions (x1,y1) and
(x2,y2).
Slope Conditions for Algorithms

• 1. ∆ y/ ∆ x > 1 when 0 >45 1

• 2. ∆ y/ ∆ x < 1 when 0 <45


• 3. ∆ y /∆ x = 1 when 0 =45 2
For Horizontal line

(x1,y1)(x2,y2)
(2,2) (9,2) X Y

∆ x=9-2=7 2 2
9
3 2
∆ y=2-2=0 4 2
8
m= ∆ y/ ∆ x=0/7=0 5 2
7
6 2
6
xinc=7/7=1 5
7 2
yinc=0/7=0 8 2
4
9 2
3
2
1

1 2 3 4 5 6 7 8 9 10
For Horizontal line

(x1,y1)(x2,y2)
(2,2) (9,2) X Y

∆ x=9-2=7 2 2
9
3 2
∆ y=2-2=0 4 2
8
m= ∆ y/ ∆ x=0/7=0 5 2
7
6 2
6
xinc=7/7=1 5
7 2
yinc=0/7=0 8 2
4
9 2
3
2
1

1 2 3 4 5 6 7 8 9 10
For Vertical line

(x1,y1)(x2,y2)
(2,3) (2,8)
∆ x=2-2=0 X Y 9
∆ y=8-2=6 2 3 8
m= ∆ y/ ∆ x=6/0=∞ 2 4 7
2 5 6
xinc=0/6=0 2 6 5
yinc=6/6=1 2 7 4
2 8 3
2
1

1 2 3 4 5 6 7 8 9 10
For Vertical line

(x1,y1)(x2,y2)
(2,3) (2,8)
∆ x=2-2=0 X Y 9
∆ y=8-2=6 2 3 8
m= ∆ y/ ∆ x=6/0=∞ 2 4 7
2 5 6
xinc=0/6=0 2 6 5
yinc=6/6=1 2 7 4
2 8 3
2
1

1 2 3 4 5 6 7 8 9 10
For any Diagonal line

(x1,y1)(x2,y2)
(1,2) (9,5) X Y

∆ x=9-1=8 1 2
9
2 2.37=2
∆ y=5-2=3 3 2.74=3
8
m= ∆ y/ ∆ x=3/8=0.37 4 3.11=3
7
6
xinc=8/8=1 5 3.48=3
5
6 3.85=4
yinc=3/8=0.37 7 4.22=4
4
3
8 4.59=5
2
9 4.96=5
1

1 2 3 4 5 6 7 8 9 10
For any Diagnal line

(x1,y1)(x2,y2)
(1,2) (9,5) X Y

∆ x=9-1=8 1 2
9
2 2.37=2
∆ y=5-2=3 3 2.74=3
8
m= ∆ y/ ∆ x=3/8=0.37 4 3.11=3
7
6
xinc=8/8=1 5 3.48=3
5
6 3.85=4
yinc=3/8=0.37 7 4.22=4
4
3
8 4.59=5
2
9 4.96=5
1

1 2 3 4 5 6 7 8 9 10
DDA Algorithm
dx-=x2-x1;
dy=y2-y1;
If(abs(dx) >abs(dy))
Steps=abs(dx);
else
Steps=abs(dy);
xinc=dx/steps;
yinc=dy/steps;
For(i-1, i<=step, i++)
{
putpixel(x1,y1);
x1=x1+xinc;
y1=y1+yinc;
}
Limitation

• There are no decimal points in coordinate system


• Time consuming because algorithm may generate floating numbers
• Line generated will not be smooth.
THANK YOU

You might also like