I have a $e \times e \times e$ cube and I want to create random planes with equation $ax + by + cz + d = 0$ inside this cube.
I will put random points on those randomly created planes as well.
Here is my algorithm to do it:
- I randomize $d$ within interval $[0, \dfrac{e}{2}]$.
- I pick a random letter from set $\{a, b, c\}$.
- I set the value of the letter I picked as $1$.
- I randomize the remaining two within interval $[0, \dfrac{d}{e}]$.
When I put random points on a plane, I do it w.r.t the letter I picked at Step 2. Here is my algorithm to put a single point $P(x,y,z)$ on a plane:
- If the letter is $a$:
- List item
- I randomize $y$ and $z$ within interval $[0, (e-d)]$.
- I set the value of $x$ as $by + cz + d$.
- If the letter is $b$:
- I randomize $x$ and $z$ within interval $[0, (e-d)]$.
- I set the value of $y$ as $ax + cz + d$.
- If the letter is $c$:
- I randomize $x$ and $y$ within interval $[0, (e-d)]$.
- I set the value of $z$ as $ax + by + d$.
I do the operations based on this logic:
- $d$ is the distance of the plane from the origin.
- $a$, $b$ and $c$ are the slopes of the plane.
My slopes are low because I don't the part of my planes those fall into the cube so tiny. I randomize $x$, $y$ and $z$ like so, because otherwise, one of them (the one I calculate at the end) goes outside of my cube.
However, my planes are almost orthogonal to each other, since their slopes are too low.
Please suggest me an algorithm to randomize planes and properly put points on them.
Step 1: Choose a point $(r,s,t)$ uniformly at random in the cube.
Step 2: Choose $a,b,c$ uniformly at random from some large interval $[-N,N]$. Set $d=-ar-bs-ct$.
Step 3: Generate a bunch of random (uniformly) $(x,y)$ points in the $[0,1]\times[0,1]$ square. Solve for $z$ from your plane equation; if the $z$ is outside $[0,1]$ then throw out. These are your random points on the plane.