# distributing points over the surface

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

## Recommended Posts

I have a model loaded in a directx app and generating poinsts randomly over the model surface. I want to arrange these points as to be placed uniformly over the surface not as most points in one triange and none in other. How can this be acheived? Thanks

##### Share on other sites
First randomly pick the triangle, weighted by the area of each triangle. Then uniformly sample a random point within the triangle. Tell me if you need help with either of these steps.

##### Share on other sites
You can get better results with that method if you stratify points in the rectangle containing the triangle, then fold them back over.

The best way to do a uniform point distribution on the surface of a mesh is to use point repulsion.

First, randomly distribute points on your mesh, then have each point be repelled by its neighbours with a force inversely proportional to the distance between the points. Do this repulsion process in a number of iterative steps, say 5-10, taking care to keep the points constrained to the mesh, and you will end up with something close to a poission distribution (i.e. all points are roughly equidistant from each other).

##### Share on other sites
Quote:
 Original post by playmesumch00nsYou can get better results with that method if you stratify points in the rectangle containing the triangle, then fold them back over.

Well, the parallelogram containing the triangle, not the rectangle containing the triangle. But yeah, that's the standard method for uniform sampling within a triangle. As for the iterative relaxation you suggest... TriML, do you want points randomly distributed but overall uniformly distributed, or do you want them in as uniform a manner (think geodesic spheres) as possible?

##### Share on other sites
Thanks for the replies

Sneftel:
What i m currently doing is picking a triangle randomly from the list of all triangles of the mesh, dont know about area-weighted...and then generating a point randomly in this triangle. This is fine, points are being generated on the surface of the model but they are not enenly distributed.

playmesumch00ns:
So for point repulsion, i have to calculate the force between points. Can u explain it a little?

##### Share on other sites
Quote:
 Original post by Snefteldo you want points randomly distributed but overall uniformly distributed

yes that's the case

##### Share on other sites
Quote:
 Original post by TriMLWhat i m currently doing is picking a triangle randomly from the list of all triangles of the mesh, dont know about area-weighted.

Area weighting is important. Otherwise, most points are going to end up in high-poly regions like faces.

##### Share on other sites
Quote:
 Original post by SneftelArea weighting is important. Otherwise, most points are going to end up in high-poly regions like faces.

hmm... and how can i do that? and will it produce points uniform on the surface?

##### Share on other sites
say you got three triangles (t1,t2,t3) the first two of which are 1 square meter and the third is 3 square meter. so you pick a triangle based on these probability

p(t1) = 1/(3+1+1) = 1/5
p(t2) = 1/5
p(t3) = 3/5

there are many ways to do this. the most straightforward way is when you know how many samples you want to take. say I know I want to take 10,000 samples. I just simply do this.

sample t1 10000*1/5 times
sample t3 10000*3/5 times
etc etc.

Tim

##### Share on other sites
Look at it like throwing darts at a dartboard. You have a smaller chance of hitting the bullseye because it is smaller. Throwing darts doesn't result in a uniform distribution but it serves to show intuitively that your chance depends upon the area.

1. 1
Rutin
37
2. 2
3. 3
4. 4
5. 5

• 11
• 15
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633352
• Total Posts
3011483
• ### Who's Online (See full list)

There are no registered users currently online

×