Description
The VectorInSphere
method is a static extension method for the System.Random
class. It generates a random Vector3
point within a sphere of a specified radius. This method is useful for scenarios where you need to randomly distribute points within a spherical volume.
Usage
To use the VectorInSphere
method, you need to have an instance of System.Random
. You can then call this method on the instance, passing the desired radius of the sphere as a parameter. The method will return a Vector3
representing a random point within the sphere.
Example
// Example usage of VectorInSphere
System.Random random = new System.Random();
float radius = 5.0f;
Vector3 randomPointInSphere = random.VectorInSphere(radius);
// randomPointInSphere now contains a random point within a sphere of radius 5.0