playrho::d2::DistanceProxy Class Reference

Distance Proxy. More...

#include <DistanceProxy.hpp>

Public Types

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

Public Member Functions

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

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. More...
 
bool operator!= (const DistanceProxy &lhs, const DistanceProxy &rhs) noexcept
 Determines with the two given distance proxies are not equal. More...
 
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

Definition at line 51 of file DistanceProxy.hpp.

Member Typedef Documentation

◆ ConstVertexPointer

Constant vertex pointer.

Definition at line 55 of file DistanceProxy.hpp.

◆ ConstVertexIterator

Constant vertex iterator.

Definition at line 58 of file DistanceProxy.hpp.

◆ ConstNormalPointer

Constant normal pointer.

Definition at line 61 of file DistanceProxy.hpp.

◆ ConstNormalIterator

Constant normal iterator.

Definition at line 64 of file DistanceProxy.hpp.

Constructor & Destructor Documentation

◆ DistanceProxy() [1/3]

playrho::d2::DistanceProxy::DistanceProxy ( )
default

◆ DistanceProxy() [2/3]

playrho::d2::DistanceProxy::DistanceProxy ( const DistanceProxy copy)
inlinenoexcept

Copy constructor.

Definition at line 69 of file DistanceProxy.hpp.

◆ DistanceProxy() [3/3]

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.

Definition at line 104 of file DistanceProxy.hpp.

Member Function Documentation

◆ GetVertexRadius()

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

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

Returns
Non-negative distance.

Definition at line 131 of file DistanceProxy.hpp.

◆ GetVertices()

Range<ConstVertexIterator> playrho::d2::DistanceProxy::GetVertices ( ) const
inlinenoexcept

Gets the range of vertices.

Definition at line 134 of file DistanceProxy.hpp.

◆ GetNormals()

Range<ConstNormalIterator> playrho::d2::DistanceProxy::GetNormals ( ) const
inlinenoexcept

Gets the range of normal.

Definition at line 140 of file DistanceProxy.hpp.

◆ 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.

Definition at line 149 of file DistanceProxy.hpp.

◆ 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.

Definition at line 164 of file DistanceProxy.hpp.

◆ GetNormal()

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

Gets the normal for the given index.

Definition at line 172 of file DistanceProxy.hpp.

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.

Definition at line 36 of file AABB.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.

Definition at line 47 of file AABB.cpp.

◆ operator==()

bool operator== ( const DistanceProxy lhs,
const DistanceProxy rhs 
)
related

Determines with the two given distance proxies are equal.

Definition at line 28 of file DistanceProxy.cpp.

◆ operator!=()

bool operator!= ( const DistanceProxy lhs,
const DistanceProxy rhs 
)
related

Determines with the two given distance proxies are not equal.

Definition at line 199 of file DistanceProxy.hpp.

◆ 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().

Definition at line 221 of file DistanceProxy.hpp.


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