8-Way Symmetry & Bresenham’s Circle Algorithm

Circle


The most important thing in drawing a circle is learning how the circle is drawn using 8-way symmetry. It is based on Mirror reflection. If we see Right hand in the mirror we will see Left hand, Similarly if we see pixel (x,y) in mirror we will see (y,x). 

So point P1(x,y) will become P2(y,x) after reflection. Point P3 (-y,x) will become P4 (-x,y) and so on.

Lets understand more how these negative signs are taken. Remember following two things.

One–  If we mirror reflect (x,y) with respect to x axis then y will change so it will become (x,-y). Similarly if we reflect point (x,y) with respect to y axis x will change , so the point will become (-x,y).

Two – Read Point (x,y) as :  x is on x position and y is on y position, so when we reflect with respect to x axis then y position becomes negative and with respect to y axis x position becomes negative. Take this logic and reflection of point P2 (y,x) with respect to y axis will make the x position negative and not where x is written, so it will become P3 (-y,x). 

Reflection of point P8 (x,-y) with respect to x axis will make y position negative and not where y is written, so it will become P1(x,y).  

8-Way Symmetry Diagram


The above diagram explains the 8-way symmetry.

Another explanation of the same concept.

This explains the same concept using quadrant. We all know there are four quadrants and

  • First quadrant x and y both are positive.
  • Second quadrant y is positive and x is negative (which is nothing but reflection with respect to y axis).
  • Third quadrant y is negative and x is positive (which is reflection with respect to  x axis).  
  • Forth quadrant both x and y are negative.

Take the following points and apply the above logic. 

  • Take a point P1 (x,y) in first quadrant.
  • Mirror reflect point P1 (x,y) with respect to y axis we will get another point called P4 (-x, y).
  • Mirror reflect point P1 (x,y) with respect to x axis we will get another point called P8 (x,-y).
  • Mirror reflect point P4 (-x, y) with respect to x axis we will get another point called P5 (-x,-y)
  • Take a point P2 (y, x) in first quadrant.
  • Mirror reflect point P2 (y, x) with respect to y axis we will get another point called P3 (-y, x)
  • Mirror reflect point P2 (y, x) with respect to x axis we will get another point called P7 (y,-x)
  • Mirror reflect point P3 (-y, x) with respect to x axis we will get another point called P6 (-y,-x)

Notice that 8 Way Symmetry generates 8 points by taking only one point (x, y) and this forms the circle.

Bresenham’s Circle Algorithm: 

Numerical or example of the Bresenham’s circle algorithm for radius 10 is given in another post.

Example of BCA


S-1; Enter the center (h, k) and radius(r)  of the circle. 

S-2: Find d=3-2r and take x = 0 , y = r ; Where r is nothing but the radius of the circle.

S-3: If (d>=0) then x = x +1 and y = y -1 ; d = d + 4*(x-y) + 10; We call d as decision variable.

S-4: if (d <0) then x =x +1 and d = d +4*x + 6;

S-5: Just use the 8 way symmetry and plot following 8 points with one point.

Putpixel (x+h, y+k)

Putpixel (-x+h, y+k)

Putpixel (x+h, -y+k)

Putpixel (-x+h, -y+k)

Putpixel (y+h,x+k)

Putpixel (-y+h,x+k)

Putpixel (y+h,-x+k)

Putpixel (-y+h,-x+k)

S-6: Go to step 3 and repeat till x = r /sqrt(2);