MathHelper
Contains common mathematical functions and constants.
Methods
public static long BinomialCoefficient(int n, int k)
result = MathHelper.BinomialCoefficient(n, k)
Calculates the binomial coefficient above .
- n
- The n.
- k
- The k.
Returns: n! / (k! * (n - k)!)
public static double DegreesToRadians(double degrees)
result = MathHelper.DegreesToRadians(degrees)
Convert degrees to radians
- degrees
- An angle in degrees
Returns: The angle expressed in radians
public static long Factorial(int n)
result = MathHelper.Factorial(n)
Calculates the factorial of a given natural number.
- n
- The number.
Returns: n!
public static double InverseSqrtFast(double x)
result = MathHelper.InverseSqrtFast(x)
Returns an approximation of the inverse square root of left number.
- x
- A number.
Returns: An approximation of the inverse square root of the specified number, with an upper error bound of 0.001
public static float InverseSqrtFast(float x)
result = MathHelper.InverseSqrtFast(x)
Returns an approximation of the inverse square root of left number.
- x
- A number.
Returns: An approximation of the inverse square root of the specified number, with an upper error bound of 0.001
public static long NextPowerOfTwo(long n)
result = MathHelper.NextPowerOfTwo(n)
Returns the next power of two that is larger than the specified number.
- n
- The specified number.
Returns: The next power of two.
public static double NextPowerOfTwo(double n)
result = MathHelper.NextPowerOfTwo(n)
Returns the next power of two that is larger than the specified number.
- n
- The specified number.
Returns: The next power of two.
public static float NextPowerOfTwo(float n)
result = MathHelper.NextPowerOfTwo(n)
Returns the next power of two that is larger than the specified number.
- n
- The specified number.
Returns: The next power of two.
public static int NextPowerOfTwo(int n)
result = MathHelper.NextPowerOfTwo(n)
Returns the next power of two that is larger than the specified number.
- n
- The specified number.
Returns: The next power of two.
public static double RadiansToDegrees(double radians)
result = MathHelper.RadiansToDegrees(radians)
Convert radians to degrees
- radians
- An angle in radians
Returns: The angle expressed in degrees
public static void Swap(double a, double b)
MathHelper.Swap(a, b)
Swaps two double values.
- a
- The first value.
- b
- The second value.
public static void Swap(float a, float b)
MathHelper.Swap(a, b)
Swaps two float values.
- a
- The first value.
- b
- The second value.
Fields
public const double PiOver2
value = MathHelper.PiOver2
Defines the value of Pi divided by two as a Single.
public const double PiOver3
value = MathHelper.PiOver3
Defines the value of Pi divided by three as a Single.
public const double PiOver4
value = MathHelper.PiOver4
Definesthe value of Pi divided by four as a Single.
public const double PiOver6
value = MathHelper.PiOver6
Defines the value of Pi divided by six as a Single.
public const double ThreePiOver2
value = MathHelper.ThreePiOver2
Defines the value of Pi multiplied by 3 and divided by two as a Single.
public const double TwoPi
value = MathHelper.TwoPi
Defines the value of Pi multiplied by two as a Single.