0% found this document useful (0 votes)
30 views3 pages

2 Line Circle Algorithms

Yyyu
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)
30 views3 pages

2 Line Circle Algorithms

Yyyu
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

Algorithms

Thursday, April 11, 2024 7:15 PM

(1,1) (2, 1) (3, 1) (4, 1) (5, 1) (6, 1) (7, 1) (8, 1) (9, 1) (10, 1)

DDA Algorithm:

(1,1) -> (10,1)


Start Point (x1 , y1)
End Point (x2 , y2) dx = 10 - 1 = 9
dy = 1 - 1 = 0
dx = x2 - x1
dy = y2 - y1 n = max(dx, dy) 9

Example: xinc = dx / n ; 1
yinc = dy / n ; 0
Start Point (1,1)
End Point (10,6) Sr. X Y Pixel
1 1 1 (1, 1)
dx = 10 - 1 = 9 2 2 1 (2, 1)
dy = 6 - 1 = 5
3 3 1 (3, 1)
4 4 1 (4, 1)
Compare dx and dy dx > dy 5 5 1 (5, 1)
6 6 1 (6, 1)
Number of steps n = dx 7 7 1 (7, 1)
8 8 1 (8, 1)
xinc = dx / n; ( 9/9 = 1 )

Unit - 3 Page 1
6 6 1 (6, 1)
Number of steps n = dx 7 7 1 (7, 1)
8 8 1 (8, 1)
xinc = dx / n; ( 9/9 = 1 )
yinc = dy / n; (5 / 9 = 0.5556 ) 9 9 1 (9, 1)
10. 10 1 (10,1)

(1,3) -> (9,1)

dx = 9 - 1 = 8 (8)
dy = 1 - 3 = -2 (2)

n = max(dx, dy) 8

xinc = dx / n ; 1
yinc = dy / n ; - 0.25

Sr. X Y Pixel
1 1 3 (1, 3)
2 2 2.75 (2, 3)
3 3 2.50 (3, 3)
4 4 2.25 (4, 2)
5 5 2 (5, 2)
6 6 1.75 (6, 2)
7 7 1.50 (7, 2)
8 8 1.25 (8, 1)
9 1 (9.1)

Unit - 3 Page 2
(1,1) -> (10,6)

dx = 10 - 1 = 9
dy = 6 - 1 = 5

n = max(dx, dy) 9 5/9 = 0.5556

xinc = dx / n ; 1 1
yinc = dy / n ; 0.556
1 + 0.556 = 1.556

Sr. X Y Pixel 1.556 + 0.556 = 2.112


1 1 1 (1, 1)
2.112 + 0.556 = 2.668
2 2 2 (2, 2)
3 3 2 (3, 2) 2.668 + 0.556 = 3.224
4 4 3 (4, 3)
3.224 + 0.556 = 3.78
5 5 3 (5, 3)
6 6 4 (6, 4) 3.78 + 0.556 = 4.336
7 7 4 (7, 4)
4.336 + 0.556 = 4.892
8 8 5 (8, 5)
9 9 5 (9, 5) 4.892 + 0.556 = 5.448
10. 10 6 (10,6)

Unit - 3 Page 3

You might also like