UnitSphere

Description
A small collection of functions that calculates random unit vectors for different purposes.


 * UnitSphere.GetPointOnCap(float spotAngle);
 * It calculates a random point on the unit sphere surface like Unity's Random.onUnitSphere but it only returns vectors that are within a cone-shaped area. This cone is oriented along the z-axis and coneAngle specifies the size of the area. 90° represents a hemisphere and 180° the full sphere like onUnitSphere.


 * UnitSphere.GetPointOnRing(float innerSpotAngle, float outerSpotAngle);
 * This one works like GetPointOnCap but it have another, inner cone that is excluded

Usage
The functions are all static functions so you can call it from everywhere. Just save the script as UnitSphere.cs

C# - UnitSphere.cs
--Bunny83 13:27, 16 April 2011 (PDT)