Mathg Class Reference

The class provide a few math functions and constants that Unity's Mathf class does not.

Static Public Member Functions

static bool AproxEquals (this float a, float b)
 compares two floating point numbers to 4 decimals of accuracy
 
static bool AproxEquals (this float a, float b, int accuracy)
 compares two floating point numbers to X decimals of accuracy, where X is specified by the accuracy parameter
 
static bool AreTrianglesFlush (Vector3 t1p0, Vector3 t1p1, Vector3 t1p2, Vector3 t2p0, Vector3 t2p1, Vector3 t2p2)
 compares the vertices of two triangles, if they have more than one matching vertex position, they are considered flush. Note: If the triangles share only PART of an edge, this function will return false.
 
static float Clip360 (float a)
 Converts any angle (degrees) to a value between zero and 360.
 
static bool MollerTrumboreTriangleIntersection (Vector3 V1, Vector3 V2, Vector3 V3, Vector3 O, Vector3 D, out float dist)
 open-source ray detection algorithm- converted to C#, and to use unity Vector3s Get the intersection between a ray and a triangle. If the line and plane of the triangle are parallel, return value is false.
 
static Vector3 NomralizePrecise (this Vector3 v)
 The standard unity function does not properly normalize small vectors, this function does.
 
static void SwapValues (ref float num1, ref float num2)
 Swaps the value in two referenced integers.
 
static void SwapValues (ref Vector2 num1, ref Vector2 num2)
 Swaps the value in two referenced Vector2's.
 
static void SwapValues (ref Vector3 num1, ref Vector3 num2)
 Swaps the value in two referenced Vector3's.
 

Properties

static float PI2 [get]
 read-only accessor for math constant, 2.0 * π
 
static float PIOver2 [get]
 read-only access for math constant: π / 2.0