Show / Hide Table of Contents

    Class MathHelper

    Contains common mathematical functions and constants.

    Inheritance
    System.Object
    MathHelper
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: AGS.API
    Assembly: AGS.API.dll
    Syntax
    public static class MathHelper

    Fields

    | Improve this Doc View Source

    E

    Defines the value of E as a System.Single.

    Declaration
    public const float E = 2.71828175F
    Field Value
    Type Description
    System.Single
    | Improve this Doc View Source

    Log10E

    Defines the base-10 logarithm of E.

    Declaration
    public const float Log10E = 0.4342945F
    Field Value
    Type Description
    System.Single
    | Improve this Doc View Source

    Log2E

    Defines the base-2 logarithm of E.

    Declaration
    public const float Log2E = 1.442695F
    Field Value
    Type Description
    System.Single
    | Improve this Doc View Source

    Pi

    Defines the value of Pi as a System.Single.

    Declaration
    public const float Pi = 3.14159274F
    Field Value
    Type Description
    System.Single
    | Improve this Doc View Source

    PiOver2

    Defines the value of Pi divided by two as a System.Single.

    Declaration
    public const float PiOver2 = 1.57079637F
    Field Value
    Type Description
    System.Single
    | Improve this Doc View Source

    PiOver3

    Defines the value of Pi divided by three as a System.Single.

    Declaration
    public const float PiOver3 = 1.04719758F
    Field Value
    Type Description
    System.Single
    | Improve this Doc View Source

    PiOver4

    Definesthe value of Pi divided by four as a System.Single.

    Declaration
    public const float PiOver4 = 0.7853982F
    Field Value
    Type Description
    System.Single
    | Improve this Doc View Source

    PiOver6

    Defines the value of Pi divided by six as a System.Single.

    Declaration
    public const float PiOver6 = 0.5235988F
    Field Value
    Type Description
    System.Single
    | Improve this Doc View Source

    ThreePiOver2

    Defines the value of Pi multiplied by 3 and divided by two as a System.Single.

    Declaration
    public const float ThreePiOver2 = 4.712389F
    Field Value
    Type Description
    System.Single
    | Improve this Doc View Source

    TwoPi

    Defines the value of Pi multiplied by two as a System.Single.

    Declaration
    public const float TwoPi = 6.28318548F
    Field Value
    Type Description
    System.Single

    Methods

    | Improve this Doc View Source

    BinomialCoefficient(Int32, Int32)

    Calculates the binomial coefficient n above k.

    Declaration
    public static long BinomialCoefficient(int n, int k)
    Parameters
    Type Name Description
    System.Int32 n

    The n.

    System.Int32 k

    The k.

    Returns
    Type Description
    System.Int64

    n! / (k! * (n - k)!)

    | Improve this Doc View Source

    Clamp(Double, Double, Double)

    Clamps a number between a minimum and a maximum.

    Declaration
    public static double Clamp(double n, double min, double max)
    Parameters
    Type Name Description
    System.Double n

    The number to clamp.

    System.Double min

    The minimum allowed value.

    System.Double max

    The maximum allowed value.

    Returns
    Type Description
    System.Double

    min, if n is lower than min; max, if n is higher than max; n otherwise.

    | Improve this Doc View Source

    Clamp(Int32, Int32, Int32)

    Clamps a number between a minimum and a maximum.

    Declaration
    public static int Clamp(int n, int min, int max)
    Parameters
    Type Name Description
    System.Int32 n

    The number to clamp.

    System.Int32 min

    The minimum allowed value.

    System.Int32 max

    The maximum allowed value.

    Returns
    Type Description
    System.Int32

    min, if n is lower than min; max, if n is higher than max; n otherwise.

    | Improve this Doc View Source

    Clamp(Single, Single, Single)

    Clamps a number between a minimum and a maximum.

    Declaration
    public static float Clamp(float n, float min, float max)
    Parameters
    Type Name Description
    System.Single n

    The number to clamp.

    System.Single min

    The minimum allowed value.

    System.Single max

    The maximum allowed value.

    Returns
    Type Description
    System.Single

    min, if n is lower than min; max, if n is higher than max; n otherwise.

    | Improve this Doc View Source

    DegreesToRadians(Double)

    Convert degrees to radians

    Declaration
    public static double DegreesToRadians(double degrees)
    Parameters
    Type Name Description
    System.Double degrees

    An angle in degrees

    Returns
    Type Description
    System.Double

    The angle expressed in radians

    | Improve this Doc View Source

    DegreesToRadians(Single)

    Convert degrees to radians

    Declaration
    public static float DegreesToRadians(float degrees)
    Parameters
    Type Name Description
    System.Single degrees

    An angle in degrees

    Returns
    Type Description
    System.Single

    The angle expressed in radians

    | Improve this Doc View Source

    Factorial(Int32)

    Calculates the factorial of a given natural number.

    Declaration
    public static long Factorial(int n)
    Parameters
    Type Name Description
    System.Int32 n

    The number.

    Returns
    Type Description
    System.Int64

    n!

    | Improve this Doc View Source

    InverseSqrtFast(Double)

    Returns an approximation of the inverse square root of left number.

    Declaration
    public static double InverseSqrtFast(double x)
    Parameters
    Type Name Description
    System.Double x

    A number.

    Returns
    Type Description
    System.Double

    An approximation of the inverse square root of the specified number, with an upper error bound of 0.001

    Remarks

    This is an improved implementation of the the method known as Carmack's inverse square root which is found in the Quake III source code. This implementation comes from http://www.codemaestro.com/reviews/review00000105.html. For the history of this method, see http://www.beyond3d.com/content/articles/8/

    | Improve this Doc View Source

    InverseSqrtFast(Single)

    Returns an approximation of the inverse square root of left number.

    Declaration
    public static float InverseSqrtFast(float x)
    Parameters
    Type Name Description
    System.Single x

    A number.

    Returns
    Type Description
    System.Single

    An approximation of the inverse square root of the specified number, with an upper error bound of 0.001

    Remarks

    This is an improved implementation of the the method known as Carmack's inverse square root which is found in the Quake III source code. This implementation comes from http://www.codemaestro.com/reviews/review00000105.html. For the history of this method, see http://www.beyond3d.com/content/articles/8/

    | Improve this Doc View Source

    NextPowerOfTwo(Double)

    Returns the next power of two that is larger than the specified number.

    Declaration
    public static double NextPowerOfTwo(double n)
    Parameters
    Type Name Description
    System.Double n

    The specified number.

    Returns
    Type Description
    System.Double

    The next power of two.

    | Improve this Doc View Source

    NextPowerOfTwo(Int32)

    Returns the next power of two that is larger than the specified number.

    Declaration
    public static int NextPowerOfTwo(int n)
    Parameters
    Type Name Description
    System.Int32 n

    The specified number.

    Returns
    Type Description
    System.Int32

    The next power of two.

    | Improve this Doc View Source

    NextPowerOfTwo(Int64)

    Returns the next power of two that is larger than the specified number.

    Declaration
    public static long NextPowerOfTwo(long n)
    Parameters
    Type Name Description
    System.Int64 n

    The specified number.

    Returns
    Type Description
    System.Int64

    The next power of two.

    | Improve this Doc View Source

    NextPowerOfTwo(Single)

    Returns the next power of two that is larger than the specified number.

    Declaration
    public static float NextPowerOfTwo(float n)
    Parameters
    Type Name Description
    System.Single n

    The specified number.

    Returns
    Type Description
    System.Single

    The next power of two.

    | Improve this Doc View Source

    RadiansToDegrees(Double)

    Convert radians to degrees

    Declaration
    public static double RadiansToDegrees(double radians)
    Parameters
    Type Name Description
    System.Double radians

    An angle in radians

    Returns
    Type Description
    System.Double

    The angle expressed in degrees

    | Improve this Doc View Source

    RadiansToDegrees(Single)

    Convert radians to degrees

    Declaration
    public static float RadiansToDegrees(float radians)
    Parameters
    Type Name Description
    System.Single radians

    An angle in radians

    Returns
    Type Description
    System.Single

    The angle expressed in degrees

    | Improve this Doc View Source

    Swap(ref Double, ref Double)

    Swaps two double values.

    Declaration
    public static void Swap(ref double a, ref double b)
    Parameters
    Type Name Description
    System.Double a

    The first value.

    System.Double b

    The second value.

    | Improve this Doc View Source

    Swap(ref Single, ref Single)

    Swaps two float values.

    Declaration
    public static void Swap(ref float a, ref float b)
    Parameters
    Type Name Description
    System.Single a

    The first value.

    System.Single b

    The second value.

    • Improve this Doc
    • View Source
    Back to top Generated by DocFX