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 :)
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.
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].
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;
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With