SUNENGINE 0.0.2
A simple and bright C++ game engine.
 
Loading...
Searching...
No Matches
SUNENGINEMathTools Class Reference

Provides mathematical tools for collision detection and vector operations. More...

#include <SUNENGINEMathTools.h>

Static Public Member Functions

static const bool Intersect (const CollisionVolume &vol1, const CollisionVolume &vol2)
 Checks for collision between two generic collision volumes.
 
static const bool BSphereToBSphereCollision (const CollisionVolumeBSphere &sphere1, const CollisionVolumeBSphere &sphere2)
 Checks for collision between two bounding spheres.
 
static const bool AABBToAABBCollision (const CollisionVolumeAABB &aabb1, const CollisionVolumeAABB &aabb2)
 Checks for collision between a bounding sphere and an axis-aligned bounding box (AABB).
 
static const bool AABBToBSphereCollision (const CollisionVolumeAABB &aabb, const CollisionVolumeBSphere &sphere)
 Checks for collision between an AABB and a bounding sphere.
 
static const bool OBBToOBBCollision (const CollisionVolumeOBB &obb1, const CollisionVolumeOBB &obb2)
 Checks for collision between two oriented bounding boxes (OBB).
 
static const bool OBBToBSphereCollision (const CollisionVolumeOBB &obb, const CollisionVolumeBSphere &sphere)
 Checks for collision between an OBB and a bounding sphere.
 
static const bool OBBToAABBCollision (const CollisionVolumeOBB &obb, const CollisionVolumeAABB &aabb)
 Checks for collision between an OBB and an AABB.
 
static const Vect Project (const Vect &v, const Vect &onto)
 Projects a vector onto another vector.
 
static float ComputeOBBProjection (const CollisionVolumeOBB &obb, const Vect &axis)
 Computes the projection of an OBB onto a given axis.
 
static Vect ClampPointToAABB (const Vect &point, const Vect &min, const Vect &max)
 Clamps a point to the bounds of an AABB.
 
static bool IsAxisSeparated (const Vect &axis, const Vect &centerDiff, const CollisionVolumeOBB &obb1, const CollisionVolumeOBB &obb2)
 Checks if two OBBs are separated along a given axis.
 
static void ComputeOBBWorldData (const Vect &minM, const Vect &maxM, const Matrix &mat, Vect &outCenter, Vect &outHalfDiagonal, Matrix &outWorldMatrix)
 Computes the world-space center, half-diagonal, and world matrix for an OBB.
 
static void EncloseAABBs (const Vect &min1, const Vect &max1, const Vect &min2, const Vect &max2, Vect &outMin, Vect &outMax)
 Computes the local-space center and half-diagonal for an OBB.
 
static bool IsPointInTriangle (const Vect &p, const Vect &a, const Vect &b, const Vect &c)
 
static Vect GetHeightAndNormal (const Vect &p, const Vect &a, const Vect &b, const Vect &c, Vect &normal)
 

Detailed Description

Provides mathematical tools for collision detection and vector operations.

The SUNENGINEMathTools class provides static utility methods for collision detection between various collision volumes (bounding spheres, AABBs, OBBs) and for performing vector operations such as projection and clamping. These methods are used throughout the engine for physics, collision, and spatial queries.

Example usage:

bool collides = SUNENGINEMathTools::AABBToAABBCollision(aabb1, aabb2);
Vect projected = SUNENGINEMathTools::Project(v, onto);
static const bool AABBToAABBCollision(const CollisionVolumeAABB &aabb1, const CollisionVolumeAABB &aabb2)
Checks for collision between a bounding sphere and an axis-aligned bounding box (AABB).
Definition SUNENGINEMathTools.cpp:24
static const Vect Project(const Vect &v, const Vect &onto)
Projects a vector onto another vector.
Definition SUNENGINEMathTools.cpp:174
See also
CollisionVolume, CollisionVolumeBSphere, CollisionVolumeAABB, CollisionVolumeOBB, Vect

Member Function Documentation

◆ AABBToAABBCollision()

const bool SUNENGINEMathTools::AABBToAABBCollision ( const CollisionVolumeAABB & aabb1,
const CollisionVolumeAABB & aabb2 )
static

Checks for collision between a bounding sphere and an axis-aligned bounding box (AABB).

Parameters
sphereThe bounding sphere.
aabbThe axis-aligned bounding box.
Returns
True if the sphere and AABB collide, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AABBToBSphereCollision()

const bool SUNENGINEMathTools::AABBToBSphereCollision ( const CollisionVolumeAABB & aabb,
const CollisionVolumeBSphere & sphere )
static

Checks for collision between an AABB and a bounding sphere.

Parameters
aabbThe axis-aligned bounding box.
sphereThe bounding sphere.
Returns
True if the AABB and sphere collide, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BSphereToBSphereCollision()

const bool SUNENGINEMathTools::BSphereToBSphereCollision ( const CollisionVolumeBSphere & sphere1,
const CollisionVolumeBSphere & sphere2 )
static

Checks for collision between two bounding spheres.

Parameters
sphere1The first bounding sphere.
sphere2The second bounding sphere.
Returns
True if the spheres collide, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClampPointToAABB()

Vect SUNENGINEMathTools::ClampPointToAABB ( const Vect & point,
const Vect & min,
const Vect & max )
static

Clamps a point to the bounds of an AABB.

Parameters
pointThe point to clamp.
minThe minimum corner of the AABB.
maxThe maximum corner of the AABB.
Returns
The clamped point.
Here is the caller graph for this function:

◆ ComputeOBBProjection()

float SUNENGINEMathTools::ComputeOBBProjection ( const CollisionVolumeOBB & obb,
const Vect & axis )
static

Computes the projection of an OBB onto a given axis.

Parameters
obbThe oriented bounding box.
axisThe axis to project onto.
Returns
The scalar projection length.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ComputeOBBWorldData()

void SUNENGINEMathTools::ComputeOBBWorldData ( const Vect & minM,
const Vect & maxM,
const Matrix & mat,
Vect & outCenter,
Vect & outHalfDiagonal,
Matrix & outWorldMatrix )
static

Computes the world-space center, half-diagonal, and world matrix for an OBB.

Parameters
minMThe minimum point of the model's AABB in model space.
maxMThe maximum point of the model's AABB in model space.
matThe world transformation matrix.
outCenterOutput: OBB center in world space.
outHalfDiagonalOutput: OBB half-diagonal in world space.
outWorldMatrixOutput: OBB world matrix (orientation + translation).
Here is the caller graph for this function:

◆ EncloseAABBs()

void SUNENGINEMathTools::EncloseAABBs ( const Vect & min1,
const Vect & max1,
const Vect & min2,
const Vect & max2,
Vect & outMin,
Vect & outMax )
static

Computes the local-space center and half-diagonal for an OBB.

Parameters
minMThe minimum point of the model's AABB in model space.
maxMThe maximum point of the model's AABB in model space.
outCenterOutput: OBB center in local space.
outHalfDiagonalOutput: OBB half-diagonal in local space.
Here is the caller graph for this function:

◆ Intersect()

const bool SUNENGINEMathTools::Intersect ( const CollisionVolume & vol1,
const CollisionVolume & vol2 )
static

Checks for collision between two generic collision volumes.

Parameters
vol1The first collision volume.
vol2The second collision volume.
Returns
True if the volumes collide, false otherwise.
Here is the caller graph for this function:

◆ IsAxisSeparated()

bool SUNENGINEMathTools::IsAxisSeparated ( const Vect & axis,
const Vect & centerDiff,
const CollisionVolumeOBB & obb1,
const CollisionVolumeOBB & obb2 )
static

Checks if two OBBs are separated along a given axis.

Parameters
axisThe axis to test.
centerDiffThe vector between the centers of the OBBs.
obb1The first OBB.
obb2The second OBB.
Returns
True if the OBBs are separated along the axis, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OBBToAABBCollision()

const bool SUNENGINEMathTools::OBBToAABBCollision ( const CollisionVolumeOBB & obb,
const CollisionVolumeAABB & aabb )
static

Checks for collision between an OBB and an AABB.

Parameters
obbThe oriented bounding box.
aabbThe axis-aligned bounding box.
Returns
True if the OBB and AABB collide, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OBBToBSphereCollision()

const bool SUNENGINEMathTools::OBBToBSphereCollision ( const CollisionVolumeOBB & obb,
const CollisionVolumeBSphere & sphere )
static

Checks for collision between an OBB and a bounding sphere.

Parameters
obbThe oriented bounding box.
sphereThe bounding sphere.
Returns
True if the OBB and sphere collide, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OBBToOBBCollision()

const bool SUNENGINEMathTools::OBBToOBBCollision ( const CollisionVolumeOBB & obb1,
const CollisionVolumeOBB & obb2 )
static

Checks for collision between two oriented bounding boxes (OBB).

Parameters
obb1The first OBB.
obb2The second OBB.
Returns
True if the OBBs collide, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Project()

const Vect SUNENGINEMathTools::Project ( const Vect & v,
const Vect & onto )
static

Projects a vector onto another vector.

Parameters
vThe vector to be projected.
ontoThe vector onto which v is projected.
Returns
The projection of v onto onto.

The documentation for this class was generated from the following files: