Search Results for

    Show / Hide Table of Contents

    Class MathUtil

    Inheritance
    Object
    MathUtil
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: g3
    Assembly: cs.temp.dll.dll
    Syntax
    public static class MathUtil

    Fields

    Deg2Rad

    Declaration
    public const double Deg2Rad = 0.017453292519943295
    Field Value
    Type Description
    Double

    Deg2Radf

    Declaration
    public const float Deg2Radf = 0.0174532924F
    Field Value
    Type Description
    Single

    Epsilon

    Declaration
    public const double Epsilon = 2.2204460492503131E-16
    Field Value
    Type Description
    Double

    Epsilonf

    Declaration
    public const float Epsilonf = 1.1920929E-07F
    Field Value
    Type Description
    Single

    FourPI

    Declaration
    public const double FourPI = 12.566370614359172
    Field Value
    Type Description
    Double

    HalfPI

    Declaration
    public const double HalfPI = 1.5707963267948966
    Field Value
    Type Description
    Double

    HalfPIf

    Declaration
    public const float HalfPIf = 1.57079637F
    Field Value
    Type Description
    Single

    PIf

    Declaration
    public const float PIf = 3.14159274F
    Field Value
    Type Description
    Single

    Rad2Deg

    Declaration
    public const double Rad2Deg = 57.295779513082323
    Field Value
    Type Description
    Double

    Rad2Degf

    Declaration
    public const float Rad2Degf = 57.29578F
    Field Value
    Type Description
    Single

    SqrtThree

    Declaration
    public const double SqrtThree = 1.7320508075688772
    Field Value
    Type Description
    Double

    SqrtTwo

    Declaration
    public const double SqrtTwo = 1.4142135623730951
    Field Value
    Type Description
    Double

    SqrtTwof

    Declaration
    public const float SqrtTwof = 1.41421354F
    Field Value
    Type Description
    Single

    SqrtTwoInv

    Declaration
    public const double SqrtTwoInv = 0.70710678118654746
    Field Value
    Type Description
    Double

    TwoPI

    Declaration
    public const double TwoPI = 6.2831853071795862
    Field Value
    Type Description
    Double

    TwoPIf

    Declaration
    public const float TwoPIf = 6.28318548F
    Field Value
    Type Description
    Single

    ZeroTolerance

    Declaration
    public const double ZeroTolerance = 1E-08
    Field Value
    Type Description
    Double

    ZeroTolerancef

    Declaration
    public const float ZeroTolerancef = 1E-06F
    Field Value
    Type Description
    Single

    Methods

    Area(Vector3d, Vector3d, Vector3d)

    Declaration
    public static double Area(Vector3d v1, Vector3d v2, Vector3d v3)
    Parameters
    Type Name Description
    Vector3d v1
    Vector3d v2
    Vector3d v3
    Returns
    Type Description
    Double

    Area(ref Vector3d, ref Vector3d, ref Vector3d)

    Declaration
    public static double Area(ref Vector3d v1, ref Vector3d v2, ref Vector3d v3)
    Parameters
    Type Name Description
    Vector3d v1
    Vector3d v2
    Vector3d v3
    Returns
    Type Description
    Double

    AspectRatio(Vector3d, Vector3d, Vector3d)

    Declaration
    public static double AspectRatio(Vector3d v1, Vector3d v2, Vector3d v3)
    Parameters
    Type Name Description
    Vector3d v1
    Vector3d v2
    Vector3d v3
    Returns
    Type Description
    Double

    AspectRatio(ref Vector3d, ref Vector3d, ref Vector3d)

    aspect ratio of triangle

    Declaration
    public static double AspectRatio(ref Vector3d v1, ref Vector3d v2, ref Vector3d v3)
    Parameters
    Type Name Description
    Vector3d v1
    Vector3d v2
    Vector3d v3
    Returns
    Type Description
    Double

    Atan2Positive(Double, Double)

    Declaration
    public static double Atan2Positive(double y, double x)
    Parameters
    Type Name Description
    Double y
    Double x
    Returns
    Type Description
    Double

    BarycentricCoords(Vector2d, Vector2d, Vector2d, Vector2d)

    Compute barycentric coordinates/weights of vPoint inside triangle (V0,V1,V2). If point is inside triangle, coords will pe positive and sum to 1. ie if result is a, then vPoint = a.xV0 + a.yV1 + a.z*V2.

    Declaration
    public static Vector3d BarycentricCoords(Vector2d vPoint, Vector2d V0, Vector2d V1, Vector2d V2)
    Parameters
    Type Name Description
    Vector2d vPoint
    Vector2d V0
    Vector2d V1
    Vector2d V2
    Returns
    Type Description
    Vector3d

    BarycentricCoords(Vector3d, Vector3d, Vector3d, Vector3d)

    Declaration
    public static Vector3d BarycentricCoords(Vector3d vPoint, Vector3d V0, Vector3d V1, Vector3d V2)
    Parameters
    Type Name Description
    Vector3d vPoint
    Vector3d V0
    Vector3d V1
    Vector3d V2
    Returns
    Type Description
    Vector3d

    BarycentricCoords(ref Vector3d, ref Vector3d, ref Vector3d, ref Vector3d)

    Compute barycentric coordinates/weights of vPoint inside triangle (V0,V1,V2). If point is in triangle plane and inside triangle, coords will be positive and sum to 1. ie if result is a, then vPoint = a.xV0 + a.yV1 + a.z*V2.

    Declaration
    public static Vector3d BarycentricCoords(ref Vector3d vPoint, ref Vector3d V0, ref Vector3d V1, ref Vector3d V2)
    Parameters
    Type Name Description
    Vector3d vPoint
    Vector3d V0
    Vector3d V1
    Vector3d V2
    Returns
    Type Description
    Vector3d

    Clamp(Double, Double, Double)

    Declaration
    public static double Clamp(double f, double low, double high)
    Parameters
    Type Name Description
    Double f
    Double low
    Double high
    Returns
    Type Description
    Double

    Clamp(Int32, Int32, Int32)

    Declaration
    public static int Clamp(int f, int low, int high)
    Parameters
    Type Name Description
    Int32 f
    Int32 low
    Int32 high
    Returns
    Type Description
    Int32

    Clamp(Single, Single, Single)

    Declaration
    public static float Clamp(float f, float low, float high)
    Parameters
    Type Name Description
    Single f
    Single low
    Single high
    Returns
    Type Description
    Single

    Clamp<T>(T, T, T)

    Declaration
    public static T Clamp<T>(T f, T low, T high)
        where T : IComparable
    Parameters
    Type Name Description
    T f
    T low
    T high
    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T

    ClampAngleDeg(Double, Double, Double)

    Declaration
    public static double ClampAngleDeg(double theta, double min, double max)
    Parameters
    Type Name Description
    Double theta
    Double min
    Double max
    Returns
    Type Description
    Double

    ClampAngleRad(Double, Double, Double)

    Declaration
    public static double ClampAngleRad(double theta, double min, double max)
    Parameters
    Type Name Description
    Double theta
    Double min
    Double max
    Returns
    Type Description
    Double

    EpsilonEqual(Double, Double, Double)

    Declaration
    public static bool EpsilonEqual(double a, double b, double epsilon = 2.2204460492503131E-16)
    Parameters
    Type Name Description
    Double a
    Double b
    Double epsilon
    Returns
    Type Description
    Boolean

    EpsilonEqual(Single, Single, Single)

    Declaration
    public static bool EpsilonEqual(float a, float b, float epsilon = 1.1920929E-07F)
    Parameters
    Type Name Description
    Single a
    Single b
    Single epsilon
    Returns
    Type Description
    Boolean

    FastNormalArea(ref Vector3d, ref Vector3d, ref Vector3d, out Double)

    simultaneously compute triangle normal and area, and only normalize after cross-product, not before (so, fewer normalizes then Normal())

    Declaration
    public static Vector3d FastNormalArea(ref Vector3d v1, ref Vector3d v2, ref Vector3d v3, out double area)
    Parameters
    Type Name Description
    Vector3d v1
    Vector3d v2
    Vector3d v3
    Double area
    Returns
    Type Description
    Vector3d

    FastNormalDirection(ref Vector3d, ref Vector3d, ref Vector3d)

    compute vector in direction of triangle normal (cross-product). No normalization.

    Declaration
    public static Vector3d FastNormalDirection(ref Vector3d v1, ref Vector3d v2, ref Vector3d v3)
    Parameters
    Type Name Description
    Vector3d v1
    Vector3d v2
    Vector3d v3
    Returns
    Type Description
    Vector3d

    The normal direction.

    InRange(Double, Double, Double)

    Declaration
    public static bool InRange(double f, double low, double high)
    Parameters
    Type Name Description
    Double f
    Double low
    Double high
    Returns
    Type Description
    Boolean

    InRange(Int32, Int32, Int32)

    Declaration
    public static bool InRange(int f, int low, int high)
    Parameters
    Type Name Description
    Int32 f
    Int32 low
    Int32 high
    Returns
    Type Description
    Boolean

    InRange(Single, Single, Single)

    Declaration
    public static bool InRange(float f, float low, float high)
    Parameters
    Type Name Description
    Single f
    Single low
    Single high
    Returns
    Type Description
    Boolean

    InvSqrt(Double)

    Declaration
    public static double InvSqrt(double f)
    Parameters
    Type Name Description
    Double f
    Returns
    Type Description
    Double

    IsFinite(Double)

    Declaration
    public static bool IsFinite(double d)
    Parameters
    Type Name Description
    Double d
    Returns
    Type Description
    Boolean

    IsFinite(Single)

    Declaration
    public static bool IsFinite(float d)
    Parameters
    Type Name Description
    Single d
    Returns
    Type Description
    Boolean

    IsLeft(Vector2d, Vector2d, Vector2d)

    Declaration
    public static double IsLeft(Vector2d P0, Vector2d P1, Vector2d P2)
    Parameters
    Type Name Description
    Vector2d P0
    Vector2d P1
    Vector2d P2
    Returns
    Type Description
    Double

    IsLeft(ref Vector2d, ref Vector2d, ref Vector2d)

    Declaration
    public static double IsLeft(ref Vector2d P0, ref Vector2d P1, ref Vector2d P2)
    Parameters
    Type Name Description
    Vector2d P0
    Vector2d P1
    Vector2d P2
    Returns
    Type Description
    Double

    IsObtuse(Vector3d, Vector3d, Vector3d)

    Declaration
    public static bool IsObtuse(Vector3d v1, Vector3d v2, Vector3d v3)
    Parameters
    Type Name Description
    Vector3d v1
    Vector3d v2
    Vector3d v3
    Returns
    Type Description
    Boolean

    Lerp(Double, Double, Double)

    Declaration
    public static double Lerp(double a, double b, double t)
    Parameters
    Type Name Description
    Double a
    Double b
    Double t
    Returns
    Type Description
    Double

    Lerp(Single, Single, Single)

    Declaration
    public static float Lerp(float a, float b, float t)
    Parameters
    Type Name Description
    Single a
    Single b
    Single t
    Returns
    Type Description
    Single

    LinearRampT(Single, Single, Single)

    Declaration
    public static float LinearRampT(float R, float deadzoneR, float x)
    Parameters
    Type Name Description
    Single R
    Single deadzoneR
    Single x
    Returns
    Type Description
    Single

    Max(Double, Double, Double)

    Declaration
    public static double Max(double a, double b, double c)
    Parameters
    Type Name Description
    Double a
    Double b
    Double c
    Returns
    Type Description
    Double

    Max(Int32, Int32, Int32)

    Declaration
    public static int Max(int a, int b, int c)
    Parameters
    Type Name Description
    Int32 a
    Int32 b
    Int32 c
    Returns
    Type Description
    Int32

    Max(Single, Single, Single)

    Declaration
    public static float Max(float a, float b, float c)
    Parameters
    Type Name Description
    Single a
    Single b
    Single c
    Returns
    Type Description
    Single

    Min(Double, Double, Double)

    Declaration
    public static double Min(double a, double b, double c)
    Parameters
    Type Name Description
    Double a
    Double b
    Double c
    Returns
    Type Description
    Double

    Min(Int32, Int32, Int32)

    Declaration
    public static int Min(int a, int b, int c)
    Parameters
    Type Name Description
    Int32 a
    Int32 b
    Int32 c
    Returns
    Type Description
    Int32

    Min(Single, Single, Single)

    Declaration
    public static float Min(float a, float b, float c)
    Parameters
    Type Name Description
    Single a
    Single b
    Single c
    Returns
    Type Description
    Single

    MinMax(Double, Double, Double, out Double, out Double)

    Declaration
    public static void MinMax(double a, double b, double c, out double min, out double max)
    Parameters
    Type Name Description
    Double a
    Double b
    Double c
    Double min
    Double max

    ModuloClamp(Int32, Int32)

    Declaration
    public static int ModuloClamp(int f, int N)
    Parameters
    Type Name Description
    Int32 f
    Int32 N
    Returns
    Type Description
    Int32

    ModuloIteration(Int32, Int32)

    Iterate from 0 to (nMax-1) using prime-modulo, so we see every index once, but not in-order

    Declaration
    public static IEnumerable<int> ModuloIteration(int nMaxExclusive, int nPrime = 31337)
    Parameters
    Type Name Description
    Int32 nMaxExclusive
    Int32 nPrime
    Returns
    Type Description
    IEnumerable<Int32>

    MostParallelAxis(Frame3f, Vector3f)

    Declaration
    public static int MostParallelAxis(Frame3f f, Vector3f vDir)
    Parameters
    Type Name Description
    Frame3f f
    Vector3f vDir
    Returns
    Type Description
    Int32

    Normal(Vector3d, Vector3d, Vector3d)

    Declaration
    public static Vector3d Normal(Vector3d v1, Vector3d v2, Vector3d v3)
    Parameters
    Type Name Description
    Vector3d v1
    Vector3d v2
    Vector3d v3
    Returns
    Type Description
    Vector3d

    Normal(ref Vector3d, ref Vector3d, ref Vector3d)

    Declaration
    public static Vector3d Normal(ref Vector3d v1, ref Vector3d v2, ref Vector3d v3)
    Parameters
    Type Name Description
    Vector3d v1
    Vector3d v2
    Vector3d v3
    Returns
    Type Description
    Vector3d

    PlaneAngleD(Vector3d, Vector3d, Int32)

    Declaration
    public static double PlaneAngleD(Vector3d a, Vector3d b, int nPlaneNormalIdx = 1)
    Parameters
    Type Name Description
    Vector3d a
    Vector3d b
    Int32 nPlaneNormalIdx
    Returns
    Type Description
    Double

    PlaneAngleD(Vector3f, Vector3f, Int32)

    Declaration
    public static float PlaneAngleD(Vector3f a, Vector3f b, int nPlaneNormalIdx = 1)
    Parameters
    Type Name Description
    Vector3f a
    Vector3f b
    Int32 nPlaneNormalIdx
    Returns
    Type Description
    Single

    PlaneAngleSignedD(Vector2d, Vector2d)

    Declaration
    public static double PlaneAngleSignedD(Vector2d vFrom, Vector2d vTo)
    Parameters
    Type Name Description
    Vector2d vFrom
    Vector2d vTo
    Returns
    Type Description
    Double

    PlaneAngleSignedD(Vector2f, Vector2f)

    Declaration
    public static float PlaneAngleSignedD(Vector2f vFrom, Vector2f vTo)
    Parameters
    Type Name Description
    Vector2f vFrom
    Vector2f vTo
    Returns
    Type Description
    Single

    PlaneAngleSignedD(Vector3d, Vector3d, Vector3d)

    Declaration
    public static double PlaneAngleSignedD(Vector3d vFrom, Vector3d vTo, Vector3d planeN)
    Parameters
    Type Name Description
    Vector3d vFrom
    Vector3d vTo
    Vector3d planeN
    Returns
    Type Description
    Double

    PlaneAngleSignedD(Vector3d, Vector3d, Int32)

    Declaration
    public static double PlaneAngleSignedD(Vector3d vFrom, Vector3d vTo, int nPlaneNormalIdx = 1)
    Parameters
    Type Name Description
    Vector3d vFrom
    Vector3d vTo
    Int32 nPlaneNormalIdx
    Returns
    Type Description
    Double

    PlaneAngleSignedD(Vector3f, Vector3f, Vector3f)

    Declaration
    public static float PlaneAngleSignedD(Vector3f vFrom, Vector3f vTo, Vector3f planeN)
    Parameters
    Type Name Description
    Vector3f vFrom
    Vector3f vTo
    Vector3f planeN
    Returns
    Type Description
    Single

    PlaneAngleSignedD(Vector3f, Vector3f, Int32)

    Declaration
    public static float PlaneAngleSignedD(Vector3f vFrom, Vector3f vTo, int nPlaneNormalIdx = 1)
    Parameters
    Type Name Description
    Vector3f vFrom
    Vector3f vTo
    Int32 nPlaneNormalIdx
    Returns
    Type Description
    Single

    PowerOf10(Int32)

    Declaration
    public static int PowerOf10(int n)
    Parameters
    Type Name Description
    Int32 n
    Returns
    Type Description
    Int32

    RangeClamp(Double, Double)

    Declaration
    public static double RangeClamp(double fValue, double fMinMaxValue)
    Parameters
    Type Name Description
    Double fValue
    Double fMinMaxValue
    Returns
    Type Description
    Double

    RangeClamp(Single, Single)

    Declaration
    public static float RangeClamp(float fValue, float fMinMaxValue)
    Parameters
    Type Name Description
    Single fValue
    Single fMinMaxValue
    Returns
    Type Description
    Single

    SignedClamp(Double, Double)

    Declaration
    public static double SignedClamp(double f, double fMax)
    Parameters
    Type Name Description
    Double f
    Double fMax
    Returns
    Type Description
    Double

    SignedClamp(Double, Double, Double)

    Declaration
    public static double SignedClamp(double f, double fMin, double fMax)
    Parameters
    Type Name Description
    Double f
    Double fMin
    Double fMax
    Returns
    Type Description
    Double

    SignedClamp(Single, Single)

    Declaration
    public static float SignedClamp(float f, float fMax)
    Parameters
    Type Name Description
    Single f
    Single fMax
    Returns
    Type Description
    Single

    SignedClamp(Single, Single, Single)

    Declaration
    public static float SignedClamp(float f, float fMin, float fMax)
    Parameters
    Type Name Description
    Single f
    Single fMin
    Single fMax
    Returns
    Type Description
    Single

    SmoothInterp(Double, Double, Double)

    Declaration
    public static double SmoothInterp(double a, double b, double t)
    Parameters
    Type Name Description
    Double a
    Double b
    Double t
    Returns
    Type Description
    Double

    SmoothInterp(Single, Single, Single)

    Declaration
    public static float SmoothInterp(float a, float b, float t)
    Parameters
    Type Name Description
    Single a
    Single b
    Single t
    Returns
    Type Description
    Single

    SmoothRise0To1(Single, Single, Single, Single)

    Declaration
    public static float SmoothRise0To1(float fX, float yshift, float xZero, float speed)
    Parameters
    Type Name Description
    Single fX
    Single yshift
    Single xZero
    Single speed
    Returns
    Type Description
    Single

    SmoothStep(Double, Double, Double)

    Declaration
    public static double SmoothStep(double a, double b, double t)
    Parameters
    Type Name Description
    Double a
    Double b
    Double t
    Returns
    Type Description
    Double

    SmoothStep(Single, Single, Single)

    Declaration
    public static float SmoothStep(float a, float b, float t)
    Parameters
    Type Name Description
    Single a
    Single b
    Single t
    Returns
    Type Description
    Single

    SolveQuadratic(Double, Double, Double, out Double, out Double)

    Declaration
    public static bool SolveQuadratic(double a, double b, double c, out double minT, out double maxT)
    Parameters
    Type Name Description
    Double a
    Double b
    Double c
    Double minT
    Double maxT
    Returns
    Type Description
    Boolean

    TriSolidAngle(Vector3d, Vector3d, Vector3d, ref Vector3d)

    signed winding angle of oriented triangle [a,b,c] wrt point p formula from Jacobson et al 13 http://igl.ethz.ch/projects/winding-number/

    Declaration
    public static double TriSolidAngle(Vector3d a, Vector3d b, Vector3d c, ref Vector3d p)
    Parameters
    Type Name Description
    Vector3d a
    Vector3d b
    Vector3d c
    Vector3d p
    Returns
    Type Description
    Double

    VectorCot(Vector3d, Vector3d)

    Declaration
    public static double VectorCot(Vector3d v1, Vector3d v2)
    Parameters
    Type Name Description
    Vector3d v1
    Vector3d v2
    Returns
    Type Description
    Double

    VectorTan(Vector3d, Vector3d)

    Declaration
    public static double VectorTan(Vector3d v1, Vector3d v2)
    Parameters
    Type Name Description
    Vector3d v1
    Vector3d v2
    Returns
    Type Description
    Double

    WrapSignedIndex(Int32, Int32)

    Declaration
    public static int WrapSignedIndex(int val, int mod)
    Parameters
    Type Name Description
    Int32 val
    Int32 mod
    Returns
    Type Description
    Int32

    WyvillFalloff(Double, Double, Double)

    Declaration
    public static double WyvillFalloff(double fD, double fInnerRad, double fOuterRad)
    Parameters
    Type Name Description
    Double fD
    Double fInnerRad
    Double fOuterRad
    Returns
    Type Description
    Double

    WyvillFalloff(Single, Single, Single)

    Declaration
    public static float WyvillFalloff(float fD, float fInnerRad, float fOuterRad)
    Parameters
    Type Name Description
    Single fD
    Single fInnerRad
    Single fOuterRad
    Returns
    Type Description
    Single

    WyvillFalloff01(Double)

    Declaration
    public static double WyvillFalloff01(double fX)
    Parameters
    Type Name Description
    Double fX
    Returns
    Type Description
    Double

    WyvillFalloff01(Single)

    Declaration
    public static float WyvillFalloff01(float fX)
    Parameters
    Type Name Description
    Single fX
    Returns
    Type Description
    Single

    WyvillRise01(Double)

    Declaration
    public static double WyvillRise01(double fX)
    Parameters
    Type Name Description
    Double fX
    Returns
    Type Description
    Double

    WyvillRise01(Single)

    Declaration
    public static float WyvillRise01(float fX)
    Parameters
    Type Name Description
    Single fX
    Returns
    Type Description
    Single
    In This Article
    Back to top ViRGIS VR GIS