Message Boards Message Boards

0
|
4932 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

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

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 equation
z = a*x + b*y + c
In 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) and
If 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 cube

Please suggest an algorithm for me to generate proper planes and random points on those planes.
POSTED BY: Onur Cagirici
2 Replies
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 BY: Daniel Lichtblau
I have found the solution in case you are curious:

I write the plane equation as two line equations:
z = a*x + c
z = b*y + c
first, 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) / n
b > (n - c) / n
 If I generate c between a reasonable interval, then my points are perfectly distributed onto random planes.
POSTED BY: Onur Cagirici
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract