0% found this document useful (0 votes)
5 views3 pages

Circle

The midpoint circle algorithm is a method for drawing circles on raster displays by utilizing symmetry to calculate circle points efficiently. The algorithm involves initializing the circle's center and radius, calculating a decision parameter, and plotting points based on this parameter until the circle is complete. It reduces calculations by only determining points for a portion of the circle and mirroring them to complete the shape.

Uploaded by

mi.4922307
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)
5 views3 pages

Circle

The midpoint circle algorithm is a method for drawing circles on raster displays by utilizing symmetry to calculate circle points efficiently. The algorithm involves initializing the circle's center and radius, calculating a decision parameter, and plotting points based on this parameter until the circle is complete. It reduces calculations by only determining points for a portion of the circle and mirroring them to complete the shape.

Uploaded by

mi.4922307
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/ 3

The midpoint circle algorithm is used to draw circles on a raster display, where each pixel

represents a point on the circle. The algorithm is based on the idea of symmetry and
efficiently calculates the points of the circle by determining their positions based on the
midpoint of the circle's circumference.

Here are the steps of the midpoint circle algorithm:

1. Initialization:
o Define the center of the circle at (x_c, y_c).
o Define the radius of the circle as r.
o Set the initial point to (0, r) [setting x = 0, y = r]
2. Plotting Points Using Symmetry:
o Calculate the decision parameter, often denoted as P, using the midpoint circle
algorithm decision parameter:

P=1−r

While plotting the circle, start at the initial point and move along the
circumference using symmetry:

▪ At each step, choose the next point based on the current decision
parameter:
▪ If P < 0, the next point is on the same horizontal line and closer
to the midpoint in the x-direction. Update P as:

Pnext=P+2x+1

If P >= 0, the next point is diagonally up and to the right


(symmetrically, you can reflect this for the other octants).
Update P as:

Pnext=P+2x+1−2y

Increment x and y coordinates appropriately based on the


decision parameter and plot the corresponding points.

3. Repeat until Completion:


o Continue plotting points until x >= y. This condition ensures that the circle is
complete for the chosen octant.

The algorithm is efficient because it uses symmetry properties to calculate only a portion of
the circle (usually one-eighth or one quadrant) and then mirrors the points to complete the
circle. This reduces the number of calculations needed compared to other methods that
calculate all points directly.
1. Initialization:
o Define the center of the circle at (x_c, y_c).
o Define the radius of the circle as r.
o Set the initial point to (0, -r). [setting x = 0, y = -r]
2. Plotting Points Using Symmetry:
o Calculate the decision parameter, often denoted as P, using the midpoint circle
algorithm decision parameter:

P=1+r

o While plotting the circle, start at the initial point and move along the
circumference using symmetry:
▪ At each step, choose the next point based on the current decision
parameter:
▪ If P < 0, the next point is on the same horizontal line and closer
to the midpoint in the x-direction. Update P as:

Pnext=P+2y+1

If P >= 0, the next point is diagonally down and to the right


(symmetrically, you can reflect this for the other octants).
Update P as:

Pnext=P+2y+1−2x

Increment y and x coordinates appropriately based on the


decision parameter and plot the corresponding points.

3. Repeat until Completion:


o Continue plotting points until y >= 0. This condition ensures that the circle is
complete for the chosen octant.
If the initial point for drawing the circle is (x=R, y=0), meaning the circle is centered on the
x-axis at x=R and touches the y-axis at y=0, then we need to adjust the midpoint circle
algorithm accordingly. Here's how you can modify the algorithm:

1. Initialization:
o Define the center of the circle at (x_c, y_c) as (R, 0).
o Define the radius of the circle as r.
o Set the initial point to (R, 0).
2. Plotting Points Using Symmetry:
o Calculate the decision parameter, often denoted as P, using the midpoint circle
algorithm decision parameter:

P=1−r

o While plotting the circle:


▪ At each step, choose the next point based on the current decision
parameter:
▪ If P < 0, the next point is on the same horizontal line and closer
to the center in the x-direction. Update P as:

Pnext=P+2x+1

▪ If P >= 0, the next point is diagonally up and to the right


(symmetrically, you can reflect this for the other octants).
Update P as:

Pnext=P+2x+1−2y

▪Increment x and decrement y coordinates appropriately based on the


decision parameter and plot the corresponding points.
3. Repeat until Completion:
o Continue plotting points until y >= x. This condition ensures that the circle is
complete for the chosen octant.

You might also like