PlayRho  1.1.0
An Interactive Real-Time-Oriented C++ Physics Engine & Library
playrho::d2::Simplex Class Reference

An encapsulation of a point, line segment, or triangle. More...

#include <Simplex.hpp>

Collaboration diagram for playrho::d2::Simplex:
[legend]

Classes

struct  Cache
 Simplex cache. More...
 

Public Types

using size_type = SimplexEdges::size_type
 Size type. More...
 
using Coefficients = ArrayList< Real, MaxSimplexEdges, std::remove_const< decltype(MaxSimplexEdges)>::type >
 Coefficients. More...
 

Public Member Functions

constexpr SimplexEdges GetEdges () const noexcept
 Gets the edges.
 
const SimplexEdgeGetSimplexEdge (size_type index) const noexcept
 Gets the give indexed simplex edge.
 
constexpr Real GetCoefficient (size_type index) const noexcept
 Gets the coefficient for the given index.
 
constexpr size_type size () const noexcept
 Gets the size in number of simplex edges that this instance is made up of. More...
 

Static Public Member Functions

static Cache GetCache (const SimplexEdges &edges) noexcept
 Gets the cache value for the given edges.
 
static Real CalcMetric (const SimplexEdges &simplexEdges)
 Gets the given simplex's "metric".
 
static Simplex Get (const SimplexEdge &s0) noexcept
 Gets the Simplex for the given simplex edge.
 
static Simplex Get (const SimplexEdge &s0, const SimplexEdge &s1) noexcept
 Gets the simplex for the given 2 edges. More...
 
static Simplex Get (const SimplexEdge &s0, const SimplexEdge &s1, const SimplexEdge &s2) noexcept
 Gets the simplex for the given 3 edges. More...
 
static Simplex Get (const SimplexEdges &edges) noexcept
 Gets the simplex for the given collection of vertices. More...
 

Private Member Functions

 Simplex (const SimplexEdges &simplexEdges, const Coefficients &normalizedWeights) noexcept
 Initializing constructor.
 

Private Attributes

SimplexEdges m_simplexEdges
 Collection of valid simplex edges. More...
 
Coefficients m_normalizedWeights
 Normalized weights. More...
 

Detailed Description

An encapsulation of a point, line segment, or triangle.

An encapsulation of a point, line segment, or triangle. These are defined respectively as: a 0-simplex, a 1-simplex, and a 2-simplex. Used in doing G.J.K. collision detection.

Note
This data structure is 104-bytes large.
Invariant
Vertex's for the same index must have the same point locations.
There may not be more than one entry for the same index pair.
See also
https://en.wikipedia.org/wiki/Simplex
https://en.wikipedia.org/wiki/Gilbert%2DJohnson%2DKeerthi_distance_algorithm

Member Typedef Documentation

◆ Coefficients

using playrho::d2::Simplex::Coefficients = ArrayList<Real, MaxSimplexEdges, std::remove_const<decltype(MaxSimplexEdges)>::type>

Coefficients.

Collection of coefficient values.

Note
This data structure is 4 * 3 + 4 = 16-bytes large.

◆ size_type

using playrho::d2::Simplex::size_type = SimplexEdges::size_type

Size type.

Note
This data type is explicitly set to 1-byte large.

Member Function Documentation

◆ Get() [1/3]

Simplex playrho::d2::Simplex::Get ( const SimplexEdge s0,
const SimplexEdge s1 
)
staticnoexcept

Gets the simplex for the given 2 edges.

Note
The given simplex vertices must have different index pairs or be of the same values.
Warning
Behavior is undefined if the given simplex edges index pairs are the same and the whole edges values are not also the same.
Parameters
s0Simplex edge 0.
s1Simplex edge 1.
Returns
One or two edge simplex.

◆ Get() [2/3]

Simplex playrho::d2::Simplex::Get ( const SimplexEdge s0,
const SimplexEdge s1,
const SimplexEdge s2 
)
staticnoexcept

Gets the simplex for the given 3 edges.

Returns
One, two, or three edge simplex.

◆ Get() [3/3]

Simplex playrho::d2::Simplex::Get ( const SimplexEdges edges)
staticnoexcept

Gets the simplex for the given collection of vertices.

Parameters
edgesCollection of zero, one, two, or three simplex edges.
Warning
Behavior is undefined if the given collection has more than 3 edges.
Returns
Zero, one, two, or three edge simplex.

◆ size()

constexpr Simplex::size_type playrho::d2::Simplex::size ( ) const
constexprnoexcept

Gets the size in number of simplex edges that this instance is made up of.

Gets the size in number of valid edges of this Simplex.

Returns
Value between 0 and MaxEdges (inclusive).

Referenced by Get(), and playrho::d2::GetClosestPoint().

Member Data Documentation

◆ m_normalizedWeights

Coefficients playrho::d2::Simplex::m_normalizedWeights
private

Normalized weights.

Collection of coefficients (ranging from greater than 0 to less than 1). A.k.a.: barycentric coordinates.

Note
This member variable is 16-bytes.

Referenced by GetCoefficient().

◆ m_simplexEdges

SimplexEdges playrho::d2::Simplex::m_simplexEdges
private

Collection of valid simplex edges.

Note
This member variable is 88-bytes.

Referenced by GetEdges(), GetSimplexEdge(), and size().


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