Provides functions for geometry related operations.
More...
|
template<typename VectorType > |
VectorType | Geometry::GJKGetAveragePoint (const GS::Array< VectorType > &vertices) |
|
template<typename VectorType > |
VectorType | Geometry::GJKGetFurthestPoint (const GS::Array< VectorType > &vertices, const VectorType &d) |
|
template<typename VectorType > |
VectorType | Geometry::GJKGetSupport (const GS::Array< VectorType > &vertices1, const GS::Array< VectorType > &vertices2, const VectorType &d) |
|
template<typename Coordinate > |
bool | Geometry::GJKDoSimplex (GS::Array< Vector2< Coordinate > > &simplex, Vector2< Coordinate > &direction) |
|
template<typename Coordinate > |
bool | Geometry::GJKDoSimplex (GS::Array< Vector3< Coordinate > > &simplex, Vector3< Coordinate > &direction) |
|
template<typename SupportFunction , typename VectorType > |
GJKResult< VectorType > | Geometry::GJKCollisionDetection (SupportFunction supportFunction, VectorType direction) |
|
template<typename VectorType > |
GJKResult< VectorType > | Geometry::GJKCollisionDetection (const GS::Array< VectorType > &vertices1, const GS::Array< VectorType > &vertices2) |
|
Provides functions for geometry related operations.
◆ GJKCollisionDetection() [1/2]
template<typename VectorType >
GJKResult< VectorType > Geometry::GJKCollisionDetection |
( |
const GS::Array< VectorType > & |
vertices1, |
|
|
const GS::Array< VectorType > & |
vertices2 |
|
) |
| |
Specific implementation of the specialized GJK algorithm for two shapes defined by vertices.
- Parameters
-
vertices1 | The array of vertices of the first shape. |
vertices2 | The array of vertices of the second shape. |
- Returns
true
if the zero point is included in the Minkowski difference, i.e. collision is detected, false
otherwise.
◆ GJKCollisionDetection() [2/2]
template<typename SupportFunction , typename VectorType >
GJKResult< VectorType > Geometry::GJKCollisionDetection |
( |
SupportFunction |
supportFunction, |
|
|
VectorType |
direction |
|
) |
| |
Generic implementation of the specialized GJK algorithm for collision detection.
- Parameters
-
supportFunction | The support function callback to get the Minkowski difference point for a specific direction. |
direction | The initial direction for algorithm startup. |
- Returns
true
if the zero point is included in the Minkowski difference, i.e. collision is detected, false
otherwise.
◆ GJKDoSimplex() [1/2]
template<typename Coordinate >
bool Geometry::GJKDoSimplex |
( |
GS::Array< Vector2< Coordinate > > & |
simplex, |
|
|
Vector2< Coordinate > & |
direction |
|
) |
| |
Zero-point check for the current simplex in the Minkowski space.
Specific implementation for the 2D case.
- Parameters
-
simplex | The current simplex. The function updates it based on the zero-point direction. |
direction | The current direction. The function updates it based on the zero-point direction. |
- Returns
true
if the zero point is included in the Minkowski sum, i.e. collision is detected, false
otherwise.
◆ GJKDoSimplex() [2/2]
template<typename Coordinate >
bool Geometry::GJKDoSimplex |
( |
GS::Array< Vector3< Coordinate > > & |
simplex, |
|
|
Vector3< Coordinate > & |
direction |
|
) |
| |
Zero-point check for the current simplex in the Minkowski space.
Specific implementation for the 3D case.
- Parameters
-
simplex | The current simplex. The function updates it based on the zero-point direction. |
direction | The current direction. The function updates it based on the zero-point direction. |
- Returns
true
if the zero point is included in the Minkowski sum, i.e. collision is detected, false
otherwise.
◆ GJKGetAveragePoint()
template<typename VectorType >
VectorType Geometry::GJKGetAveragePoint |
( |
const GS::Array< VectorType > & |
vertices | ) |
|
This is to compute the average center (roughly).
It might be different from the Center of Gravity, especially for bodies with nonuniform density, but this is ok as the initial direction of simplex search in GJK.
- Parameters
-
vertices | The array of vertices. |
- Returns
- The average center point.
◆ GJKGetFurthestPoint()
template<typename VectorType >
VectorType Geometry::GJKGetFurthestPoint |
( |
const GS::Array< VectorType > & |
vertices, |
|
|
const VectorType & |
d |
|
) |
| |
Get the furthest vertex point along a certain direction.
- Parameters
-
vertices | The array of vertices. |
d | The direction vector. |
- Returns
- The furthest vertex point.
◆ GJKGetSupport()
template<typename VectorType >
VectorType Geometry::GJKGetSupport |
( |
const GS::Array< VectorType > & |
vertices1, |
|
|
const GS::Array< VectorType > & |
vertices2, |
|
|
const VectorType & |
d |
|
) |
| |
Minkowski sum support function for GJK.
- Parameters
-
vertices1 | The array of vertices of the first shape. |
vertices2 | The array of vertices of the second shape. |
d | The direction vector. |
- Returns
- The Minkowski sum support point along the specified direction.