nPoints evenly spaced inside circle

nPoints evenly spaced inside circle

stuzzz
Collaborator Collaborator
852 Views
8 Replies
Message 1 of 9

nPoints evenly spaced inside circle

stuzzz
Collaborator
Collaborator

Hello,

 

I'm not sure if that's the right place to ask that question but:

I'd like to compute the positions of a determined amount of points inside a circle (ideally an arbitrary shape). This points have to be equidistant (evenly distributed).

 

Thanks!

 

0 Likes
853 Views
8 Replies
Replies (8)
Message 2 of 9

stuzzz
Collaborator
Collaborator

I've found the vogel method which works fine but only for circle.

 

 

0 Likes
Message 3 of 9

jmreinhart
Advisor
Advisor

I'm not sure what the vogel method is, unless you meant voxel?

 

There are three patterns you can use the create a set of points that are all equidistant from their closest neighbors.

jonahrnhrt_0-1586018145592.png

You can see this when you are tiling a plane. If your points at are the center of the polygons, then they will be evenly distributed. You'd just need to choose a starting point in the shape, and then build out to each of the neighboring points and if those points are inside the shape continue the process until none of the points have neighbors that are inside the shape. 

 

It might be easier/faster to get a bounding box for your shape and use that to quickly find all the points that would be inside that box and then check if they are in your shape.

Message 4 of 9

jmreinhart
Advisor
Advisor

I just realized you may have meant sphere not circle. In that case the only tiling shape is a cube so you would just create a code that loops through the points that would be in some A x B x C 3D grid, and check if they are inside the shape. 

 

To check if the point is inside, find the closest point on the shapes surface. Get the normal vectors at that point. Find the vector from your point to the point on the surface. Take the dot product of the two. If the result is <0 then you are inside the shape. This method will not work for self intersecting shapes.

Message 5 of 9

stuzzz
Collaborator
Collaborator

hi,

 

I really meant Vogel method, here is a link

This works for 2d circles but not for arbitrary shapes(unfortunately). Ideally I need an approach for arbitrary shapes.

here's a python code made from the Vogel forumla:

points = []
num_pts = 100
golden = pi *(3 - sqrt(5))
for index in range(num_pts):
	theta = index * golden
	r = sqrt(index) / sqrt(num_pts)
	pos = (r*cos(theta), 0, r*sin(theta))
        points.append(pos)

 

The yellow tessellation (with triangles) would help. But let say you X amount of points inside that shape, how would you define the distance between these points. Do you think about a loop reevaluation until the X value is found?

 

Message 6 of 9

jmreinhart
Advisor
Advisor

Oh, that's a really interesting method. I've seen graphics showing flower seeds following that method to spread out evenly. Yeah unfortunately that method is only useful for circles. I think your best bet is creating a grid of points and checking if they are in or out. You'll need to iterate the distance to if you want an exact number of points inside the shape. Iterating until you get an exact number of points might be slow (if you have lots of points) so if you just want a result that looks right you could put in a distance have it generate the points inside the shape, and then you could decide if you want more or less and adjust the distance manually. 

0 Likes
Message 7 of 9

stuzzz
Collaborator
Collaborator

Yes, the spiral flower is really nice for circles but has poor result with very few points (less than 10).

I though about the grid also but you are right, it wouldn't be the best approach for efficiency.

We could have an approximation by calculating the area of the shape and dividing that wih the X amount of points as starting point...🙄

This will give an idea of the optimal distance for generating the grid and thus reducing the amount of iterations.

 

I still hope to find a better method.

0 Likes
Message 8 of 9

jmreinhart
Advisor
Advisor

What do you need these points for? There might be a slightly different approach that would suit your needs better.

0 Likes
Message 9 of 9

stuzzz
Collaborator
Collaborator

I'd need to generate a scatter of curves inside a closed nurbs surface.

 

0 Likes