Javascript required
Skip to content Skip to sidebar Skip to footer

Drawing a Circle With Input Radius C++ Domain_10

Circle Drawing Algorithms-

In computer graphics, popular algorithms used to generate circle are-

  1. Mid Point Circumvolve Drawing Algorithm
  2. Bresenham'due south Circumvolve Drawing Algorithm

In this article, we will discuss about Mid Point Circle Cartoon Algorithm.

Mid Point Circle Cartoon Algorithm-

Given the center point and radius of circle,

Mid Point Circle Drawing Algorithm attempts to generate the points of one octant.

The points for other octacts are generated using the eight symmetry property.

Procedure-

Given-

  • Centre indicate of Circle = (Ten0, Y0)
  • Radius of Circumvolve = R

The points generation using Mid Point Circle Drawing Algorithm involves the following steps-

Pace-01:

Assign the starting bespeak coordinates (X0, Y0) as-

  • X0 = 0
  • Y0 = R

Step-02:

Summate the value of initial conclusion parameter P0 as-

P0 = one – R

Footstep-03:

Suppose the current point is (Tenk, Yk) and the adjacent bespeak is (Xchiliad+1, Yk+1).

Find the next point of the first octant depending on the value of determination parameter Pyard.

Follow the below 2 cases-

Footstep-04:

If the given centre point (X0, Y0) is not (0, 0), then do the following and plot the point-

  • 10plot = 10c + Ten0
  • Yplot = Yc + Y0

Hither, (Xc, Yc) denotes the current value of X and Y coordinates.

Step-05:

Proceed repeating Step-03 and Footstep-04 until Xplot >= Yplot.

Stride-06:

Step-05 generates all the points for i octant.

To notice the points for other seven octants, follow the eight symmetry property of circle.

This is depicted by the post-obit effigy-

Too Read- Line Drawing Algorithms

Practise PROBLEMS BASED ON MID POINT CIRCLE Drawing ALGORITHM-

Trouble-01:

Given the eye point coordinates (0, 0) and radius as 10, generate all the points to class a circle.

Solution-

Given-

  • Middle Coordinates of Circumvolve (X0, Y0) = (0, 0)
  • Radius of Circle = 10

Pace-01:

Assign the starting point coordinates (X0, Y0) as-

  • X0 = 0
  • Y0 = R = 10

Step-02:

Calculate the value of initial decision parameter P0 as-

P0 = 1 – R

P0 = 1 – x

P0 = -9

Step-03:

As Pinitial < 0, so instance-01 is satisfied.

Thus,

  • 10yard+1 = Xyard + 1 = 0 + 1 = ane
  • Yk+1 = Yk = 10
  • Pk+1 = Pchiliad + 2 x Xk+one + one = -9 + (2 ten 1) + 1 = -half dozen

Stride-04:

This pace is not applicable hither as the given centre point coordinates is (0, 0).

Step-05:

Pace-03 is executed similarly until Xyard+1 >= Y1000+i equally follows-

Pone thousand Pk+one (Xk+one, Ythousand+ane)
(0, ten)
-ix -6 (one, 10)
-6 -i (2, 10)
-one half-dozen (3, 10)
6 -3 (4, nine)
-iii eight (five, nine)
viii v (6, eight)
Algorithm Terminates

These are all points for Octant-1.

Algorithm calculates all the points of octant-ane and terminates.

At present, the points of octant-two are obtained using the mirror effect by swapping Ten and Y coordinates.

Octant-i Points Octant-two Points
(0, 10) (8, half-dozen)
(i, 10) (9, 5)
(2, ten) (9, iv)
(3, 10) (10, 3)
(iv, nine) (ten, ii)
(v, 9) (10, one)
(half-dozen, viii) (ten, 0)
These are all points for Quadrant-ane.

Now, the points for residue of the part are generated by following the signs of other quadrants.

The other points can also be generated by calculating each octant separately.

Hither, all the points have been generated with respect to quadrant-i-

Quadrant-i (X,Y) Quadrant-2 (-Ten,Y) Quadrant-3 (-X,-Y) Quadrant-4 (X,-Y)
(0, 10) (0, 10) (0, -10) (0, -10)
(ane, 10) (-1, 10) (-1, -10) (one, -10)
(2, 10) (-ii, 10) (-two, -10) (2, -10)
(iii, ten) (-3, ten) (-iii, -ten) (3, -10)
(four, 9) (-4, 9) (-4, -ix) (iv, -nine)
(5, nine) (-five, 9) (-5, -ix) (5, -9)
(6, 8) (-vi, 8) (-6, -8) (6, -8)
(viii, 6) (-8, 6) (-8, -6) (8, -6)
(9, 5) (-9, 5) (-9, -5) (9, -five)
(nine, iv) (-ix, 4) (-ix, -4) (nine, -4)
(ten, three) (-10, 3) (-10, -3) (x, -3)
(10, 2) (-10, ii) (-ten, -ii) (10, -2)
(10, 1) (-10, 1) (-x, -1) (ten, -1)
(x, 0) (-10, 0) (-10, 0) (10, 0)
These are all points of the Circle.

Problem-02:

Given the centre point coordinates (4, -4) and radius equally 10, generate all the points to form a circumvolve.

Solution-

Given-

  • Centre Coordinates of Circumvolve (X0, Y0) = (four, -iv)
  • Radius of Circle = 10

As stated in the algorithm,

  • Nosotros start calculate the points bold the centre coordinates is (0, 0).
  • At the end, nosotros translate the circle.

Step-01, Step-02 and Footstep-03 are already completed in Problem-01.

At present, nosotros discover the values of Xplot and Yplot using the formula given in Step-04 of the main algorithm.

The following table shows the generation of points for Quadrant-1-

  • Xplot = Xc + Ten0 = four + X0
  • Yplot = Yc + Y0 = four + Y0
(Xyard+ane, Yyard+one) (Xplot, Yplot)
(0, ten) (iv, 14)
(1, 10) (5, 14)
(2, 10) (6, 14)
(3, 10) (7, 14)
(4, 9) (eight, 13)
(5, 9) (9, 13)
(vi, 8) (10, 12)
(8, six) (12, x)
(9, 5) (13, 9)
(nine, iv) (xiii, 8)
(ten, 3) (14, 7)
(10, ii) (14, half-dozen)
(ten, 1) (14, v)
(10, 0) (xiv, 4)
These are all points for Quadrant-ane.

The following table shows the points for all the quadrants-

Quadrant-1 (X,Y) Quadrant-ii (-X,Y) Quadrant-three (-Ten,-Y) Quadrant-iv (Ten,-Y)
(4, 14) (4, 14) (iv, -half-dozen) (iv, -vi)
(v, 14) (3, fourteen) (iii, -6) (5, -six)
(vi, 14) (2, 14) (two, -half dozen) (6, -6)
(7, 14) (one, fourteen) (1, -6) (vii, -half-dozen)
(8, 13) (0, xiii) (0, -v) (8, -5)
(9, 13) (-i, thirteen) (-1, -5) (nine, -v)
(10, 12) (-2, 12) (-2, -4) (10, -4)
(12, 10) (-4, 10) (-4, -ii) (12, -ii)
(thirteen, 9) (-5, 9) (-5, -ane) (13, -1)
(13, 8) (-five, 8) (-five, 0) (13, 0)
(14, 7) (-half-dozen, seven) (-6, i) (14, i)
(fourteen, half dozen) (-six, six) (-6, 2) (fourteen, 2)
(14, v) (-6, five) (-six, 3) (xiv, 3)
(fourteen, 4) (-6, four) (-6, iv) (14, four)
These are all points of the Circle.

Advantages of Mid Point Circle Drawing Algorithm-

The advantages of Mid Bespeak Circle Cartoon Algorithm are-

  • Information technology is a powerful and efficient algorithm.
  • The entire algorithm is based on the unproblematic equation of circumvolve 102 + Y2 = Rii.
  • It is easy to implement from the programmer'due south perspective.
  • This algorithm is used to generate curves on raster displays.

Disadvantages of Mid Point Circle Drawing Algorithm-

The disadvantages of Mid Bespeak Circle Cartoon Algorithm are-

  • Accuracy of the generating points is an issue in this algorithm.
  • The circumvolve generated past this algorithm is not smooth.
  • This algorithm is time consuming.

Important Points

  • Circle drawing algorithms take the advantage of 8 symmetry property of circle.
  • Every circumvolve has eight octants and the circle drawing algorithm generates all the points for one octant.
  • The points for other vii octants are generated by changing the sign towards X and Y coordinates.
  • To take the reward of viii symmetry holding, the circle must be formed assuming that the centre point coordinates is (0, 0).
  • If the centre coordinates are other than (0, 0), so we add together the X and Y coordinate values with each betoken of circle with the coordinate values generated by assuming (0, 0) as centre signal.

To gain meliorate understanding nigh Mid Point Circle Drawing Algorithm,

Lookout this Video Lecture

Adjacent Article- Bresenham Circle Drawing Algorithm

Go more notes and other report cloth of Computer Graphics.

Watch video lectures past visiting our YouTube channel LearnVidFun.

Summary

Mid Point Circle Drawing Algorithm

Article Name

Mid Indicate Circle Drawing Algorithm

Description

Circumvolve Cartoon Algorithms- Midpoint Circumvolve Cartoon Algorithm is a famous circle drawing algorithm. Midpoint Circle Drawing Algorithm takes the eye betoken & radius of circumvolve and generates the points for 1 octant.

Author

Akshay Singhal

Publisher Name

Gate Vidyalay

Publisher Logo

mcphersonwhates.blogspot.com

Source: https://www.gatevidyalay.com/mid-point-circle-drawing-algorithm/