dirtyb115
November 30th, 2005, 02:48 PM
HI all, I need a little advice for a simple 2d application that i am currently working on. I am the standard opengl libraires and glut. Anyways, I need to draw 100 circles, of the same radius, in random positions. The only catch is non of them can overlap. Anyone have any suggestions on how i could test and replace any overlapping circles?
ahoodin
November 30th, 2005, 04:06 PM
Create a 100 element vector array of center points.
Well better make it a small radius, but:
while (circle counter is less than 100)
begin loop
1 Get two random numbers well call them x and y. Thes will be the center.
2 Make sure that these two are not within (radius) length of any center.
if within radius throw out center and do not increment circle counter.
if outside radius add center to vector array and increment circle counter.
end loop
Note you may want to make sure that your not in an endless loop somehow. Such as count the iterations of your while loop and if they are less than some high number just keep plugging.
HTH,
ahoodin
And if this did help don't forget to rate.