You are on page 1of 18

Grafika Komputer

Week 3 : Bressenhem (Circle)

christianskaditya@umm.ac.id 1
•A  circle is a collection of points that have a distance from the same
center point for all points.

In general, circles are used as components of an image. The procedure


for displaying circles and ellipses is made with the basic equation of the
circle .

Circles can be made by drawing a quarter circle, because other parts


can be made as symmetrical parts.

christianskaditya@umm.ac.id 2
Symmetrical Eight Points
The process of making a circle can be done by determining one starting point. If
the starting point is a circle (x, y), then there are three other positions, so that
eight points can be obtained.
 Thus,it is only necessary to calculate the
segment in determining the complete circle.
Eight symmetrical points, namely:

Quadrant I : (x,y),(y,x)
Quadrant II : (-x,y),(-y,x)
Quadrant III : (-x,-y),(-y-x)
Quadrant IV : (x,-y),(y,-x)

christianskaditya@umm.ac.id 3
The algorithm used forms all points based on the center point with the addition of all the paths
around the circle.

Fcircle (x,y) ; < 0, if (x,y) inside the circle line


Fcircle (x,y) ; = 0, if (x,y) on the circle line
Fcircle (x,y) ; > 0, if (x,y) outside the circle line

P1 = M(xk, yk)
P2 = M(xk + 1, yk - 1)
P3 = M(xk + 1, yk)

After point P1, do we choose P2 or P3 ?


D(si) = distance of P3 from circle  D(si) = (xk + 1)2 + yk2 – r2
D(ti) = distance of P2 from circle  D(ti) = (xk + 1)2 + (yk - 1)2 – r2

christianskaditya@umm.ac.id 4
Decision Parameter Pk = D(si) + D(ti)
= (xk + 1)2 + yk2 – r2 + (xk + 1)2 + (yk - 1)2 – r2
= 2(xk + 1)2 + yk2 + (yk - 1)2 – 2r2……… (1)

So if Pk < 0 the circle is closer to P3 (above point)


(xk + 1, yk) = (xk + 1, yk)
So if Pk ≥ 0 the circle is closer to P2 (below point)
(xk + 1, yk) = (xk + 1, yk -1)

Next decision parameter Pk+1 :


Pk+1 = 2(xk+1 + 1)2 + yk+12 + (yk+1 - 1)2 – 2r2……… (2)
christianskaditya@umm.ac.id 5
Difference between equation (2) – (1)
Pk+1 - Pk = 2(xk+1 + 1)2 + yk+12 + (yk+1 - 1)2 – 2r2
- 2(xk + 1)2 - yk2 - (yk - 1)2 + 2r2

where xk+1 = xk + 1
Pk+1 - Pk = 2(xk + 1 + 1)2 + yk+12 + (yk+1 - 1)2
- 2(xk + 1)2 - yk2 - (yk - 1)2)
= 2(xk + 2)2 + yk+12 + (yk+1 - 1)2
- 2(xk + 1)2 + yk2 + (yk - 1)2
= 2(xk2 + 4xk + 4) + yk+12 + yk+12 - 2yk+1 + 1
- 2(xk2 + 2xk + 1) - yk2 - yk2 + 2yk – 1
= 2xk2 + 8xk + 8 + 2yk+12 - 2yk+1
- 2xk2 - 4xk - 2 - 2yk2 + 2yk
= 4xk + 6 + 2yk+12 - 2yk+1 - 2yk2 + 2yk

Pk+1 = Pk + 4xk + 2(yk+12 - yk2) - 2(yk+1 - yk) + 6

christianskaditya@umm.ac.id 6
If Pk < 0 (P3 is select) then yk+1 = yk
Pk+1 = Pk + 4xk + 2(yk2 - yk2) - 2(yk - yk) + 6
= Pk + 4xk + 6

If Pk ≥ 0 (P2 is select) then yk+1 = yk - 1


Pk+1 = Pk + 4xk + 2((yk – 1)2 - yk2) - 2(yk - 1 - yk) + 6
= Pk + 4xk + 2(yk2 – 2yk + 1 - yk2) - 2(yk - 1 - yk) + 6
= Pk + 4xk – 4yk + 10

christianskaditya@umm.ac.id 7
Initial decision Parameter P0
D(si) = distance of P3 from circle  D(si) = (xk + 1)2 + yk2 – r2
D(ti) = distance of P2 from circle  D(ti) = (xk + 1)2 + (yk - 1)2 – r2
xk = 1
yk = r

P0 = D(si) + D(ti)
= [12 + r2 - r2] + [12 + (r - 1)2 - r2]
= 1 + 1 + r2 – 2r + 1 - r2
= 3 - 2r

christianskaditya@umm.ac.id 8
Circle Formation Bressenhem Steps:

1. Determine the radius r with the center point of the circle (xc, yc); yc = r  (0,r)
2. Calculate the parameter p0 = 3 - 2r
3. While (x < y), Determine the initial value k = 0 for each xk position:
a) If pk < 0 then the next point is (xk + 1, yk) and pk+1 = pk + 4xk + 6
b) If pk > 0 then the next point is (xk + 1, yk - 1) and pk+1 = pk + 4(xk – yk) + 10
Where 2xk+1 = 2xk + 2 and 2yk+1 = 2yk - 2
4. Determine the symmetrical point on the other seven octane.
5. Move each pixel position (x, y) on the circular line of the circle with the center
point (xc, yc) and specify the coordinate value:
x = x + xc and y = y + yc
6. Repeat steps 3 -5, up to x ≥ y

christianskaditya@umm.ac.id 9
Example
To illustrate the Bressenham algorithm in the formation of a circle with
a center point (0,0) and a radius is 10, the calculation is based on the
first quadrant where x = 0 to x = y

christianskaditya@umm.ac.id 10
Iteration 1
k=0
p0 = 3 – 2r  p0 = 3 – 20 = -17
p0 < 0
(xk + 1, yk)  (x0 + 1, y0)  (1, 10)
pk+1 = pk + 4xk + 6  p1 = -17 + 4.0 + 6  p1 = -11

2xk+1 = 2xk + 2 and 2yk+1 = 2yk - 2


2.1 = 2.0 + 2

christianskaditya@umm.ac.id 11
Iteration 2
k=1
p1 = -11
p1 < 0
(xk + 1, yk)  (x1 + 1, y1)  (2, 10)
pk+1 = pk + 4xk + 6  p1 = -11 + 4.1 + 6  p2 = -1

2xk+1 = 2xk + 2 and 2yk+1 = 2yk - 2


2.2 = 2.1 + 2

christianskaditya@umm.ac.id 12
Iteration 3
k=2
p2 = -1
p2 < 0
(xk + 1, yk)  (x2 + 1, y2)  (3, 10)
pk+1 = pk + 4xk + 6  p1 = -1 + 4.2 + 6  p3 = 13

2xk+1 = 2xk + 2 and 2yk+1 = 2yk - 2


2.3 = 2.2 + 2

christianskaditya@umm.ac.id 13
Iteration 4
k=3
p3 = 13
p3 > 0
(xk + 1, yk - 1)  (x3 + 1, y3 – 1)  (4, 9)
pk+1 = pk + 4(xk – yk) + 10  p4 = 13 + 4(3 - 10) + 10  p4 = -5

2xk+1 = 2xk + 2 and 2yk+1 = 2yk - 2


2.9 = 2.10 - 2

christianskaditya@umm.ac.id 14
Iteration 4
and so on. . .

christianskaditya@umm.ac.id 15
11
10
9
k Pk (xk+1, yk+1) 8
0 -17 (1,10)
7
1 -11 (2,10)
6
2 -1 (3,10)
5
3 13 (4,9)
4 -5 (5,9)
4
5 17 (6,8) 3
6 11 (7,7) 2
1
1 2 3 4 5 6 7 8 9 10 11

christianskaditya@umm.ac.id 16
EXERCISE
Create a circle with r = 9 towards the center point (0,0)

christianskaditya@umm.ac.id 17
THANKYOU

christianskaditya@umm.ac.id 18

You might also like