Mid-point Circle Generating Algorithm
The Mid-point Circle Generating Algorithm is a method used in computer graphics to draw circles efficiently. It is based on the principle of symmetry and uses the concept of a decision parameter to determine the appropriate pixels to plot for the circle.
Algorithm Steps:
- Input the radius (r) of the circle and the coordinates of the center point (xc, yc).
- Initialize the decision parameter (p) as (5/4) - r.
- Set the initial values of (x) and (y) to (0) and (r) respectively.
- Plot the initial point (x, y) and its symmetrical points in all octants.
- While (x) is less than or equal to (y), repeat the following steps:
- If the decision parameter (p) is less than (0), increment (x) and update (p) as (p + 2x + 1).
- Otherwise, increment both (x) and (y) and update (p) as (p + 2x + 1 - 2y).
- Plot the points in each octant based on the updated values of (x) and (y).
Example:
Let's consider drawing a circle with a radius of 4 units and a center at (0, 0).
- Input: r = 4, xc = 0, yc = 0.
- Decision Parameter: p = (5/4) - r = 1 - 4 = -3.
- Initial Point: (x, y) = (0, 4).
- Plot initial point and its symmetrical points.
- Begin while loop with (x = 0, y = 4).
- Update p = p + 2x + 1 = -3 + 2*0 + 1 = -2.
- As p < 0, increment x.
- Plot the points based on the updated values.
- Continue the process until x > y.