well if you got the plane A.x + B.y + C.z + D = 0
then n(A,B,C)
is the normal vector. So I think the easiest approach to your task is to use basis vectors. So you need 2
perpendicular vectors on this plane. For that you can exploit cross product. first some definitions:
knowns:
p
planet center position (or the center point of your rotations or any point on the plane so in worst case you can try p=0,0,-D/C
or any other combinationn...)
n
normal vector
q= (1,0,0) or (0,1,0)
chose the one that has lesser |dot(n,q)|
operations:
vector = cross(a,b) = a
x b
- cross product returns perpendicular vector to a,b
scalar = dot(a,b) = (a
.b)
- dot product returns 0
if a,b
are perpendicular
|a| = abs(a)
- absolute value (both scalar and vector)
scalar = Rand()
- float pseudo random value on interval <0.0,1.0>
unknowns:
u,v
- basis vectors
r
- your pseudo-random point
So first get u,v
by exploiting cross product:
u=cross(n,q)
v=cross(n,u)
And now the point:
r = p + u*(2.0*Rand()-1.0) + v*(2.0*Rand()-1.0)
If you want just random vector then ignore the start position p
r' = u*(2.0*Rand()-1.0) + v*(2.0*Rand()-1.0)
That is all ... so you can compute u,v
once (per normal vector change) and generate the r
as often as you need. If u,v
are unit vectors then this will generate points inside 2x2
square ... if you want more or less just add scales to them ...
see Is it possible to make realistic n-body solar system simulation? and generate random orbital parameters for Kepler's equation instead ...