Class MathUtil
Namespace: g3
Assembly: cs.temp.dll.dll
Syntax
public static class MathUtil
Fields
Deg2Rad
Declaration
public const double Deg2Rad = 0.017453292519943295
Field Value
Deg2Radf
Declaration
public const float Deg2Radf = 0.0174532924F
Field Value
Epsilon
Declaration
public const double Epsilon = 2.2204460492503131E-16
Field Value
Epsilonf
Declaration
public const float Epsilonf = 1.1920929E-07F
Field Value
FourPI
Declaration
public const double FourPI = 12.566370614359172
Field Value
HalfPI
Declaration
public const double HalfPI = 1.5707963267948966
Field Value
HalfPIf
Declaration
public const float HalfPIf = 1.57079637F
Field Value
PIf
Declaration
public const float PIf = 3.14159274F
Field Value
Rad2Deg
Declaration
public const double Rad2Deg = 57.295779513082323
Field Value
Rad2Degf
Declaration
public const float Rad2Degf = 57.29578F
Field Value
SqrtThree
Declaration
public const double SqrtThree = 1.7320508075688772
Field Value
SqrtTwo
Declaration
public const double SqrtTwo = 1.4142135623730951
Field Value
SqrtTwof
Declaration
public const float SqrtTwof = 1.41421354F
Field Value
SqrtTwoInv
Declaration
public const double SqrtTwoInv = 0.70710678118654746
Field Value
TwoPI
Declaration
public const double TwoPI = 6.2831853071795862
Field Value
TwoPIf
Declaration
public const float TwoPIf = 6.28318548F
Field Value
ZeroTolerance
Declaration
public const double ZeroTolerance = 1E-08
Field Value
ZeroTolerancef
Declaration
public const float ZeroTolerancef = 1E-06F
Field Value
Methods
Area(Vector3d, Vector3d, Vector3d)
Declaration
public static double Area(Vector3d v1, Vector3d v2, Vector3d v3)
Parameters
Returns
Area(ref Vector3d, ref Vector3d, ref Vector3d)
Declaration
public static double Area(ref Vector3d v1, ref Vector3d v2, ref Vector3d v3)
Parameters
Returns
AspectRatio(Vector3d, Vector3d, Vector3d)
Declaration
public static double AspectRatio(Vector3d v1, Vector3d v2, Vector3d v3)
Parameters
Returns
AspectRatio(ref Vector3d, ref Vector3d, ref Vector3d)
Declaration
public static double AspectRatio(ref Vector3d v1, ref Vector3d v2, ref Vector3d v3)
Parameters
Returns
Atan2Positive(Double, Double)
Declaration
public static double Atan2Positive(double y, double x)
Parameters
Returns
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
Returns
BarycentricCoords(Vector3d, Vector3d, Vector3d, Vector3d)
Declaration
public static Vector3d BarycentricCoords(Vector3d vPoint, Vector3d V0, Vector3d V1, Vector3d V2)
Parameters
Returns
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
Returns
Clamp(Double, Double, Double)
Declaration
public static double Clamp(double f, double low, double high)
Parameters
Returns
Clamp(Int32, Int32, Int32)
Declaration
public static int Clamp(int f, int low, int high)
Parameters
Returns
Clamp(Single, Single, Single)
Declaration
public static float Clamp(float f, float low, float high)
Parameters
Returns
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 Parameters
ClampAngleDeg(Double, Double, Double)
Declaration
public static double ClampAngleDeg(double theta, double min, double max)
Parameters
Returns
ClampAngleRad(Double, Double, Double)
Declaration
public static double ClampAngleRad(double theta, double min, double max)
Parameters
Returns
EpsilonEqual(Double, Double, Double)
Declaration
public static bool EpsilonEqual(double a, double b, double epsilon = 2.2204460492503131E-16)
Parameters
Returns
EpsilonEqual(Single, Single, Single)
Declaration
public static bool EpsilonEqual(float a, float b, float epsilon = 1.1920929E-07F)
Parameters
Returns
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
Returns
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
Returns
Type |
Description |
Vector3d |
The normal direction.
|
InRange(Double, Double, Double)
Declaration
public static bool InRange(double f, double low, double high)
Parameters
Returns
InRange(Int32, Int32, Int32)
Declaration
public static bool InRange(int f, int low, int high)
Parameters
Returns
InRange(Single, Single, Single)
Declaration
public static bool InRange(float f, float low, float high)
Parameters
Returns
InvSqrt(Double)
Declaration
public static double InvSqrt(double f)
Parameters
Type |
Name |
Description |
Double |
f |
|
Returns
IsFinite(Double)
Declaration
public static bool IsFinite(double d)
Parameters
Type |
Name |
Description |
Double |
d |
|
Returns
IsFinite(Single)
Declaration
public static bool IsFinite(float d)
Parameters
Type |
Name |
Description |
Single |
d |
|
Returns
IsLeft(Vector2d, Vector2d, Vector2d)
Declaration
public static double IsLeft(Vector2d P0, Vector2d P1, Vector2d P2)
Parameters
Returns
IsLeft(ref Vector2d, ref Vector2d, ref Vector2d)
Declaration
public static double IsLeft(ref Vector2d P0, ref Vector2d P1, ref Vector2d P2)
Parameters
Returns
IsObtuse(Vector3d, Vector3d, Vector3d)
Declaration
public static bool IsObtuse(Vector3d v1, Vector3d v2, Vector3d v3)
Parameters
Returns
Lerp(Double, Double, Double)
Declaration
public static double Lerp(double a, double b, double t)
Parameters
Returns
Lerp(Single, Single, Single)
Declaration
public static float Lerp(float a, float b, float t)
Parameters
Returns
LinearRampT(Single, Single, Single)
Declaration
public static float LinearRampT(float R, float deadzoneR, float x)
Parameters
Returns
Max(Double, Double, Double)
Declaration
public static double Max(double a, double b, double c)
Parameters
Returns
Max(Int32, Int32, Int32)
Declaration
public static int Max(int a, int b, int c)
Parameters
Returns
Max(Single, Single, Single)
Declaration
public static float Max(float a, float b, float c)
Parameters
Returns
Min(Double, Double, Double)
Declaration
public static double Min(double a, double b, double c)
Parameters
Returns
Min(Int32, Int32, Int32)
Declaration
public static int Min(int a, int b, int c)
Parameters
Returns
Min(Single, Single, Single)
Declaration
public static float Min(float a, float b, float c)
Parameters
Returns
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
ModuloClamp(Int32, Int32)
Declaration
public static int ModuloClamp(int f, int N)
Parameters
Returns
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
MostParallelAxis(Frame3f, Vector3f)
Declaration
public static int MostParallelAxis(Frame3f f, Vector3f vDir)
Parameters
Returns
Normal(Vector3d, Vector3d, Vector3d)
Declaration
public static Vector3d Normal(Vector3d v1, Vector3d v2, Vector3d v3)
Parameters
Returns
Normal(ref Vector3d, ref Vector3d, ref Vector3d)
Declaration
public static Vector3d Normal(ref Vector3d v1, ref Vector3d v2, ref Vector3d v3)
Parameters
Returns
PlaneAngleD(Vector3d, Vector3d, Int32)
Declaration
public static double PlaneAngleD(Vector3d a, Vector3d b, int nPlaneNormalIdx = 1)
Parameters
Returns
PlaneAngleD(Vector3f, Vector3f, Int32)
Declaration
public static float PlaneAngleD(Vector3f a, Vector3f b, int nPlaneNormalIdx = 1)
Parameters
Returns
PlaneAngleSignedD(Vector2d, Vector2d)
Declaration
public static double PlaneAngleSignedD(Vector2d vFrom, Vector2d vTo)
Parameters
Returns
PlaneAngleSignedD(Vector2f, Vector2f)
Declaration
public static float PlaneAngleSignedD(Vector2f vFrom, Vector2f vTo)
Parameters
Returns
PlaneAngleSignedD(Vector3d, Vector3d, Vector3d)
Declaration
public static double PlaneAngleSignedD(Vector3d vFrom, Vector3d vTo, Vector3d planeN)
Parameters
Returns
PlaneAngleSignedD(Vector3d, Vector3d, Int32)
Declaration
public static double PlaneAngleSignedD(Vector3d vFrom, Vector3d vTo, int nPlaneNormalIdx = 1)
Parameters
Returns
PlaneAngleSignedD(Vector3f, Vector3f, Vector3f)
Declaration
public static float PlaneAngleSignedD(Vector3f vFrom, Vector3f vTo, Vector3f planeN)
Parameters
Returns
PlaneAngleSignedD(Vector3f, Vector3f, Int32)
Declaration
public static float PlaneAngleSignedD(Vector3f vFrom, Vector3f vTo, int nPlaneNormalIdx = 1)
Parameters
Returns
PowerOf10(Int32)
Declaration
public static int PowerOf10(int n)
Parameters
Type |
Name |
Description |
Int32 |
n |
|
Returns
RangeClamp(Double, Double)
Declaration
public static double RangeClamp(double fValue, double fMinMaxValue)
Parameters
Returns
RangeClamp(Single, Single)
Declaration
public static float RangeClamp(float fValue, float fMinMaxValue)
Parameters
Returns
SignedClamp(Double, Double)
Declaration
public static double SignedClamp(double f, double fMax)
Parameters
Returns
SignedClamp(Double, Double, Double)
Declaration
public static double SignedClamp(double f, double fMin, double fMax)
Parameters
Returns
SignedClamp(Single, Single)
Declaration
public static float SignedClamp(float f, float fMax)
Parameters
Returns
SignedClamp(Single, Single, Single)
Declaration
public static float SignedClamp(float f, float fMin, float fMax)
Parameters
Returns
SmoothInterp(Double, Double, Double)
Declaration
public static double SmoothInterp(double a, double b, double t)
Parameters
Returns
SmoothInterp(Single, Single, Single)
Declaration
public static float SmoothInterp(float a, float b, float t)
Parameters
Returns
SmoothRise0To1(Single, Single, Single, Single)
Declaration
public static float SmoothRise0To1(float fX, float yshift, float xZero, float speed)
Parameters
Returns
SmoothStep(Double, Double, Double)
Declaration
public static double SmoothStep(double a, double b, double t)
Parameters
Returns
SmoothStep(Single, Single, Single)
Declaration
public static float SmoothStep(float a, float b, float t)
Parameters
Returns
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
Returns
TriSolidAngle(Vector3d, Vector3d, Vector3d, ref Vector3d)
Declaration
public static double TriSolidAngle(Vector3d a, Vector3d b, Vector3d c, ref Vector3d p)
Parameters
Returns
VectorCot(Vector3d, Vector3d)
Declaration
public static double VectorCot(Vector3d v1, Vector3d v2)
Parameters
Returns
VectorTan(Vector3d, Vector3d)
Declaration
public static double VectorTan(Vector3d v1, Vector3d v2)
Parameters
Returns
WrapSignedIndex(Int32, Int32)
Declaration
public static int WrapSignedIndex(int val, int mod)
Parameters
Returns
WyvillFalloff(Double, Double, Double)
Declaration
public static double WyvillFalloff(double fD, double fInnerRad, double fOuterRad)
Parameters
Returns
WyvillFalloff(Single, Single, Single)
Declaration
public static float WyvillFalloff(float fD, float fInnerRad, float fOuterRad)
Parameters
Returns
WyvillFalloff01(Double)
Declaration
public static double WyvillFalloff01(double fX)
Parameters
Type |
Name |
Description |
Double |
fX |
|
Returns
WyvillFalloff01(Single)
Declaration
public static float WyvillFalloff01(float fX)
Parameters
Type |
Name |
Description |
Single |
fX |
|
Returns
WyvillRise01(Double)
Declaration
public static double WyvillRise01(double fX)
Parameters
Type |
Name |
Description |
Double |
fX |
|
Returns
WyvillRise01(Single)
Declaration
public static float WyvillRise01(float fX)
Parameters
Type |
Name |
Description |
Single |
fX |
|
Returns