Points of a Circle

Hello

I have the centerpoint of a circle (x,y) and radius (r). How can I find all the points of the circle (atleast 360 points).

Thanks
praveenuniAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

snoyes_jwCommented:
There are an infinite number of points on a circle.

For a = 0° to 360°,
x = r cos a
y = r sin a
snoyes_jwCommented:
Sorry, forgot to account for the centerpoint offset.

x' = r cos a + x
y' = r cos a + y

where
r = radius
(x, y) = centerpoint
(x', y') = point on edge of circle

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GwynforWebCommented:
x'(s) = x + r*cos(2*Pi*s)
y'(s) = y + r*sin(2*Pi*s)

where    0<= s <1

ie varying s form 0 to 1 will have the points  ( x'(s), y'(s) ) trace the circle out

So to draw a circle with N points on it center (x,y) radius r (in pseudo code)

inc=1/N
MoveTo(x+r,y)
for (i=1;i<=N;i++){
  s=i*inc
  LineTo(x + r*cos(2*Pi*s) ,y + r*sin(2*Pi*s))
}


Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

avizitCommented:
just another way of saying the same as above


(X-x)^2 + (Y-y)^2 = r^2

put

vary X from  (x-r ) to (x+r)   in as many steps as you want i.e increment by  0.1 , 0.001 etc
and solve for Y and there you have as many solution as you want


TalmashCommented:
changing snoye commnet a little :

For a = 0° to 360°,
x[a] = x + r*cos a
y[a] = y + r* sin a

I guess you want to draw the circle, so you need the points to be given as integers :

For a = 0° to 360°,
x[a] = round(x + r*cos a)
y[a] = round(y + r* sin a)

comment : if your software "cos" and "sin", using RADIANS and not DEGRESS :

For deg = 0° to 360°,
a = 3.1415296 * deg / 180
x[a] = round(x + r*cos a)
y[a] = round(y + r* sin a)




MysidiaCommented:
You can never find all the points of a circle, you can only get "close enough"
for your use.

There are many methods to find the points you want, and the primary
consideration will be how many points you need, how precisely you want them,
and how fast you want them.

If performance is an issue, and the exact number of points isn't so important,
you might look at adapting one of the well-known methods for scan conversion
of circles normally used in graphics, deciding which pixels to draw to represent
a figure on a computer... it is a very similar problem to "getting some of the points
of a circle"

See  http://www.cim.mcgill.ca/~langer/557B/Jan9.html


The real problem is to compute the points in one of the quadrant of the circle:
once you can do that, the horizontal and vertical symmetries automatically
give you all the other points with very little computation.

PaulCaswellCommented:
If you want to implement this in code, you may be better off using Bresenhams circle algorithm. You should be able to find source and discussions all over the place.

Paul
PaulCaswellCommented:
Actually, that was a waste of time because Mysidia's link above has a good discussion of Bresenhams algorithm.

Paul
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Math / Science

From novice to tech pro — start learning today.