GetRandomPolarCoordinates() 정적인 개인적인 메소드

Generates a random Vector3 point in a Polar Coordinate System.
static private GetRandomPolarCoordinates ( Random dice ) : Vector3
dice System.Random The Random instance to be used when generating data.
리턴 Vector3
예제 #1
0
        /// <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));
        }
예제 #2
0
        /// <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));
        }