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

Distance Proxy. More...

#include <DistanceProxy.hpp>

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

Public Types

using ConstVertexPointer = const Length2 *
 Constant vertex pointer.
 
using ConstVertexIterator = ConstVertexPointer
 Constant vertex iterator.
 
using ConstNormalPointer = const UnitVec *
 Constant normal pointer.
 
using ConstNormalIterator = ConstNormalPointer
 Constant normal iterator.
 

Public Member Functions

 DistanceProxy (const DistanceProxy &copy) noexcept
 Copy constructor.
 
 DistanceProxy (const NonNegative< Length > vertexRadius, const VertexCounter count, const Length2 *vertices, const UnitVec *normals) noexcept
 Initializing constructor. More...
 
auto GetVertexRadius () const noexcept
 Gets the vertex radius of the vertices of the associated shape. More...
 
Range< ConstVertexIteratorGetVertices () const noexcept
 Gets the range of vertices.
 
Range< ConstNormalIteratorGetNormals () const noexcept
 Gets the range of normal.
 
auto GetVertexCount () const noexcept
 Gets the vertex count. More...
 
auto GetVertex (VertexCounter index) const noexcept
 Gets a vertex by index. More...
 
auto GetNormal (VertexCounter index) const noexcept
 Gets the normal for the given index.
 

Private Attributes

const Length2m_vertices = nullptr
 Vertices.
 
const UnitVecm_normals = nullptr
 Normals.
 
VertexCounter m_count = 0
 Count of valid elements of m_vertices.
 
NonNegative< Lengthm_vertexRadius = 0_m
 Radius of the vertices of the associated shape.
 

Related Functions

(Note that these are not member functions.)

AABB ComputeAABB (const DistanceProxy &proxy, const Transformation &xf) noexcept
 Computes the AABB. More...
 
AABB ComputeAABB (const DistanceProxy &proxy, const Transformation &xfm0, const Transformation &xfm1) noexcept
 Computes the AABB. More...
 
bool operator== (const DistanceProxy &lhs, const DistanceProxy &rhs) noexcept
 Determines with the two given distance proxies are equal.
 
bool operator!= (const DistanceProxy &lhs, const DistanceProxy &rhs) noexcept
 Determines with the two given distance proxies are not equal.
 
template<class T >
VertexCounter GetSupportIndex (const DistanceProxy &proxy, T dir) noexcept
 Gets the supporting vertex index in the given direction for the given distance proxy. More...
 
bool TestPoint (const DistanceProxy &proxy, Length2 point) noexcept
 Tests a point for containment in the given distance proxy. More...
 
RayCastOutput RayCast (const DistanceProxy &proxy, const RayCastInput &input, const Transformation &transform) noexcept
 Cast a ray against the distance proxy. More...
 

Detailed Description

Distance Proxy.

A distance proxy aggregates a convex set of vertices and a vertex radius of those vertices. This can be visualized as a convex N-sided polygon with rounded corners. It's meant to represent any single portion of a shape identified by its child-index. These are used by the G.J.K. algorithm: "a method for determining the minimum distance between two convex sets".

Note
This data structure is 24-bytes.
See also
https://en.wikipedia.org/wiki/Gilbert%2DJohnson%2DKeerthi_distance_algorithm

Constructor & Destructor Documentation

◆ DistanceProxy()

playrho::d2::DistanceProxy::DistanceProxy ( const NonNegative< Length vertexRadius,
const VertexCounter  count,
const Length2 vertices,
const UnitVec normals 
)
inlinenoexcept

Initializing constructor.

Constructs a distance proxy for n-point shape (like a polygon).

Parameters
vertexRadiusRadius of the given vertices.
countCount of elements of the vertices and normals arrays.
verticesCollection of vertices of the shape (relative to the shape's origin).
normalsCollection of normals of the shape.
Note
The vertices collection must have more than zero elements and no more than MaxShapeVertices elements.
Warning
Behavior is undefined if the vertices collection has less than one element or more than MaxShapeVertices elements.
Behavior is undefined if the vertices are not in counter-clockwise order.
Behavior is undefined if the shape defined by the vertices is not convex.
Behavior is undefined if the normals aren't normals for adjacent vertices.
Behavior is undefined if any normal is not unique.

Member Function Documentation

◆ GetVertex()

auto playrho::d2::DistanceProxy::GetVertex ( VertexCounter  index) const
inlinenoexcept

Gets a vertex by index.

Parameters
indexIndex value less than the count of vertices represented by this proxy.
Warning
Behavior is undefined if the index given is not less than the count of vertices represented by this proxy.
Behavior is undefined if InvalidVertex is given as the index value.
Returns
Vertex linear position (relative to the shape's origin) at the given index.
See also
Distance.

Referenced by playrho::d2::CollideShapes(), playrho::d2::GetManifold(), playrho::d2::GetMaxSeparation(), playrho::d2::GetMaxSeparation4x4(), and playrho::d2::GetSeparationScenario().

◆ GetVertexCount()

auto playrho::d2::DistanceProxy::GetVertexCount ( ) const
inlinenoexcept

Gets the vertex count.

This is the count of valid vertex elements that this object provides.

Returns
Value between 0 and MaxShapeVertices.
Note
This only returns 0 if this proxy was default constructed.

Referenced by playrho::d2::CollideShapes(), playrho::d2::Distance(), playrho::d2::GetManifold(), playrho::d2::GetMaxSeparation(), and playrho::d2::GetSeparationScenario().

◆ GetVertexRadius()

auto playrho::d2::DistanceProxy::GetVertexRadius ( ) const
inlinenoexcept

Gets the vertex radius of the vertices of the associated shape.

Returns
Non-negative distance.

Referenced by playrho::d2::CollideShapes(), playrho::d2::GetManifold(), playrho::d2::GetToiViaSat(), and playrho::d2::TestOverlap().

Friends And Related Function Documentation

◆ ComputeAABB() [1/2]

AABB ComputeAABB ( const DistanceProxy proxy,
const Transformation xf 
)
related

Computes the AABB.

Computes the Axis Aligned Bounding Box (AABB) for the given child shape at a given a transform.

Warning
Behavior is undefined if the given transformation is invalid.
Parameters
proxyDistance proxy for the child shape.
xfWorld transform of the shape.
Returns
AABB for the proxy shape or the default AABB if the proxy has a zero vertex count.
Examples
World.cpp.

◆ ComputeAABB() [2/2]

AABB ComputeAABB ( const DistanceProxy proxy,
const Transformation xfm0,
const Transformation xfm1 
)
related

Computes the AABB.

Computes the Axis Aligned Bounding Box (AABB) for the given child shape at the given transforms.

Warning
Behavior is undefined if a given transformation is invalid.
Parameters
proxyDistance proxy for the child shape.
xfm0World transform 0 of the shape.
xfm1World transform 1 of the shape.
Returns
AABB for the proxy shape or the default AABB if the proxy has a zero vertex count.

◆ GetSupportIndex()

template<class T >
VertexCounter GetSupportIndex ( const DistanceProxy proxy,
dir 
)
related

Gets the supporting vertex index in the given direction for the given distance proxy.

This finds the vertex that's most significantly in the direction of the given vector and returns its index.

Note
0 is returned for a given zero length direction vector.
Parameters
proxyDistance proxy object to find index in if a valid index exists for it.
dirDirection vector to find index for.
Returns
InvalidVertex if d is invalid or the count of vertices is zero, otherwise a value from 0 to one less than count.
See also
GetVertexCount().

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