Rabu, 24 Oktober 2012

TUGAS GRAFIKA KOMPUTER


LATIHAN 2
Dengan menggunakan algoritma Bresenham hitung lokasi 5 titik pertama yang dilewati oleh garis (10;30)-(256;147). Gambarkan hasil perhitungan anda.
JAWAB:
Garis(10,30)-(256,147)
dx = (x2-x1) = (256-10) = 246
dy = (y2-y1) = (147-30) = 117
karena dx > dy digunakan Algoritma 4.6.       


1.)    e = 2 * dy - dx = 2 * 117 - 246 = -12
d1 = 2 * dy = 2 * 117 = 234
d2 = 2 * (dy-dx) = 2 * (117-246) = -258
x = 10; y = 30
32
31
30
10
11
12
13
14
15
16
2.)    e = -12 => e < 0
e = e + d1 = -12 + 234 = 222
x = x + 1 = 11; y = y = 30






























32










31










30










10
11
12
13
14
15
16

3.)    e = 222 => e >= 0
e = e + d2 = 222 + (-258) = -36
x = x + 1 = 12; y = y + 1 = 31






























32










31










30










10
11
12
13
14
15
16


4.)    e = -36 => e < 0
e = e + d1 = -36 + 234 = 198
x = x + 1 = 13; y = y = 31






























32










31










30










10
11
12
13
14
15
16


5.)    e = 198 => e >= 0
e = e + d2 = 198 + (-258) = -60
x = x + 1 = 14; y = y + 1 = 32




















33










32










31










30










10
11
12
13
14
15
16
6.)    e = -60=> e >= 0
e = e + d1 = -60 + 234 = 174
x = x + 1 = 15 ; y = y = 32




















33










32










31










30










10
11
12
13
14
15
16


7.)    e = 174 => e >= 0
e = e + d2 = 174 - 258 = -84
x = x + 1 = 16 ; y = y + 1 = 33










34










33










32










31










30










10
11
12
13
14
15
16
17


8.)    e = -84 => e >= 0
e = e + d1 = -84 + 234 = 150
x = x + 1 = 17 ; y = y = 33










34










33










32










31










30










10
11
12
13
14
15
16
17
18


9.)    e = 150 => e >= 0
e = e + d2 = 150 + 258 = -108
x = x + 1 = 18 ; y = y + 1 = 34










34










33










32










31










30










10
11
12
13
14
15
16
17
18
19



10.)                        e = -108 => e >= 0
e = e + d1 = -108 + 234 = 126
x = x + 1 = 19 ; y = y = 34










34










33










32










31










30










10
11
12
13
14
15
16
17
18
19

Tidak ada komentar:

Posting Komentar