2-Example 3
2-Example 3
( 2 )
Dr. Majid D. Y.
02/04/2025 [email protected]
2
of
6
Line Drawing
Indicate which raster location would be chosen by Line Equation when scan converting
a line P1(26,18) P2(20,10)
Solution
1- m = (10-18)/(20-26) = -8/-6 =1.33
2- b = 18 – 26 * 1.33 = -16.66
3- because 18
m > 1 use x = (y-b) / m 17
y1>y2 decrement y
4- 16
X(18) = (18 +16.66) / 1.33 = 26 ≈ 26 15
X(17) = (17 +16.66) / 1.33 = 25.25 ≈ 25
X(16) = (16 +16.66) / 1.33 = 24.5 ≈ 25
14
X(15) = (15 +16.66) / 1.33 = 23.75 ≈ 24 13
X(14) = (14 +16.66) / 1.33 = 23 ≈ 23 12
X(13) = (13 +16.66) / 1.33 = 22.25 ≈ 22
X(12) = (12 +16.66) / 1.33 = 21.5 ≈ 22 11
X(11) = (11 +16.66) / 1.33 = 20.75 ≈ 21 10
X(10) = (10 +16.66) / 1.33 = 20 ≈ 20
18 10 20 21 22 23 24 25 26 27 28
3
of
6
Line Drawing
مالحظة ممكن كتابة الخطوة الرابعة على شكل جدول
4-
y x ≈x
18 26 26
17 25.25 25
16 24.5 25
15 23.75 24
14 23 23
13 22.25 22
12 21.5 22
11 20.75 21
10 20 20
4
of
6
Line Drawing
Indicate which raster location would be chosen by Sloop method when scan converting
a line P1(26,18) P2(20,10)
Solution
1- m = (10-18)/(20-26) = -8/-6 =1.33
2- because
m > 1 change y by one 18
and x by 1/m = .75 17
x1>x2 decrement x by 1/m
16
y1>y2 decrement y
3- 15
14
13
12
11
10
18 10 20 21 22 23 24 25 26 27 28
5
of
6
Line Drawing
Indicate which raster location would be chosen by DDA when scan converting a line P1(26,18)
P2(20,10)
Solution
1- m = (10-18)/(20-26) = -8/-6 =1.33 m > 1 change any x to y and any y to x but we most
rechange when draw pixel P1(18,26) P2(10,20) m = (20-26)/(10-18) = -6/-8 = 0.75
2- m1=-(1-0.75)=-0.25 , iy = y1 = 26 , E = 0
3- because 18
x1>x2 decrement x
y1>y2 decrement iy 17
4- 16
X Iy E
18 26 0 15
17 25 -0.25 14
16 25 0.5 13
15 24 0.25
12
14 23 0
11
13 22 -0.25
12 22 0.5 10
11 21 0.25 18 10 20 21 22 23 24 25 26 27 28
10 20 0
6
of
6
Line Drawing
Indicate which raster location would be chosen by Bresenham Line Algorithm when scan
converting a line P1(26,18) P2(20,10)
Solution When Exch = 1
1- Dx = 20-26 =-6 Xinc = -1 Dx = 6 Y changes always
2- Dy = 10-18 =-8 Yinc = -1 Dy = 8
3- Dx < Dy Exch = 1 Dx = 8 , Dy = 6
X depend on P
4- P = 2 Dy – Dx = 4
Pinc = 2 Dy – 2 Dx = -4
Ninc = 2 Dy = 12
18
5- X Y P Dx
17
26 18 4 8
16
25 17 0 7
15
25 16 12 6
24 15 8 5
14
23 14 4 4 13
22 13 0 3 12
22 12 12 2 11
21 11 8 1 10
20 10 4 0
18 10 20 21 22 23 24 25 26 27 28