Defining a circle using Polar Co-ordinates :
The second method of defining a circle makes use of polar coordinates as shown in fig:
x=r cos θ y = r sin θ
Where θ=current angle
r = circle radius
x = x coordinate
y = y coordinate
By this method, θ is stepped from 0 to & each value of x & y is calculated.
Algorithm:
Step1: Set the initial variables:
r = circle radius
(h, k) = coordinates of the circle center
i = step size
θ_end=
θ=0
Step2: If θ>θendthen stop.
Step3: Compute
x = r * cos θ y=r*sin?θ
Step4: Plot the eight points, found by symmetry i.e., the center (h, k), at the current (x, y) coordinates.
Plot (x + h, y +k) Plot (-x + h, -y + k)
Plot (y + h, x + k) Plot (-y + h, -x + k)
Plot (-y + h, x + k) Plot (y + h, -x + k)
Plot (-x + h, y + k) Plot (x + h, -y + k)
Step5: Increment θ=θ+i
Step6: Go to step (ii).
Program to draw a circle using Polar Coordinates:
Output: