0
|
4855 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
GROUPS:

# How To Generate Random Points on the Positive Side of a Plane in 3-D

Posted 10 years ago
 Hello all,Here is what I am struggling with:I have a cube, whose origin is (0,0,0) and one egde length is e.I am generating random planes with respect to the equationz = a*x + b*y + cIn order to generate planes, I randomly generate a, b and c first.After that, I put random points on the planes I have generated.However, I need my points to be in the cube.But when I generate my planes randomly, most of the times, z coordinate is huge.For instance: If my cube is (100 x 100 x 100) andIf I generate x coordinate as 9, then only way for my point to be inside the cube is (9,0,100).I don't want this for two reasons:1. The points are distributed so apart, as in example (I generated 10 different planes and those are three random points on three of them) z = 11x + 9y + 5 42(3.00,0.00,38.00) z = 13x + 3y + 2 43(2.00,8.00,52.00) z = 11x + 9y + 5 44(6.00,3.00,98.00)2. Some of my points are outside of the cubePlease suggest an algorithm for me to generate proper planes and random points on those planes.
2 Replies
Sort By:
Posted 10 years ago
 You could instead generate three points in the cube, and then compute the plane equation parameters from those.An alternative might be to generate a random direction vector (equivalent to a random point ont he sphere-- there are several ways to do this). Start with the plane through the origin with that direction vector. Then generate one point in the cube and take the translation of your starting plane that goes through that point.
Posted 10 years ago
 I have found the solution in case you are curious:I write the plane equation as two line equations:z = a*x + cz = b*y + cfirst, I generate c.Then, I generate a and b.When generating x and y coordinates, I use the following constraints:x < ((n - c)/a)y < ((n - c) / b)To avoid coordinates like 0.0002 and distribute the points regularly, while generating a and b, I use the following:a > (n - c) / nb > (n - c) / n If I generate c between a reasonable interval, then my points are perfectly distributed onto random planes.