Dda Circle Drawing Algorithm Ppt
Bresenham Circle Drawing Algorithm,
Download Presentation
Bresenham Circle Drawing Algorithm,
- - - - - - - - - - - - - - - - - - - - - - - - - - - E North D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
-
BresenhamCircle Drawing Algorithm,
-
Contents • In today'due south lecture nosotros'll have a await at: • Bresenham'south Circle cartoon algorithm • Exercise using Bresenham'due south algorithm
-
CIRCLE • The set of points that are all at a given distance 'r' from a eye position (Xc,Yc).
-
A Simple Circle Drawing Algorithm • The equation for a circumvolve is: • where r is the radius of the circle • So, we can write a elementary circle cartoon algorithm by solving the equation for y at unit x intervals using:
-
A Uncomplicated Circle Drawing Algorithm (cont…)
-
A Simple Circumvolve Cartoon Algorithm (cont…) • However, unsurprisingly this is not a brilliant solution! • Firstly, the resulting circle has big gaps where the slope approaches the vertical • Secondly, the calculations are not very efficient • The foursquare (multiply) operations • The square root operation – try really hard to avoid these! • Nosotros need a more than efficient, more accurate solution
-
Eight-Way Symmetry (-ten, y) (ten, y) (-y, x) (y, x) (-y, -ten) (y, -x) (-x, -y) (10, -y) • The offset thing we can notice to make our circumvolve cartoon algorithm more than efficient is that circles centred at (0, 0) accept viii-mode symmetry
-
Mid-Point Circumvolve Algorithm • Similarly to the case with lines, in that location is an incremental algorithm for drawing circles – the mid-point circle algorithm • In the mid-point circle algorithm nosotros use 8-way symmetry so only ever calculate the points for the superlative right eighth of a circle, and and so employ symmetry to get the remainder of the points The mid-signal circle algorithm was developed by Jack Bresenham, who we heard about earlier.
-
Mid-Point Circumvolve Algorithm (cont…) (xk+1, yk) (xk, yk) (xk+1, yk-1) • Assume that we accept merely plotted point (xk, yk) • The next point is a choice betwixt (xk+1, yk) and (xk+i, yk-1) • Nosotros would like to choose the betoken that is nearest to the bodily circle • And then how do we brand this pick?
-
Mid-Bespeak Circle Algorithm (cont…) • Let's re-jig the equation of the circle slightly to give us: • …(1) • The equation evaluates every bit follows: • Past evaluating this function at the midpoint between the candidate pixels nosotros can make our decision
-
Mid-Signal Circumvolve Algorithm (cont…) • Assuming nosotros accept just plotted the pixel at (xk,yk) so we need to choose between (xk+1,yk) and (xk+ane,yk-1) • Our determination variable can be defined every bit:mid betoken b/w 2 points (xk+1,Yk) and (Xk+one, Yk-ane) is [xk+i, yk-1/ii] • ...2 • If pk < 0 the midpoint is inside the circle and the pixel at yk is closer to the circle • Otherwise the midpoint is exterior and yk-ane is closer
-
Mid-Indicate Circumvolve Algorithm (cont…) • To ensure things are as efficient as possible nosotros tin do all of our calculations incrementally • First consider: ( since Xk+one = Xk+1) • or: • where yk+1 is either yk or yk-1 depending on the sign of pk
-
the initial value of Pk is given past the circle function at the position (0,r) every bit, • Substituting k=0,Xk=0,Yk=r in the above function results in,
-
Mid-Point Circle Algorithm (cont…) • The first decision variable is given as: • if r is an integer, then Po can be rounded to P0= 1 – r. • So if pk < 0 and then the side by side decision variable is given as: • If pk > 0 then the conclusion variable is:
-
The Mid-Bespeak Circle Algorithm • MID-POINT CIRCLE ALGORITHM • Input radius r and circle centre (xc, yc), then set the coordinates for the kickoff signal on the circumference of a circle centred on the origin as: • Calculate the initial value of the decision parameter as: • Perform the test, Starting with g = 0 at each position xk, perform the following test. • (i) If pk < 0, the side by side point forth the circle centred on (0, 0) is (xk+i, yk) and:
-
The Mid-Point Circle Algorithm (cont…) • (ii) If Pk >0 and so the adjacent betoken along the circumvolve is (xk+1, yk-1) and: • where = 2Xk+two and = 2Yk – 2 • Identify the symmetry points in the other seven octants • Move (x, y) according to: • Repeat steps 3 to 5 until x >= y
-
Mid-Point Circle Algorithm Case • To come across the mid-point circle algorithm in action lets use it to depict a circumvolve centred at (0,0) with radius 10 • Determine the positions along the circle octant in the get-go quadrant from ten=0 to x=y. • The intial value of the decision parameter is • P0 = 1-r = one-ten = -nine • For circumvolve centred on the coordinate origin, the initial point is (X0,Y0)=(0,10) and initial increment terms for calculating the decision parameters are • 2X0 =0 and 2Y0 = xx
-
K=0 and P0 = -ix (i,10) • (pk<0) • K=one, P1=P0+2Xk+1 => -9+ii(i)+1 =-9+3=-6 (ii,x) • K=two, P2= P1 +2(2)+1 = -6+four+1 = -1 (3,10) • Chiliad=iii P3=P2+2(3)+ane = -1+7= 6 (four,nine) • 1000=4 (Pk>0) • P4= P3+2(4)+1-ii(nine) => vi+8+i-18 = -3 (5,nine) • K=5 p5= p4+2(5)+1 => -three+10+ane = eight (6,8) • K=6 p6=viii+2(6)+1-2(8) => 8+12+1-16 = 5 (7,vii) • K=vii p7= half-dozen (8,6) • K=viii p8=11 (ix,5) • Chiliad=9 p9 =20 (10,4)
-
Mid-Point Circle Algorithm Instance (cont…) ten 9 8 7 half dozen v 4 three two one 0 0 1 2 iii 4 5 vi seven 8 nine 10
-
Mid-Indicate Circumvolve Algorithm Do • Utilise the mid-point circle algorithm to draw the circle centred at (0,0) with radius 15
-
Mid-Point Circle Algorithm Case (cont…) 16 15 14 thirteen 12 11 10 nine viii vii 6 5 4 3 2 1 0 eleven 12 13 fourteen 15 16 0 i 2 3 4 5 6 7 8 9 10
-
Mid-Signal Circumvolve Algorithm Summary • The key insights in the mid-indicate circle algorithm are: • 8-way symmetry tin can hugely reduce the piece of work in drawing a circumvolve • Moving in unit steps along the x axis at each betoken forth the circle's edge we need to choose between 2 possible y coordinates
-
Mid-Point Circle Algorithm (cont…) 6 5 4 3 ane 2 three 4
-
Mid-Indicate Circumvolve Algorithm (cont…) half dozen 5 4 3 1 2 3 4
-
Mid-Point Circle Algorithm (cont…) 6 M 5 4 3 1 2 3 4
-
Mid-Point Circle Algorithm (cont…) 6 M 5 four three 1 2 iii four
-
Mid-Point Circle Algorithm (cont…) half dozen M 5 4 3 one 2 3 iv
-
Bare Grid
-
Blank Grid
-
Blank Grid 10 9 eight seven 6 v 4 3 2 1 0 0 1 two iii four 5 6 7 8 9 x
-
Blank Grid
Source: https://www.slideserve.com/happy/bresenham-circle-drawing-algorithm
0 Response to "Dda Circle Drawing Algorithm Ppt"
Post a Comment