Beruflich Dokumente
Kultur Dokumente
(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
• https://www.tutorialspoint.com/computer_graphics/line_generation_algorit
hm.htm
• http://personales.unican.es/iglesias
• https://www.geeksforgeeks.org/dda-line-generation-algorithm
• https://www.tutorialspoint.com/.../line_generation_algorithm.htm
• www.codingalpha.com/dda-line-drawing-algorithm-c-program