问题
I would like to generate random points on a 3D box defined by its (minx, miny, minz) and (maxx, maxy, maxz) corners. I was thinking of generating a random point inside of the box and then somehow projecting it onto one of the box sides. However, I don't have explicit plane information for the box sides and this seems like it will not produce a uniform distribution of points since if some sides of the box are bigger than others, those sides should have more points generated on them.
Any suggestions are appreciated.
Thanks.
回答1:
- Select a side at random weighted by it's area (spare link or this one ...)
- Place a point randomly selected from a uniform distribution on that side
- Lather, rinse, repeat.
or alternately
- Decide on the density of points
- Populate each side in turn with a random set of points having that density
which is more uniform (i.e. less random) but will look fine as long as the density is high enough for each side to have more than a handful of points
来源:https://stackoverflow.com/questions/2671415/uniform-generation-of-points-on-3d-box