Mid-point circle generating algorithm

Mid-point Circle Generating Algorithm

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:

  1. Input the radius (r) of the circle and the coordinates of the center point (xc, yc).
  2. Initialize the decision parameter (p) as (5/4) - r.
  3. Set the initial values of (x) and (y) to (0) and (r) respectively.
  4. Plot the initial point (x, y) and its symmetrical points in all octants.
  5. 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).
  6. 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).

  1. Input: r = 4, xc = 0, yc = 0.
  2. Decision Parameter: p = (5/4) - r = 1 - 4 = -3.
  3. Initial Point: (x, y) = (0, 4).
  4. Plot initial point and its symmetrical points.
  5. Begin while loop with (x = 0, y = 4).
  6. Update p = p + 2x + 1 = -3 + 2*0 + 1 = -2.
  7. As p < 0, increment x.
  8. Plot the points based on the updated values.
  9. Continue the process until x > y.