Static math function class. More...
#include <IonMathTools.h>
Detailed Description
Static math function class.
IonMathTools is filled with static functions for comonly used math operations.
Static Public Member Functions | |
static bool | Intersect (const Collidable *colA, const Collidable *colB) |
Function for Intersection dynamic dispatch. More... | |
static bool | Intersect (const CollisionVolumeBSphere &colA, const CollisionVolumeBSphere &colB) |
Function for Intersection of BSphere on BSphere. More... | |
static bool | Intersect (const CollisionVolumeAABB &colA, const CollisionVolumeAABB &colB) |
Function for Intersection of AABB on AABB. More... | |
static bool | Intersect (const CollisionVolumeOBB &colA, const CollisionVolumeOBB &colB) |
Function for Intersection of OBB on OBB. More... | |
static bool | Intersect (const CollisionVolumeAABB &colA, const CollisionVolumeOBB &colB) |
Function for Intersection of AABB on OBB. More... | |
static bool | Intersect (const CollisionVolumeBSphere &colA, const CollisionVolumeAABB &colB) |
Function for Intersection of BSphere on AABB. More... | |
static bool | Intersect (const CollisionVolumeOBB &colA, const CollisionVolumeBSphere &colB) |
Function for Intersection of OBB on BSphere. More... | |
static float | Projection (const Vect &v, const Vect &w) |
Function that projects one Vect onto another Vect. More... | |
static Vect | GetMatrixScale (const Matrix &m) |
Function that returns the scalar of a Matrix as a Vect. More... | |
static Vect | SqrVect (const Vect &v) |
Function that returns a squared Vect. More... | |
static Vect | GetMinVect (const Vect *v, int length) |
Function that returns the min Vect within a Vect array. More... | |
static Vect | GetMaxVect (const Vect *v, int length) |
Function that returns the max Vect within a Vect array. More... | |
static void | GetMinMaxVect (const Vect *v, int length, Vect &min_vect, Vect &max_vect, const Matrix &mat=Matrix(IDENTITY)) |
Function that returns the min and max Vects within a Vect array. More... | |
static float | fClamp (float f, float min, float max) |
Function that returns a clamped float. More... | |
static Vect | vClamp (const Vect &v, const Vect &min, const Vect &max) |
Function that returns a clamped Vect. More... | |
static float | vDistance (const Vect &vA, const Vect &vB) |
Function that calculates the distance formula on two Vects. More... | |
static float | TriangleArea (const Vect &v1, const Vect &v2, const Vect &v3) |
Function that calculates the area of a triangle from three given points. More... | |
static bool | InsideSphere (const Vect &v, const Vect ¢er, float radius) |
Function that checks if a 3D point is inside a sphere. More... | |
static bool | InsideTriangle (const Vect &T_v1, const Vect &T_v2, const Vect &T_v3, const Vect &pos) |
Function that checks if a 3D point is inside a triangle from three given points. More... | |
static int | LineIntersectTriangle (const Vect &p1, const Vect &p2, const Vect &T_v1, const Vect &T_v2, const Vect &T_v3, Vect &out_pos) |
Function that checks if a line is intersects with a triangle from three given points. More... | |
static bool | ComputeIntervalOverlap (float f1_min, float f1_max, float f2_min, float f2_max) |
Function that checks if two intervals overlap. More... | |
Member Function Documentation
|
static |
Function that checks if two intervals overlap.
- Parameters
-
f1_min first min float f1_max first max float f2_min second min float f2_max second max float
- Returns
- True or false if the intervals overlap
|
static |
Function that returns a clamped float.
This function clamps a float f between the min and max float params
- Parameters
-
f Float to clamp min Min float value max Max float value
- Returns
- Float value that has been clamped
|
static |
Function that returns the scalar of a Matrix as a Vect.
- Parameters
-
m Matrix to get scale from
- Returns
- A scalar Vect
|
static |
Function that returns the max Vect within a Vect array.
- Parameters
-
v pointer to Vect array length int length of Vect array
- Returns
- The maximum Vect from the array
|
static |
Function that returns the min and max Vects within a Vect array.
This function takes in two vect references (min_vect and max_vect) for outputing the min and max Vect values within a Vect array v. The function also will optionally transform the Vects by a world matrix with param mat. If left blank, no vects will be transformed as mat defaults to the Identity matrix.
- Parameters
-
v pointer to Vect array length int length of Vect array min_vect Output Vect reference for min max_vect Output Vect reference for max mat Optional matrix for Vect transformations
|
static |
Function that returns the min Vect within a Vect array.
- Parameters
-
v pointer to Vect array length int length of Vect array
- Returns
- The minimum Vect from the array
|
static |
Function that checks if a 3D point is inside a sphere.
- Parameters
-
v Vect point to test center Vect center of sphere radius float radius of sphere
- Returns
- True or false if the point is in the sphere.
|
static |
Function that checks if a 3D point is inside a triangle from three given points.
- Parameters
-
T_v1 Triangle point one T_v2 Triangle point two T_v3 Triangle point three pos Vect point to test
- Returns
- True or false if the point is in the triangle.
|
static |
Function for Intersection dynamic dispatch.
This intersect function takes in two Collidable pointers and calls the intersect function of colA on colB.
- Parameters
-
colA first Collidable pointer colB second Collidable pointer
- Returns
- bool if the CollisionVolumes intersect
|
static |
Function for Intersection of BSphere on BSphere.
This function calculates if the two CollisionVolumeBSphere refrences colA and colB are intersecting.
- Parameters
-
colA first CollisionVolumeBSphere ref colB second CollisionVolumeBSphere ref
- Returns
- bool if the CollisionVolumes intersect
|
static |
Function for Intersection of AABB on AABB.
This function calculates if the two CollisionVolumeAABB refrences colA and colB are intersecting.
- Parameters
-
colA first CollisionVolumeAABB ref colB second CollisionVolumeAABB ref
- Returns
- bool if the CollisionVolumes intersect
|
static |
Function for Intersection of OBB on OBB.
This function calculates if the two CollisionVolumeOBB refrences colA and colB are intersecting.
- Parameters
-
colA first CollisionVolumeOBB ref colB second CollisionVolumeOBB ref
- Returns
- bool if the CollisionVolumes intersect
|
static |
Function for Intersection of AABB on OBB.
This function calculates if the CollisionVolumeAABB and CollisionVolumeOBB refrences (colA and colB) are intersecting.
- Parameters
-
colA CollisionVolumeAABB ref colB CollisionVolumeOBB ref
- Returns
- bool if the CollisionVolumes intersect
|
static |
Function for Intersection of BSphere on AABB.
This function calculates if the CollisionVolumeBSphere and CollisionVolumeAABB refrences (colA and colB) are intersecting.
- Parameters
-
colA CollisionVolumeBSphere ref colB CollisionVolumeAABB ref
- Returns
- bool if the CollisionVolumes intersect
|
static |
Function for Intersection of OBB on BSphere.
This function calculates if the CollisionVolumeOBB and CollisionVolumeBSphere refrences (colA and colB) are intersecting.
- Parameters
-
colA CollisionVolumeOBB ref colB CollisionVolumeBSphere ref
- Returns
- bool if the CollisionVolumes intersect
|
static |
Function that checks if a line is intersects with a triangle from three given points.
This function tests for a line intersection point with a triangle. The function returns an int based on what is calculated: return -1: Triangle is degenerate return 0: Line is disjoint from triangle plane return 1: Line intersects with triangle plane return 2: Line lies in triangle triangle plane The function only ever modifies the out_pos Vect ref if it returns 1
- Parameters
-
p1 Line point 1 p2 Line point 2 T_v1 Triangle point one T_v2 Triangle point two T_v3 Triangle point three out_pos Output Vect ref for point of intersection
- Returns
- int based on how successful the test was
|
static |
Function that projects one Vect onto another Vect.
This function calculates the projection of v onto w as follows: |v dot w| / ||w||
- Parameters
-
v first Vect to project w second Vect to project
- Returns
- A float of the projected length
|
static |
Function that returns a squared Vect.
- Parameters
-
v Vect to square
- Returns
- A new squared Vect
|
static |
Function that calculates the area of a triangle from three given points.
- Parameters
-
v1 Triangle point one v2 Triangle point two v3 Triangle point three
- Returns
- float area of the triangle.
|
static |
Function that returns a clamped Vect.
This function clamps a Vect f between the min and max Vect params
- Parameters
-
v Vect to clamp min Min vect value max Max vect value
- Returns
- Vect value that has been clamped
|
static |
Function that calculates the distance formula on two Vects.
- Parameters
-
vA Vect position one vB Vect position two
- Returns
- Distance of the two points as a float.