Go to: Synopsis. Return value. Related. MEL examples.
sphrand
[string] float|vector
sphrand is NOT undoable, NOT queryable, and NOT editable.
This command generates random vectors evenly distributed inside a sphere of the specified radius. If a vector argument is given, sphrand scales the output by the components of the vector argument.
Multiple random number streams:
The two stream-based variants of sphrand accept a
string parameter which specifies the name of the random number
stream to use when generating random numbers. The behaviour of the
function is identical to the non-stream versions with the exception
that random number generation is performed from the specified rather
than the default random number stream. For more details on multiple
random number streams please see the rand function.
float | or vector |
// This command may be used to generate evenly distributed points on // the surface of a sphere when the output is normalized. $radius = 42; $result=unit(sphrand(1)) * $radius; // Result: <<5.35843, 28.2859, -30.581>> // string $s1 = "stream1"; $result=unit(sphrand($s1,1)) * $radius; // Result: <<5.35843, 28.2859, -30.581>> //