Class Utility
Mathematical Utilities and Struct Extras
public static class Utility
Namespace Engine4.Internal
Inheritance
Fields
BoxVertices
List of tesseract vertices permutations
public static readonly Vector4[] BoxVertices
QuadToTris
Quad into Two triangles
public static readonly int[] QuadToTris
Methods
AngleLoop(Single)
Convert value range -pi to pi into 0 to 2pi
public static float AngleLoop(float v)
Atan2(Single, Single)
Atan2 with better handling of near 0, 0 singularity
public static float Atan2(float y, float x)
Atan2AvoidPi(Single, Single)
Atan2 with clear meaning that we don't want pi simply to avoid headache
public static float Atan2AvoidPi(float y, float x)
Clamp(Single, Single, Single)
Clamp T between A and B
public static float Clamp(float a, float b, float t)
Clamp01(Single)
Clamp T between 0 and 1
public static float Clamp01(float t)
Clear<T>(Stack<T>, T)
Clear and push a new item to the stack
public static void Clear<T>(this Stack<T> stack, T item)
CrossInterpolate(Vector4, Vector4)
Internally do Plane4.Intersect(), then Vector4.Lerp()
public static Vector4 CrossInterpolate(Vector4 x, Vector4 y)
CrossInterpolate(Vector4, Vector4, out Single)
Internally do Plane4.Intersect(), then Vector4.Lerp(), and make the phase out
public static Vector4 CrossInterpolate(Vector4 x, Vector4 y, out float phase)
Expand<T>(List<T>, Int32)
Expand list capacity to given capacity target
public static void Expand<T>(this List<T> list, int capacity)
Expand<T, T2>(List<T>, List<T2>)
Expand list capacity to what another list has
public static void Expand<T, T2>(this List<T> list, List<T2> capacity)
GetAverage(List<Vector3>)
Get average value
public static Vector3 GetAverage(this List<Vector3> v)
GetBounding(Vector4[], Int32)
Get bounding min-max
public static Bounds4 GetBounding(this Vector4[] v, int count)
GetValue<K, V>(Dictionary<K, V>, K, V)
Get a unique hash from the vector
public static V GetValue<K, V>(this Dictionary<K, V> dict, K key, V fallback)
GiveSign(Vector4, Int32, Int32)
Give sign to any nonzero vector elements
public static Vector4 GiveSign(Vector4 v, int x, int y)
GiveSign(Vector4, Int32, Int32, Int32)
Give sign to any nonzero vector elements
public static Vector4 GiveSign(Vector4 v, int x, int y, int z)
GiveSign(Vector4, Int32, Int32, Int32, Int32)
Give sign to any nonzero vector elements
public static Vector4 GiveSign(Vector4 v, int x, int y, int z, int w)
Hue()
Get Hue variation in gradient
public static Gradient Hue()
Hue(Single)
Get Hue variation
public static Color Hue(float h)
Invert(Single)
Inverse function (x => 1 / x)
public static float Invert(float i)
Random()
Next random integer
public static int Random()
RemoveFast<T>(List<T>, T)
Quickly remove an item if list order doesn't matter.
public static void RemoveFast<T>(this List<T> list, T item)
SetW(Vector3, Single)
Sets the w and return Vector4
public static Vector4 SetW(this Vector3 xyz, float w)
Sign(Single)
Sign function (x => x / Abs(x))
public static float Sign(float v)
Remarks
This function will never return zero compared with .NET Math
Swap<T>(ref T, ref T)
Swap two object
public static void Swap<T>(ref T l, ref T r)
Tidy(Euler4)
Remove unnecessary trailing digits for debugging ease.
public static Euler4 Tidy(Euler4 v)
Tidy(Matrix4)
Remove unnecessary trailing digits for debugging ease.
public static Matrix4 Tidy(Matrix4 v)
Tidy(Vector4)
Remove unnecessary trailing digits for debugging ease.
public static Vector4 Tidy(Vector4 v)
Tidy(Single)
Remove unnecessary trailing digits for debugging ease.
public static float Tidy(float v)
VectorToKey(Vector4)
Get a unique hash from the vector
public static int VectorToKey(Vector4 v)
VectorToKey(Vector3)
Get a unique hash from the vector
public static int VectorToKey(Vector3 v)