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.

Note: This C program for Midpoint circle generation algorithm is compiled with Turbo C compiler on Microsoft Windows 10 operating system.

Method 1: C Program To Implement Midpoint Circle Algorithm using Function

Method 2: Midpoint Circle Drawing algorithm in C Programming without Function

Output

Enter the radius of Circle: 10
Enter the coordinates of the centre point of the circle:
Enter the X – coordinate value: 20
Enter the Y – coordinate value: 10

Implement Midpoint Circle Algorithm in C Programming with Functions, Explanation and Output

Let us discuss more on this midpoint circle drawing algorithm in C programming in the comment section below.


Do let us know if you have any doubts or have any information to share. For information, check Wikipedia.

One thought on “Midpoint Circle Algorithm C Program

  1. Vishal Sharma

    This circle drawing algorithm can be manipulated for integer based calculations.

    Reply

Let's Discuss