#### Archived

This topic is now archived and is closed to further replies.

# Distribution of points on a plane

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

## Recommended Posts

I''d like to uniformly distribute points on a plane bounded by a bounding box. Any help here with the math/implementation. Thanks in advance.

##### Share on other sites
quote:
Original post by drown
I''d like to uniformly distribute points on a plane bounded by a bounding box. Any help here with the math/implementation. Thanks in advance.

Quick-and-dirty hack: generate uniformly points inside the bounding sphere for your bounding box (search google for uniform random distribution sphere), project on the plane, then cull those outside the box.

##### Share on other sites
Is the plane aligned with an axis of the bounding box? If so, that will make your life easier.

WHat you can do is parameterize the plane by finding two basis vectors. Then, you figure out the extents of your bounding box. Finally, generate random numbers between those extents, and get the 3space point from your parameterization.

EG:
plane has (0,1,0) normal, bbox is (-50,-50,-10),(50,50,10)
so basis vectors are (1,0,0) and (0,0,1)
parameterization extents are [-50,50], [-10,10]
So, let''s generate a random point.
pt = rand()%(extentmax - extentmin) + extentmin
u = rand()%(100) - 50
t = rand()%(20) - 10
point = (1,0,0)*u + (0,0,1) * t

##### Share on other sites
Thanks for the replies, both are interesting ideas. The reason I''m doing this is to calculate ray sample points for PVS calculation. So there is no guarantee that the plane will orient itself with the BB. And the sphere idea might be a possibility...

The loose idea I have is to calculate the intersection points of the BB''s edges with the plane and use those to construct a quad polygon. Then somehow (scanline?) distribute uniform points within that quad. I don''t know if this would work, but it''s just an idea.

Antipenumbral tests might be better here? But there''s very few good, free sources of information about this.

##### Share on other sites
quote:
The loose idea I have is to calculate the intersection points of the BB''s edges with the plane and use those to construct a quad polygon. Then somehow (scanline?) distribute uniform points within that quad.

The intersection of an arbitrary oriented plane with a box is a hexagon, not a quad.

Now I think of it, the sphere idea would NOT give you uniformly distributed points in that hexagon.

Generate points on the plane in some reasonable extent - e.g. a square centered around the point where the box center is projected, with a side big enough that it covers the entire box projection. Cull those points that aren''t inside the box.

Recap:

ProjCenter = Project(Center(BBox), Plane)
MaxRad = Max( Distance(ProjCenter, Project(each of 6 box vertices), Plane)
XVec, YVec = two non-colinear unit vectors, coplanar with Plane
while more points needed
PointCandidate = ProjCenter + XVec * MaxRad * Rand() + YVec * MaxRad * Rand()
if BBox.Contains(PointCandidate)
Add PointCandidate to list of points

Since the XVec * MaxRad * Rand() + YVec * MaxRad * Rand() transformation is affine, it preserves the uniformity of the distribution.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633736
• Total Posts
3013600
×