Uniform distribution of points in a 2D convex hull

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

Recommended Posts

Hi all,

Given a set of points N and a convex hull H, how can I place the points in N such that they are uniformly distributed in H? All points in N must be inside of H.

I'm defining uniform distribution in this case to be:
For each point p in N:
the minimum distance between p and (any other point in N OR the perimeter of H) = p_d

All p_d values should have minimal variance for N to be uniformly distributed in H.

I'm looking for a good balance between distribution and time complexity, so approximations are welcome! I'm only concerned about 2D for right now, but solutions that naturally extend to 3D would be awesome.

Thank you,

Share on other sites
This is a tricky problem. The first thing I would try is to throw the points in following a uniform random distribution and then iterate through the process of finding the closest pair of points and pushing both of them away from each other a little bit. See if you can get reasonable results with that.

Share on other sites
A Poisson disc would be perfect for your needs, as it specifically focuses on keeping a minimal distance between sample points. You'll still need to check intersection with the hull in case a point happens to fall outside it by chance.

Otherwise, if Poisson disc does not apply in your case for some reason or you are just looking for a more ghetto (or intuitive, depending on your perspective) solution, read on:

If you do not need perfect correctness (i.e. some points may be closer together and others may be further away, or in other words, the variance of the distance should be nonzero but not too large), then another probabilistic way to do it is to generate a regular point lattice with distance equal to your mean minimum distance, and displace each point in every dimension using a Gaussian distribution with your required variance? Like this:

Let [eqn]\mu[/eqn] be the mean distance between each point, and [eqn]\sigma[/eqn] be the required variance.
1. Generate a regular lattice spaced by [eqn]\mu[/eqn] in every dimension.
2. For each point in the lattice:
- choose a random angle (or two, if you are in three dimensions) to displace the point in some direction in space
- generate a random variable [eqn]z[/eqn] following a Gaussian distribution* with your variance but with mean 0
- displace the point by [eqn]z[/eqn] units in the direction determined by the angle chosen above
- if the point falls outside or too close to your convex hull, try again until it works (this is biased, but I think it's acceptable given that considering the shape of the hull would likely be intractable)

* see Box-Muller transform to get that from uniform variables
[/quote]

Some examples rendered with a throwaway program, with a mean [eqn]\mu = 1[/eqn] and a progressively higher variance (from 0 to 0.0003) - remember to square root the variance if you need the standard deviation:

Obviously, as variance increases, the distribution tends to perfect uniformity (assuming an infinite lattice - if it is finite, the algorithm will degenerate).

The 3D situation is exactly the same, your lattice is now 3D and you are displacing the points according to two angles (spherical coordinates i.e. azimuth and elevation instead of just rotation in 2D), but you still only need one Gaussian distribution sample. Edited by Bacterius

Share on other sites
I need to insist on proper language: you want Poisson disk sampling, not a uniform distribution of points. In a uniform distribution, every point inside your polygon would be equally probable, with no consideration for their distances; your "uniform" property is actually called low discrepancy,

If you care a lot about equalizing distances between samples, you should start from the right number of uniformly distributed samples, build their Voronoi graph, and move them iteratively until each of them has satisfying distances from its closest neighbours (and maybe from the polygon edges or from samples outside the polygon). For example, you could pretend that the samples are material points and move them with forces computed from Delaunay edges: if they are shorter than the median they push and if they are longer than the median they pull.