0% found this document useful (0 votes)
40 views6 pages

Midpointcircle

Mid Point Circle Drawing

Uploaded by

Jyoti Ahuja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
40 views6 pages

Midpointcircle

Mid Point Circle Drawing

Uploaded by

Jyoti Ahuja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 6
< Circle Drawing Algorithm Qh Circle Drawing Algorithm Properties of Circles A circle is defined as the set of points that are all at a given distance r from a center position (Xs ye). This distance relationship is expressed by the Pythagorean theorem in Cartesian coordinates as We can use this equation to calculate the position of points on a circle circumference by stepping along the x axis in unit steps from xe-r to xct r and calculating the corresponding y values at each position as But this is not the best method for generating a circle. One problem with this approach is that it involves considerable computation at each step. Moreover, the spacing between plotted pixel positions is not uniform. Another way to eliminate the unequal spacing is to calculate points along the circular boundary using polar coordinates r and @. Expressing the circle equation in parametric polar form yields the pair of equations y=y, + rsind When a display is generated with these equations using a fixed angular step size, a circle is plotted with equally spaced points along the circumference. The step size chosen for © depends on the application and the display device. Larger angular separations along the circumference can be connected with straight line segments to approximate the circular path. For a more continuous boundary on a raster display, we can set the step size at I/. This plots pixel positions that are approximately one unit apart. 8-Way Symmetry in Circle Computation can be reduced by considering the symmetry of circles. The shape of the circle is similar in each quadrant. We can generate the circle section in the second quadrant of the xy plane by noting that the two circle sections are symmetric with respect to the y axis. And circle sections in the third and fourth quadrants can be obtained from sections in the first and second quadrants by considering symmetry about the x axis. We can take this one step further and -note that there is a symmetry between octants. Circle sections in adjacent ‘octants within one quadrant are symmetric with respect to the 45 _line dividing the two octants. These symmetry conditions are illustrated in Fig,, where a point at position (x, y) on @ one-eighth circle sector is mapped into the seven circle points in the other octants of the xy plane. Taking advantage of the circle symmetry in this way we can generate all pixel positions around a circle by calculating only the points within the sector from x= Oto x=y Algorithm draw_circle(int xc, int yc, int x, int y) { putpixel(x+xc, y+yc,color); putpixel(x+xc, -ytyc,color); putpixel(-x+xc, -y+yc,color); putpixel(-x+xe, y+yc,color); putpixel(y+xc, x+yc,color); putpixel(y+xc, -x+yc,color); putpixel(-y+xc, -x+yc,color); putpixel(-y+xc, x+yc,color); } Mid Point Circle Drawing Algorithm As in the raster line algorithm, we sample at unit intervals and determine the closest pixel position to the specified circle path at each step. For a given radius r and screen center position (xe ye), we can first set up our algorithm to calculate pixel positions around a circle path centered at the coordinate origin (0,0). To apply the midpoint method, we define a circle function: forae¥) = + Yh? Any point (x, y) on the boundary of the circle with radius r satisfies the equation Crce(x, y) = 0. If the point is in the interior of the circle, the circle function is negative. And if the point is outside the circle, the circle function is positive. To summarize, the relative position of any point (x. v) can be determined by checking the sign of the circle function: <0, if(x,y) is inside the circle boundary Fpe%¥) = {=0 if(xy) is on the circle boundary, \>0 _if(x,y) is outside the circle boundary) J PO ; ate, S witt he selected ' PEO HI) 4-1) Y Bare =O , Hai, ruil petd wil be on boundang S Sort can be selected - Pett = (Xen tI? + (ty a) es Xe = Re ae Baye (x tay" + (4) d) - ak Fes Bap. i= BOHN ELEC He, — ye) = Yeu “2 a point T ip selected , a

You might also like