# Finding a set of even spaced points on a circle?

This topic is 4851 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

What's the quickest way to arrange a set of points or objects in a circle, evenly spaced?

##### Share on other sites
In terms of computer programming, take 2 Pi, divide by the number of points, and use sin and cos on multiples of that angle to create the points. e.g.:
angle = 2 PI / 7point = []for i in range(0, 6)  point.append( Point(sin(angle * i), cos(angle * i)) )

##### Share on other sites
If I understand the question right, divide 360 by the number of objects to find the number of degrees between each one.

So, 2 objects will be placed 180 degrees apart
3 - 120 degress apart
4 - 90
5 - 72
6 - 60

.
.
.

##### Share on other sites
Quote:
 Original post by SiCraneIn terms of computer programming, take 2 Pi, divide by the number of points, and use sin and cos on multiples of that angle to create the points. e.g.:angle = 2 PI / 7point = []for i in range(0, 6) point.append( Point(sin(angle * i), cos(angle * i)) )

Yeah this is what I have and its creating a circle, but when I place objects at those points by translating them there, they are not perfectly spaced. Some are showing up closer than others.

##### Share on other sites
Sounds like rounding errors. If you're using ints, try using floats instead.

##### Share on other sites
Quote:
 Original post by TomSounds like rounding errors. If you're using ints, try using floats instead.

Yeah I'm using floats and still having the problem. One thing worth noting is that sin(angle * i), cos(angle * i)) does not create a value large enough for the size of the spheres i'm trying to render, so I multiplied it by 10. That shouldn't be an issue though.

##### Share on other sites
You haven't given your sine function degrees when it was expecting radians, or something really obvious like that? By the way, how bad is the non-uniformity? If it's a pixel or two, it could easily be roundoff error in translating the floats to screen coordinates. And by the way, you are using inbuilt PI values, and not (say) your own #define'd PI = 3.14, or anything?

Edit : Oh, by the way, are you perhaps moving the lower-left corner of your object to the given point? That might give you a bit of trouble if the object is of non-negligible size compared to the circle's radius. Try changing your objects to points and see how that works.

##### Share on other sites
Ok, working now, stupid error was preventing it.

The issue now is that the circle starts at the origin and sweeps around towards positive X axis, but sweeps Y in both positive and negative. Meaning, the center of the circle is not the origin, which is what I want.

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 13
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633326
• Total Posts
3011373
• ### Who's Online (See full list)

There are no registered users currently online

×