Struct Contact
Defined in File collision_data.h
Struct Documentation
-
struct Contact
Contact information returned by collision.
Public Functions
-
inline Contact()
Default constructor.
-
Contact(const Contact &other) = default
Copy constructor. This constructor does a raw copy of the contact information, including the pointers to the collision geometries.
-
inline Contact(const Contact &other, std::pair<const CollisionGeometry*, const CollisionGeometry*> new_o1_o2)
Copy constructor using an other contact and a pair of CollisionGeometry pointers. This constructor allows to copy the contact information from an other contact, but remap the pointers to the collision geometries to the provided ones. This is usefull in a deep-copy context, when the collision geometries are also copied and the pointers in the contact need to be remapped to the new collision geometries.
-
inline Contact(const CollisionGeometry *o1_, const CollisionGeometry *o2_, int b1_, int b2_)
-
inline Contact(const CollisionGeometry *o1_, const CollisionGeometry *o2_, int b1_, int b2_, const Vec3s &pos_, const Vec3s &normal_, Scalar depth_)
-
inline Contact(const CollisionGeometry *o1_, const CollisionGeometry *o2_, int b1_, int b2_, const Vec3s &p1, const Vec3s &p2, const Vec3s &normal_, Scalar depth_)
-
inline bool operator==(const Contact &other) const
Equality operator. Two contacts are considered equal if they have the same normal, the same nearest points and the same penetration depth and if the shapes they point to are equal. Note: two contacts may be equal even if they point to different collision geometries o1/o2, as long as these geometries are equal.
-
inline bool operator!=(const Contact &other) const
Inequality operator. Negation of the equality operator.
-
inline Scalar getDistanceToCollision(const CollisionRequest &request) const
Returns the distance to collision: penetration depth - security margin.
-
inline void resolveReferences(std::pair<const CollisionGeometry*, const CollisionGeometry*> new_o1_o2)
Resolve internal references to the pair of collision geometries. This is useful when deserializing a contact, as the pointers to the collision objects are not valid anymore and need to be remapped to the collision objects in the current context.
-
inline void disp(std::ostream &os, const std::string &prefix = "") const
Prints the contact to the provided output stream.
Public Members
-
const CollisionGeometry *o1
collision object 1
-
const CollisionGeometry *o2
collision object 2
-
int b1
contact primitive in object 1 if object 1 is mesh or point cloud, it is the triangle or point id if object 1 is geometry shape, it is NONE (-1), if object 1 is octree, it is the id of the cell
-
int b2
contact primitive in object 2 if object 2 is mesh or point cloud, it is the triangle or point id if object 2 is geometry shape, it is NONE (-1), if object 2 is octree, it is the id of the cell
-
Vec3s normal
contact normal, pointing from o1 to o2. The normal defined as the normalized separation vector: normal = (p2 - p1) / dist(o1, o2), where p1 = nearest_points[0] belongs to o1 and p2 = nearest_points[1] belongs to o2 and dist(o1, o2) is the signed distance between o1 and o2. The normal always points from o1 to o2.
Note
The separation vector is the smallest vector such that if o1 is translated by it, o1 and o2 are in touching contact (they share at least one contact point but have a zero intersection volume). If the shapes overlap, dist(o1, o2) = -((p2-p1).norm()). Otherwise, dist(o1, o2) = (p2-p1).norm().
-
std::array<Vec3s, 2> nearest_points
nearest points associated to this contact.
Note
Also referred as “witness points” in other collision libraries. The points p1 = nearest_points[0] and p2 = nearest_points[1] verify the property that dist(o1, o2) * (p1 - p2) is the separation vector between o1 and o2, with dist(o1, o2) being the signed distance separating o1 from o2. See DistanceResult::normal for the definition of the separation vector. If o1 and o2 have multiple contacts, the nearest_points are associated with the contact which has the greatest penetration depth. TODO (louis): rename
nearest_pointstowitness_points.
Public Static Attributes
-
static const int NONE = -1
invalid contact primitive information
-
inline Contact()