Since I thought this could be useful to someone, here is how to get random points on a sphere and on a circle
This will give unit length vectors, you just need to multiply the vector by the radius and it gives you a random point on a sphere/circle of this radius
Firsly, on a circle.
I used the formula
x=cos(alpha)
z=sin(alpha)
variables
{
global:
1: Alpha
4: Point_on_circle
}
rule("Randomize point on a circle")
{
event
{
Ongoing - Global;
}
actions
{
Set Global Variable(Alpha, Random Real(0, 360));
Set Global Variable(Point_on_circle, Vector(Cosine From Degrees(Global Variable(Alpha)), 0, Sine From Degrees(Global Variable(
Alpha))));
}
}
And now on a sphere.
I used the formula with I and j both being random number ∈ [0,1)
θ=2×π×i
φ=arcos(2×j−1)
x=cos(θ)×sin(φ)
y=sin(θ)×sin(φ)
z=cos(φ)
variables
{
global:
0: Point_on_sphere
2: Theta
3: Phi
}
rule("Randomize point on a sphere")
{
event
{
Ongoing - Each Player;
All;
All;
}
actions
{
Set Global Variable(Theta, Multiply(Multiply(2, Divide(22, 7)), Random Real(0, 1)));
Set Global Variable(Phi, Arccosine In Radians(Subtract(Multiply(2, Random Real(0, 1)), 1)));
Set Global Variable(Point_on_sphere, Vector(Multiply(Cosine From Radians(Global Variable(Theta)), Sine From Radians(
Global Variable(Phi))), Multiply(Sine From Radians(Global Variable(Theta)), Sine From Radians(Global Variable(Phi))),
Cosine From Radians(Global Variable(Phi))));
}
}