Midpoint Circle Algorithm C Program

Let us understand what is Midpoint circle drawing algorithm in computer graphics and then let us see how to draw a circle using midpoint circle algorithm in C programming using different methods.

What is Midpoint Circle Algorithm?

The midpoint circle drawing algorithm constructs a circle using the coordinates of X-axis and Y-axis and creates an image in a vector graphics format. Here, the perimeter points of the circle are plotted on the graph using the X and Y coordinates.

The same algorithm can be used to create a vector graphics image for any 2-dimensional curve such as a parabola, hyperbola, ellipse, etc. Unlike Bresenham’s line drawing algorithm, this algorithm can be optimized to perform integer based calculations.

The getmaxy() function used in the second method is available in the graphics.h library. It returns the maximum Y – coordinate for the available driver and graphics mode.

The equation of the circle x2 + y2 = radius2 is used in this circle generation algorithm, and this algorithm is based on Bresenham’s circle drawing algorithm.

However, there are a few disadvantages with this algorithm as well. The execution time for drawing the circle is comparatively high and also the pixel distance is a bit unequal which doesn’t provide a smooth lined circle.

If you face any issues while compiling this algorithm in computer graphics, you may have to install graphics.h in your operating system.