Box2D  3.0.0
A Real-Time-Oriented 2-D Physics Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
box2d::Simplex Class Reference

Simplex. More...

#include <Simplex.hpp>

Classes

class  Cache
 Simplex cache. More...
 

Public Types

using Edges = ArrayList< SimplexEdge, MaxEdges, std::remove_const< decltype(MaxEdges)>::type >
 Simplex edge collection. More...
 
using size_type = Edges::size_type
 Size type. More...
 
using Coefficients = ArrayList< RealNum, MaxEdges, std::remove_const< decltype(MaxEdges)>::type >
 Coefficients. More...
 
using IndexPairs = ArrayList< IndexPair, MaxEdges, std::remove_const< decltype(MaxEdges)>::type >
 Index pairs. More...
 

Public Member Functions

 Simplex ()=default
 
BOX2D_CONSTEXPR Edges GetEdges () const noexcept
 
const SimplexEdgeGetSimplexEdge (size_type index) const noexcept
 
BOX2D_CONSTEXPR RealNum GetCoefficient (size_type index) const noexcept
 
BOX2D_CONSTEXPR size_type GetSize () const noexcept
 

Static Public Member Functions

static Cache GetCache (const Simplex::Edges &edges) noexcept
 
static IndexPairs GetIndexPairs (const Edges &collection) noexcept
 Gets index pairs for the given edges collection. More...
 
static BOX2D_CONSTEXPR Length2D CalcSearchDirection (const Edges &simplexEdges) noexcept
 Calculates the "search direction" for the given simplex edge list. More...
 
static RealNum CalcMetric (const Edges &simplexEdges)
 Gets the given simplex's "metric". More...
 
static Simplex Get (const SimplexEdge &s0) noexcept
 
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 Edges &edges) noexcept
 Gets the simplex for the given collection of vertices. More...
 

Static Public Attributes

static constexpr auto MaxEdges = std::uint8_t{3}
 Maximum number of supportable edges in a simplex. More...
 

Detailed Description

Simplex.

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 GJK 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 box2d::Simplex::Coefficients = ArrayList<RealNum, MaxEdges, std::remove_const<decltype(MaxEdges)>::type>

Coefficients.

Collection of coefficient values.

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

◆ Edges

using box2d::Simplex::Edges = ArrayList<SimplexEdge, MaxEdges, std::remove_const<decltype(MaxEdges)>::type>

Simplex edge collection.

Note
This data is 28 * 3 + 4 = 88-bytes large (on at least one 64-bit platform).

◆ IndexPairs

using box2d::Simplex::IndexPairs = ArrayList<IndexPair, MaxEdges, std::remove_const<decltype(MaxEdges)>::type>

Index pairs.

Note
This data type is 7-bytes large (on at least one 64-bit platform).

◆ size_type

using box2d::Simplex::size_type = Edges::size_type

Size type.

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

Constructor & Destructor Documentation

◆ Simplex()

box2d::Simplex::Simplex ( )
default

Member Function Documentation

◆ CalcMetric()

RealNum box2d::Simplex::CalcMetric ( const Edges simplexEdges)
inlinestatic

Gets the given simplex's "metric".

◆ CalcSearchDirection()

BOX2D_CONSTEXPR Length2D box2d::Simplex::CalcSearchDirection ( const Edges simplexEdges)
inlinestaticnoexcept

Calculates the "search direction" for the given simplex edge list.

Parameters
simplexEdgesA one or two edge list.
Warning
Behavior is undefined if the given edge list has zero edges.
Returns
"search direction" vector.

◆ Get() [1/4]

Simplex Simplex::Get ( const SimplexEdge s0)
staticnoexcept

◆ Get() [2/4]

Simplex 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() [3/4]

Simplex 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() [4/4]

Simplex Simplex::Get ( const Edges 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.

◆ GetCache()

Simplex::Cache box2d::Simplex::GetCache ( const Simplex::Edges edges)
inlinestaticnoexcept

◆ GetCoefficient()

BOX2D_CONSTEXPR RealNum box2d::Simplex::GetCoefficient ( size_type  index) const
inlinenoexcept

◆ GetEdges()

BOX2D_CONSTEXPR Simplex::Edges box2d::Simplex::GetEdges ( ) const
inlinenoexcept

◆ GetIndexPairs()

Simplex::IndexPairs box2d::Simplex::GetIndexPairs ( const Edges collection)
inlinestaticnoexcept

Gets index pairs for the given edges collection.

◆ GetSimplexEdge()

const SimplexEdge & box2d::Simplex::GetSimplexEdge ( size_type  index) const
inlinenoexcept

◆ GetSize()

BOX2D_CONSTEXPR Simplex::size_type box2d::Simplex::GetSize ( ) const
inlinenoexcept

Member Data Documentation

◆ MaxEdges

constexpr auto box2d::Simplex::MaxEdges = std::uint8_t{3}
static

Maximum number of supportable edges in a simplex.


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