/// <summary> /// Generates a random Vector3 positionned inside a sphere. /// </summary> /// <param name="dice">The Random instance to be used when generating data.</param> /// <param name="maxDistanceFromOrigin">The maximum distance from origin the point can be generated. Usually, the radius of a sphere.</param> /// <returns>Returns a randomly generated Vector3 positionned inside a sphere of a given maximum radius.</returns> static public Vector3 GetRandomPointInSphere(Random dice, int maxDistanceFromOrigin) { Vector3 randomPolarCoordinates = RandomExtensions.GetRandomPolarCoordinates(dice); return(randomPolarCoordinates * dice.Next(0, maxDistanceFromOrigin)); }
/// <summary> /// Generates a random Vector3 on the surface of a sphere. /// </summary> /// <param name="dice">The Random instance to be used when generating data.</param> /// <param name="radius">The radius of the Sphere.</param> /// <returns>Returns a randomly generated Vector3 positionned on the surface of a Sphere.</returns> static public Vector3 GetRandomPointOnSphere(Random dice, float radius) { Vector3 randomPolarCoordinates = RandomExtensions.GetRandomPolarCoordinates(dice); return(Vector3.Multiply(randomPolarCoordinates, radius)); }