Bresenhams Circle Drawing Solved Example
Bresenham'south Circle Drawing Algorithm in Computer Graphics
Bresenham'south algorithm is also used for circle drawing. It is known as Bresenham'southward circumvolve drawing algorithm. Information technology helps us to draw a circle. The circumvolve generation is more complicated than cartoon a line. In this algorithm, nosotros will select the closest pixel position to complete the arc. We cannot represent the continuous arc in the raster brandish system. The different part of this algorithm is that we only use arithmetic integer. We can perform the calculation faster than other algorithms.
Permit us assume we have a point p (ten, y) on the purlieus of the circle and with r radius satisfying the equation fc (x, y) = 0
As nosotros know the equation of the circle is –
fc (10, y) = 10two + y2 = r2
If
fc (10, y) < 0
then
The point is within the circle boundary.
If
fc (10, y) = 0
then
The point is on the circumvolve boundary.
If
fc (ten, y) > 0
then
The point is outside the circle boundary.
Nosotros assume,
The distance betwixt point Piii and circle purlieus = d1
The distance betwixt point P2 and circle purlieus = d2
At present, if we select indicate P3 then circle equation will be-
d1 = (tenk +1)2 + (yk)2 – r2 {Value is +ve, because the point is outside the circle}
if we select betoken P2 then circumvolve equation will exist-
dii = (xthou +1)2 + (yyard -1)ii – r2{Value is -ve, because the point is inside the circumvolve}
At present, we will calculate the decision parameter (done thousand) = d1 + dtwo
dk =(tenone thousand +1)2 + (yk)2 – r2 + d2 + (tenthousand +1)2 + (yk -1)two – r2
= 2(tenk +one)2 + (yk)2+ (yk -1)2 – 2r2 …………………… (1)
If
dk < 0
then
Point P3 is closer to circle purlieus, and the final coordinates are-
(xone thousand +i, yk) = (tenk +1, yk)
If
dk >= 0
and then
Point Pii is closer to circle boundary, and the terminal coordinates are-
(xk +1, ythousand) = (xone thousand +1, y1000 -ane)
Now, nosotros volition find the adjacent decision parameter (dk+1)
(d1000+i) = 2(xk+1 +1)2 + (yk+1)2+ (yk+1 -1)2 – 2r2 …………………… (two)
Now, we notice the difference between decision parameter equation (two) - equation (1) (dk+one) – (dk) = 2(xk+1+1)2 + (yyard+1)ii+ (yk+1 –1)2 – 2r2 – 2(xk +i)ii + (yk)two+ (yk– 1)2 – 2r2 (dm+ane) = dchiliad + 4xk + ii(ygrand+1 2– y1000 ii) – (yk+i – yk) + 6
Now, we cheque two weather condition for decision parameter-
Condition i: If
dk < 0
and then
yk+ane = yk (Nosotros select signal P3)
Condition 2: If
dk >= 0
and so
ygrand+ane = ythousand-1 (We select point Pthree)
Now, we calculate initial decision parameter (d0)
d0 = d1 + d2
d0 = {ane2 +r2– rtwo} + {12 +(r – 1)two – r2}
d0 = 3 – 2r
Algorithm of Bresenham'south Circle Cartoon
Stride i: Start.
Step 2: First, nosotros destine the starting coordinates (x1, yi) as follows-
xone = 0
yi =r
Pace 3: At present, we calculate the initial decision parameter d0 -
d0 = three – 2 x r
Step 4: Assume,the initial coordinates are (10k, yk)
The next coordinates volition be (tenk+ane, yk+1)
At present, we will find the next point of the kickoff octant according to the value of the decision parameter (dk).
Step 5: Now, we follow two cases-
Case 1: If
dyard < 0
then
10g+1 =xm + ane
yk+1 =ythousand
dm+1 = dyard + 4x1000+ane + 6
Case two: If
dk >= 0
then
xyard+1 =xchiliad + 1
ychiliad+1 =yk –1
d1000+1 = dk + four(xg+one – yk+1)+ 10
Pace six: If the centre coordinates (xi, y1) is not at the origin (0, 0), and so we will describe the points as follow-
X coordinate = tenc + x1
y coordinate = yc + y1 {10c andyc representsthe electric current value of ten and y coordinate}
Step 7: We repeat step 5 and vi until we get x>=y.
Step 8: Stop.
Example: The radius of a circumvolve is 8, and center betoken coordinates are (0, 0). Apply bresenham's circle drawing algorithm to plot all points of the circle.
Solution:
Step ane: The given stating points of the circumvolve (x1, y1) = (0, 0)
Radius of the circle (r) = 8
Pace ii: At present, we will assign the starting betoken (xi, yone) every bit follows-
x1 = 0
yi = r (radius) = 8
Step 3: Now, we will calculate the initial determination parameter (d0)
d0 = three – 2 x r
d0 = three – 2 ten 8
d0 = -thirteen
Step four:The value of initial parameter d0 < 0. So, case 1 is satisfied.
Thus,
tenk+ane =xk + 1 = 0 + 1 = 1
yk+i =yk = 8
dm+one = dyard + 4xk+1 + 6 = -13 + (four 10 one) + 6 = -3
Step 5: The middle coordinates are already (0, 0) so we will motion to next step.
Step 6: Follow step 4 until nosotros get x >= y.
Table for all points of octant 1:
| dthousand | dm+1 | (xgrand+1,ychiliad+i) |
| (0, 8) | ||
| -13 | -iii | (1, 8) |
| -3 | 11 | (2, viii) |
| 11 | 5 | (3, 7) |
| 5 | vii | (4, 6) |
| 7 | (5, 5) |
Now, we will calculate the coordinates of the octant 2 past swapping the 10 and y coordinates.
| Coordinates of Octant i | Coordinates of Octant 2 |
| (0, 8) | (5, v) |
| (one, 8) | (half dozen, 4) |
| (ii, 8) | (7, 3) |
| (3, 7) | (8, 2) |
| (4, vi) | (8, 1) |
| (5, 5) | (8, 0) |
Thus, we will summate all points of the circumvolve with respect to octant one.
| Quadrant 1 (x, y) | Quadrant 2 (-10, y) | Quadrant iii (-10, -y) | Quadrant four (x, -y) |
| (0, 8) | (0, viii) | (0, -8) | (0, -eight) |
| (ane, 8) | (-1, 8) | (-1, -8) | (ane, -eight) |
| (two, 8) | (-2, eight) | (-2, -8) | (two, -8) |
| (3, seven) | (-three, 7) | (-three, -vii) | (3, -7) |
| (4, 6) | (-4, six) | (-four, -6) | (four, -vi) |
| (5, 5) | (-5, v) | (-5, -v) | (5, -5) |
| (half dozen, 4) | (-half dozen, iv) | (-half-dozen, -4) | (six, -iv) |
| (7, 3) | (-7, 3) | (-seven, -iii) | (7, -3) |
| (8, 2) | (-8, two) | (-8, -two) | (viii, -2) |
| (8, 1) | (-8, 1) | (-viii, -i) | (eight, -ane) |
| (8, 0) | (-8, 0) | (-8, 0) | (8, 0) |
Advantages of Bresenham'due south Circle Drawing Algorithm
- It is simple and easy to implement.
- The algorithm is based on unproblematic equation ten2 + y2 = rtwo.
Disadvantages of Bresenham'south Circle Drawing Algorithm
- The plotted points are less authentic than the midpoint circle drawing.
- It is not then skillful for complex images and high graphics images.
- Bresenham'southward Line Drawing Algorithm in Computer Graphics
- Line Drawing Algorithm in Computer Graphics
- Mid-Point Line Drawing Algorithm in Reckoner Graphics
- Midpoint Circumvolve Drawing Algorithm in Computer Graphics
- DDA line Drawing Algorithm in Reckoner Graphics
- Line Clipping in Figurer Graphics
- Animation in Reckoner Graphics
- Epitome Representation in Figurer Graphics
- Pointing and Positioning Technique Computer Graphics
- Scan Conversion of a Circumvolve Computer Graphics
Source: https://www.tutorialandexample.com/bresenhams-circle-drawing-algorithm
0 Response to "Bresenhams Circle Drawing Solved Example"
Post a Comment