This structure allows to encode contact patches. A contact patch is defined by a set of points belonging to a subset of a plane passing by p
and supported by n
, where n = Contact::normal
and p = Contact::pos
. If we denote by P this plane and by S1 and S2 the first and second shape of a collision pair, a contact patch is represented as a polytope which vertices all belong to P & S1 & S2
, where &
denotes the set-intersection. Since a contact patch is a subset of a plane supported by n
, it has a preferred direction. In Coal, the Contact::normal
points from S1 to S2. In the same way, a contact patch points by default from S1 to S2.
More...
#include <collision_data.h>
Public Types | |
enum | PatchDirection { DEFAULT = 0, INVERTED = 1 } |
Direction of ContactPatch. When doing collision detection, the convention of Coal is that the normal always points from the first to the second shape of the collision pair i.e. from shape1 to shape2 when calling collide(shape1, shape2) . The PatchDirection enum allows to identify if the patch points from shape 1 to shape 2 (Default type) or from shape 2 to shape 1 (Inverted type). The Inverted type should only be used for internal Coal computations (it allows to properly define two separate contact patches in the same frame). More... | |
using | Polygon = std::vector< Vec2s > |
Public Member Functions | |
void | addPoint (const Vec3s &point_3d) |
Add a 3D point to the set, expressed in the world frame. More... | |
void | clear () |
Clear the set. More... | |
ContactPatch (size_t preallocated_size=default_preallocated_size) | |
Default constructor. Note: the preallocated size does not determine the maximum number of points in the patch, it only serves as preallocation if the maximum size of the patch is known in advance. Coal will automatically expand/shrink the contact patch if needed. More... | |
Vec3s | getNormal () const |
Normal of the contact patch, expressed in the WORLD frame. More... | |
Vec3s | getPoint (const size_t i) const |
Get the i-th point of the set, expressed in the 3D world frame. More... | |
Vec3s | getPointShape1 (const size_t i) const |
Get the i-th point of the contact patch, projected back onto the first shape of the collision pair. This point is expressed in the 3D world frame. More... | |
Vec3s | getPointShape2 (const size_t i) const |
Get the i-th point of the contact patch, projected back onto the first shape of the collision pair. This 3D point is expressed in the world frame. More... | |
bool | isSame (const ContactPatch &other, const CoalScalar tol=Eigen::NumTraits< CoalScalar >::dummy_precision()) const |
Whether two contact patches are the same or not. Checks for different order of the points. More... | |
bool | operator== (const ContactPatch &other) const |
Whether two contact patches are the same or not. More... | |
Vec2s & | point (const size_t i) |
Getter for the i-th 2D point in the set. More... | |
const Vec2s & | point (const size_t i) const |
Const getter for the i-th 2D point in the set. More... | |
Polygon & | points () |
Getter for the 2D points in the set. More... | |
const Polygon & | points () const |
Const getter for the 2D points in the set. More... | |
size_t | size () const |
Returns the number of points in the contact patch. More... | |
Public Attributes | |
PatchDirection | direction |
Direction of this contact patch. More... | |
CoalScalar | penetration_depth |
Penetration depth of the contact patch. This value corresponds to the signed distance d between the shapes. More... | |
Transform3s | tf |
Frame of the set, expressed in the world coordinates. The z-axis of the frame's rotation is the contact patch normal. More... | |
Static Public Attributes | |
static constexpr size_t | default_preallocated_size = 12 |
Default maximum size of the polygon representing the contact patch. Used to pre-allocate memory for the patch. More... | |
Protected Attributes | |
Polygon | m_points |
Container for the vertices of the set. More... | |
This structure allows to encode contact patches. A contact patch is defined by a set of points belonging to a subset of a plane passing by p
and supported by n
, where n = Contact::normal
and p = Contact::pos
. If we denote by P this plane and by S1 and S2 the first and second shape of a collision pair, a contact patch is represented as a polytope which vertices all belong to P & S1 & S2
, where &
denotes the set-intersection. Since a contact patch is a subset of a plane supported by n
, it has a preferred direction. In Coal, the Contact::normal
points from S1 to S2. In the same way, a contact patch points by default from S1 to S2.
ContactPatch
is a polygon (2D polytope), so the points of the set, forming the convex-hull of the polytope, are stored in a counter-clockwise fashion. Definition at line 512 of file coal/collision_data.h.
using coal::ContactPatch::Polygon = std::vector<Vec2s> |
Definition at line 514 of file coal/collision_data.h.
Direction of ContactPatch. When doing collision detection, the convention of Coal is that the normal always points from the first to the second shape of the collision pair i.e. from shape1 to shape2 when calling collide(shape1, shape2)
. The PatchDirection enum allows to identify if the patch points from shape 1 to shape 2 (Default type) or from shape 2 to shape 1 (Inverted type). The Inverted type should only be used for internal Coal computations (it allows to properly define two separate contact patches in the same frame).
Enumerator | |
---|---|
DEFAULT | |
INVERTED |
Definition at line 529 of file coal/collision_data.h.
|
inlineexplicit |
Default constructor. Note: the preallocated size does not determine the maximum number of points in the patch, it only serves as preallocation if the maximum size of the patch is known in advance. Coal will automatically expand/shrink the contact patch if needed.
Definition at line 561 of file coal/collision_data.h.
|
inline |
Add a 3D point to the set, expressed in the world frame.
Definition at line 584 of file coal/collision_data.h.
|
inline |
Clear the set.
Definition at line 640 of file coal/collision_data.h.
|
inline |
Normal of the contact patch, expressed in the WORLD frame.
Definition at line 569 of file coal/collision_data.h.
|
inline |
Get the i-th point of the set, expressed in the 3D world frame.
Definition at line 590 of file coal/collision_data.h.
|
inline |
Get the i-th point of the contact patch, projected back onto the first shape of the collision pair. This point is expressed in the 3D world frame.
Definition at line 600 of file coal/collision_data.h.
|
inline |
Get the i-th point of the contact patch, projected back onto the first shape of the collision pair. This 3D point is expressed in the world frame.
Definition at line 609 of file coal/collision_data.h.
|
inline |
Whether two contact patches are the same or not. Checks for different order of the points.
Definition at line 658 of file coal/collision_data.h.
|
inline |
Whether two contact patches are the same or not.
isEqual
in this case. Definition at line 650 of file coal/collision_data.h.
|
inline |
Getter for the i-th 2D point in the set.
Definition at line 622 of file coal/collision_data.h.
|
inline |
Const getter for the i-th 2D point in the set.
Definition at line 631 of file coal/collision_data.h.
|
inline |
Getter for the 2D points in the set.
Definition at line 616 of file coal/collision_data.h.
|
inline |
Const getter for the 2D points in the set.
Definition at line 619 of file coal/collision_data.h.
|
inline |
Returns the number of points in the contact patch.
Definition at line 577 of file coal/collision_data.h.
|
staticconstexpr |
Default maximum size of the polygon representing the contact patch. Used to pre-allocate memory for the patch.
Definition at line 549 of file coal/collision_data.h.
PatchDirection coal::ContactPatch::direction |
Direction of this contact patch.
Definition at line 532 of file coal/collision_data.h.
|
protected |
Container for the vertices of the set.
Definition at line 553 of file coal/collision_data.h.
CoalScalar coal::ContactPatch::penetration_depth |
Penetration depth of the contact patch. This value corresponds to the signed distance d
between the shapes.
p
in the patch of normal n
, p1 = p - 0.5*d*n
and p2 = p + 0.5*d*n
define a pair of witness points. p1
belongs to the surface of the first shape and p2
belongs to the surface of the second shape. For any pair of witness points, we always have p2 - p1 = d * n
. The vector d * n
is called a minimum separation vector: if S1 is translated by it, S1 and S2 are not in collision anymore. d * n
. Definition at line 545 of file coal/collision_data.h.
Transform3s coal::ContactPatch::tf |
Frame of the set, expressed in the world coordinates. The z-axis of the frame's rotation is the contact patch normal.
Definition at line 518 of file coal/collision_data.h.