Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculating the position of points in a circle

I'm having a bit of a mind blank on this at the moment. I've got a problem where I need to calculate the position of points around a central point, assuming they're all equidistant from the center and from each other.

The number of points is variable so it's DrawCirclePoints(int x) I'm sure there's a simple solution, but for the life of me, I just can't see it :)

like image 835
JoeBrown Avatar asked Mar 14 '11 15:03

JoeBrown


People also ask

How do you find the position of a point on a circle?

To determine the position of a given point with respect to a circle, all we need to do is to find the distance between the point and the center of the circle, and compare it with the circle's radius. If the distance is greater than the radius, the point lies outside.

How do you find the coordinates of the center of a circle?

The center of a circle is the midpoint of the diameter. So, by using the midpoint formula, if the endpoints of the diameter are (a, b) and (c, d), then the coordinates of the center of circle are [(a + c)/2, (b + d)/2].


2 Answers

Given a radius length r and an angle t in radians and a circle's center (h,k), you can calculate the coordinates of a point on the circumference as follows (this is pseudo-code, you'll have to adapt it to your language):

float x = r*cos(t) + h; float y = r*sin(t) + k; 
like image 86
Brian Driscoll Avatar answered Oct 16 '22 05:10

Brian Driscoll


A point at angle theta on the circle whose centre is (x0,y0) and whose radius is r is (x0 + r cos theta, y0 + r sin theta). Now choose theta values evenly spaced between 0 and 2pi.

like image 43
Gareth McCaughan Avatar answered Oct 16 '22 04:10

Gareth McCaughan