Returns a random vector value that exists within a spherical or ellipsoidal region of your choice. An ellipsoid is a sphere scaled along its X-, Y- or Z-axes.
vector sphrand(float radius)
vector sphrand(vector vector)
radius is the radius of a sphere in which the returned vector exists.
vector is the radius of an ellipsoid along the X-, Y-, and Z-axis.
To control the random values returned by this function, see seed.
sphrand(1)
Returns a vector whose randomly selected coordinates reside within an imaginary sphere centered at the origin and with a radius of 1. An example returned vector is <<0.444, -0.427, 0.764>>.
sphrand(<<2,1,1>>)
Returns a vector whose coordinates reside within an ellipsoid centered at the origin and with a radius of 2 along the X-axis, 1 along the Y-axis, and 1 along the Z-axis.
You can use the sphrand function, for example, to create a cluster of 500 particles randomly positioned within an ellipsoid having a radius of 2 in the X-axis, 1 in the Y-axis, and 1 in the Z-axis.
To create a particle ellipsoid:
position = sphrand(<<2,1,1>>);
Maya executes the expression once for each particle. It gives each particle a different random position around the origin within the ellipsoid specified by <<2,1,1>>.