0% found this document useful (0 votes)
11 views

Mid Point Circle Generation Algorithm

The Mid-point Circle Generation Algorithm efficiently rasterizes a circle by calculating points in the first octant and using symmetry to generate points in the other octants. The algorithm involves determining if a pixel lies inside, on, or outside the circle based on a decision parameter, and it iterates through points to plot the circle. An example with a circle of radius 3 demonstrates the step-by-step implementation of the algorithm.

Uploaded by

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

Mid Point Circle Generation Algorithm

The Mid-point Circle Generation Algorithm efficiently rasterizes a circle by calculating points in the first octant and using symmetry to generate points in the other octants. The algorithm involves determining if a pixel lies inside, on, or outside the circle based on a decision parameter, and it iterates through points to plot the circle. An example with a circle of radius 3 demonstrates the step-by-step implementation of the algorithm.

Uploaded by

mgnregasvgsvg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Page 1 of 6

Home Whiteboard AI Assistant Online Compilers Jobs Free Library

SQL HTML CSS Javascript Python Java C C++ PHP Scala C#

Mid-point Circle Generation Algorithm

The Mid-point Circle Generation Algorithm works by determining the points needed for
rasterizing it. It is efficient because it calculates the points present in the first octant of
the circle and uses the circle's symmetry to generate the remaining points for the other
seven octants.

In this chapter, we will explain the basics of the mid-point circle generation algorithm
and go through a detailed example. We will also cover its step-by-step implementation
for a better understanding.

Basics of Mid-Point Circle Generation Algorithm


The main idea of the Mid-point Circle Generation Algorithm is to determine whether a
pixel lies inside, on, or outside the boundary of a circle. We plot the points for one-eighth
of the circle (the first octant) and use the symmetry of the circle to replicate those points
in the other octants.

Symmetry of Circles
As we have seen in the last algorithm also the circle generation has been done with the
idea of symmetry. We generate for only 45 and rest can be easily calculated with
changing the coordinate values, since a circle is symmetric about its center.

For a circle with a center at (0,0) and radius r, the equation of the circle is −

2 2 2
x + y = r

Given a point P(x, y) on the circle, the decision to plot the next point depends on
whether the midpoint between two possible pixels lies inside or outside the circle.
Page 2 of 6

Here, P and Q both points are inside the circle, whereas the point R is outside of the
circle.

The Algorithm

The algorithm follows these steps −

Start with an initial point − The first point to be plotted is (r, 0), which lies on
the positive X-axis.

Calculate the initial decision parameter − The initial decision parameter is


computed as −

P1 = 1 − r

Iterate through points in the first octant − For each subsequent point, we
check whether the next pixel is above or below the circle or not. The next pixel is
either at (x, y + 1) or (x − 1, y + 1)

If the decision parameter is less than or equal to zero, the midpoint is inside
the circle. In this case, the next pixel is (x, y + 1).

If the decision parameter is greater than zero, the midpoint is outside the
circle. The next pixel is (x − 1, y + 1) .

Update the decision parameter − For each new pixel, update the decision
parameter depending on which pixel was chosen.

If the midpoint was inside or on the circle −

P k+1 = P k + 2y k + 1

If the midpoint was outside the circle −


Page 3 of 6

P k+1 = P k + 2y k − 2x k + 1

Example of Mid-Point Circle Generation


Let us go through a detailed example where we apply the Mid-point Circle Generation
Algorithm.

Consider the center is at location (0,0), and Radius is 3.

Let's understand the step-by-step calculation.

Starting point − The first point to plot is (3, 0) on the x-axis.

Initial decision parameter − Using the formula, the initial decision parameter P1 is −

P1 = 1 − r = 1 − 3 = −2

First iteration − For the first iteration, we start with x = 3 and y = 0. Since P1 = − 2
(which is less than 0), the next point is (3, 1). The new decision parameter is −

P2 = P 1 + 2y 1 + 1 = −2 + 2(0) + 1

The points at this stage are: (3, 0), (−3, 0), (0, 3), and (0, −3). Using symmetry, we
also plot (3, 1), (−3, 1), (3, −1), and (−3, −1).

Second iteration − For the second iteration, with x = 3 and y = 1, since P2 = −1


(which is less than 0), the next point is (3, 2). The new decision parameter is −

P3 = P 2 + 2y 2 + 1 = −1 + 2(1) + 1 = 2

The points at this stage are: (3, 2), (3,2), (3, 2), and (3, 2)

Chapters − Now, for the third iteration, with x = 3 and y = 2 since


Third iteration Categories
P3 = 2 (which
is greater than 0), the next point is (2, 3). The new decision parameter is −

P4 = P 3 + 2y 3 − 2x 3 + 1 = 2 + 2(2) − 2(3) + 1 = 3

The points at this stage are: (2, 3), (2, 3), (2, 3), and (2, 3)

Final iteration − For the final iteration, with x = 2 and y = 3, since P4 = 3 (which is
greater than 0), the next point is (1, 3). The decision parameter is updated, but since x
is now smaller than y, the algorithm stops.

The points at this stage are: (1, 3), (1, 3), (1, 3), and (1,3)

Full Set of Points − After completing all iterations, we have the following points for the
circle with a radius of 3 and center at (0,0) −
Page 4 of 6

(3, 0), (3, 0), (0, 3), (0, 3), (3, 1), (3, 1), (3, 1), (3, 1), (3, 2), (3, 2), (3, 2), (3, 2), (2,
3), (2, 3), (2, 3), (2, 3), (1, 3), (1, 3), (1, 3), (1, 3).

Conclusion
In this chapter, we explained the Mid-point circle generation algorithm in detail. We
started the chapter with a brief discussion on the symmetry of circles, which forms the
basis of the algorithm. Then, we outlined the steps of the algorithm, explaining how the
decision parameter helps in determining the next point to plot. Finally, we worked
through an example with a radius of 3 to explain the algorithm in action.

TOP TUTORIALS

Python Tutorial

Java Tutorial
C++ Tutorial

C Programming Tutorial

C# Tutorial
PHP Tutorial

R Tutorial

HTML Tutorial
CSS Tutorial

JavaScript Tutorial

You might also like