Collision objects

Description

Collaboration diagram for Collision objects:

Classes

class  chrono::collision::ChCAABBGenerator
 Generator for Axis-Aligned Bounding Boxes. More...
 
class  chrono::collision::ChCBroadphase
 Class for performing broad-phase collision detection. More...
 
class  chrono::collision::ChCNarrowphaseDispatch
 Class for performing narrow-phase collision detection. More...
 
class  chrono::collision::ChCollisionShapeMulticore
 Class to encapsulate description of a convex collision shape. More...
 
class  chrono::collision::ChCollisionModelMulticore
 Class for geometric model for collision detection. More...
 
class  chrono::collision::ChCollisionSystemBulletMulticore
 Collision engine based on the 'Bullet' library. More...
 
class  chrono::collision::ChCollisionSystemMulticore
 Class for collision engine based on the spatial subdivision method. More...
 
class  chrono::ChContactContainerMulticore
 Class representing a container of many contacts, implemented as a linked list of contact tuples. More...
 
class  chrono::ChContactContainerMulticoreNSC
 Specialization of the multicore contact container for NSC contacts. More...
 
class  chrono::ChContactContainerMulticoreSMC
 Specialization of the multicore contact container for SMC contacts. More...
 
class  chrono::collision::ConvexBase
 Base class for convex contact shapes. More...
 
class  chrono::collision::ConvexShape
 Convex contact shape. More...
 
class  chrono::collision::ConvexShapeSphere
 Sphere contact shape. More...
 
class  chrono::collision::ConvexShapeCustom
 Custom contact shape. More...
 
class  chrono::collision::ConvexShapeTetrahedron
 Tetrahedron contact shape. More...
 
class  chrono::collision::ConvexShapeTriangle
 Triangle contact shape. More...
 

Functions

template<class T >
vec3 chrono::collision::HashMin (const T &A, const real3 &inv_bin_size_vec)
 Convert a position into a bin index ("lower" corner).
 
template<class T >
vec3 chrono::collision::HashMax (const T &A, const real3 &inv_bin_size_vec)
 Convert a position into a bin index ("upper" corner).
 
CH_MULTICORE_API bool chrono::collision::MPRContact (const ConvexBase *ShapeA, const ConvexBase *ShapeB, const real &envelope, real3 &returnNormal, real3 &point, real &depth)
 
CH_MULTICORE_API bool chrono::collision::MPRCollision (const ConvexBase *ShapeA, const ConvexBase *ShapeB, real envelope, real3 &returnNormal, real3 &pointA, real3 &pointB, real &depth)
 
CH_MULTICORE_API void chrono::collision::MPRGetPoints (const ConvexBase *ShapeA, const ConvexBase *ShapeB, const real &envelope, real3 &N, real3 p0, real3 &p1, real3 &p2)
 
CH_MULTICORE_API bool chrono::collision::MPRSphereSphere (const ConvexBase *ShapeA, const ConvexBase *ShapeB, real3 &N, real &dist, real3 &p1, real3 &p2)
 
bool chrono::collision::sphere_sphere (const real3 &pos1, const real &radius1, const real3 &pos2, const real &radius2, const real &separation, real3 &norm, real &depth, real3 &pt1, real3 &pt2, real &eff_radius)
 Analytical sphere vs. sphere collision function.
 
bool chrono::collision::capsule_sphere (const real3 &pos1, const quaternion &rot1, const real &radius1, const real &hlen1, const real3 &pos2, const real &radius2, const real &separation, real3 &norm, real &depth, real3 &pt1, real3 &pt2, real &eff_radius)
 Analytical capsule vs. sphere collision function.
 
bool chrono::collision::cylinder_sphere (const real3 &pos1, const quaternion &rot1, const real &radius1, const real &hlen1, const real3 &pos2, const real &radius2, const real &separation, real3 &norm, real &depth, real3 &pt1, real3 &pt2, real &eff_radius)
 Analytical cylinder vs. sphere collision function.
 
bool chrono::collision::roundedcyl_sphere (const real3 &pos1, const quaternion &rot1, const real &radius1, const real &hlen1, const real &srad1, const real3 &pos2, const real &radius2, const real &separation, real3 &norm, real &depth, real3 &pt1, real3 &pt2, real &eff_radius)
 Analytical rounded cylinder vs. sphere collision function.
 
bool chrono::collision::box_sphere (const real3 &pos1, const quaternion &rot1, const real3 &hdims1, const real3 &pos2, const real &radius2, const real &separation, real3 &norm, real &depth, real3 &pt1, real3 &pt2, real &eff_radius)
 Analytical box vs. sphere collision function.
 
bool chrono::collision::roundedbox_sphere (const real3 &pos1, const quaternion &rot1, const real3 &hdims1, const real &srad1, const real3 &pos2, const real &radius2, const real &separation, real3 &norm, real &depth, real3 &pt1, real3 &pt2, real &eff_radius)
 Analytical rounded box vs. sphere collision function.
 
bool chrono::collision::triangle_sphere (const real3 &A1, const real3 &B1, const real3 &C1, const real3 &pos2, const real &radius2, const real &separation, real3 &norm, real &depth, real3 &pt1, real3 &pt2, real &eff_radius)
 Analytical triangle face vs. sphere collision function.
 
int chrono::collision::capsule_capsule (const real3 &pos1, const quaternion &rot1, const real &radius1, const real &hlen1, const real3 &pos2, const quaternion &rot2, const real &radius2, const real &hlen2, const real &separation, real3 *norm, real *depth, real3 *pt1, real3 *pt2, real *eff_radius)
 Analytical capsule vs. capsule collision function.
 
int chrono::collision::box_capsule (const real3 &pos1, const quaternion &rot1, const real3 &hdims1, const real3 &pos2, const quaternion &rot2, const real &radius2, const real &hlen2, const real &separation, real3 *norm, real *depth, real3 *pt1, real3 *pt2, real *eff_radius)
 Analytical box vs. capsule collision function.
 
int chrono::collision::box_cylshell (const real3 &pos1, const quaternion &rot1, const real3 &hdims1, const real3 &pos2, const quaternion &rot2, const real &radius2, const real &hlen2, const real &separation, real3 *norm, real *depth, real3 *pt1, real3 *pt2, real *eff_radius)
 Analytical box vs. cylindrical shell collision function. More...
 
int chrono::collision::box_box (const real3 &pos1, const quaternion &rot1, const real3 &hdims1, const real3 &pos2, const quaternion &rot2, const real3 &hdims2, const real &separation, real3 *norm, real *depth, real3 *pt1, real3 *pt2, real *eff_radius)
 Analytical box vs. box collision function.
 
bool chrono::collision::RCollision (const ConvexBase *shapeA, const ConvexBase *shapeB, real separation, real3 *ct_norm, real3 *ct_pt1, real3 *ct_pt2, real *ct_depth, real *ct_eff_rad, int &nC)
 Dispatcher for analytic collision functions. More...
 
void chrono::collision::SetDefaultEdgeRadius (real radius)
 Set the fictitious radius of curvature used for collision with a corner or an edge.
 
real chrono::collision::GetDefaultEdgeRadius ()
 Return the fictitious radius of curvature used for collisions with a corner or an edge.
 
real3 chrono::collision::triangle_normal (const real3 &A, const real3 &B, const real3 &C)
 This utility function returns the normal to the triangular face defined by the vertices A, B, and C. More...
 
bool chrono::collision::snap_to_triangle (const real3 &A, const real3 &B, const real3 &C, const real3 &P, real3 &res)
 This utility function takes the location 'P' and snaps it to the closest point on the triangular face with given vertices (A, B, and C). More...
 
uint chrono::collision::snap_to_cylinder (const real &rad, const real &hlen, real3 &loc)
 This utility function snaps the specified location to a point on a cylinder with given radius and half-length. More...
 
uint chrono::collision::box_closest_feature (const real3 &dir, const real3 &hdims)
 This utility function returns a code that indicates the closest feature of a box in the specified direction. More...
 
uint chrono::collision::snap_to_box (const real3 &hdims, real3 &loc)
 This utility function snaps the specified location to a point on a box with given half-dimensions. More...
 
real3 chrono::collision::snap_to_box_face (const real3 &hdims, const real3 &pt_on_box, uint code, const real3 &pt_to_snap)
 This utility function snaps the location 'pt_to_snap' to a location on the face of this box identified by the specified 'code' and 'pt_on_box'. More...
 
real3 chrono::collision::snap_to_box_edge (const real3 &hdims, const real3 &pt_on_box, uint code, const real3 &pt_to_snap)
 This utility function snaps the location 'pt_to_snap' to a location on the edge of this box identified by the specified 'code' and 'pt_on_box'. More...
 
void chrono::collision::get_edge_corners (const real3 &pt_on_edge, uint code, real3 *corners)
 This utility function fill out 'corners' with the corners of the box edge specified by 'code' and 'pt_on_edge'. More...
 
void chrono::collision::get_face_corners (const real3 &pt_on_face, uint code, real3 *corners)
 This utility function fill out 'corners' with the corners of the face specified by 'code' and 'pt_on_face'. More...
 
real3 chrono::collision::get_face_normal (const real3 &pt_on_face, uint code)
 This utility function returns the box face normal (expressed in the box local frame) for the face specified by 'code' and 'pt_on_face'. More...
 
bool chrono::collision::point_vs_face (const real3 &hdims, const real3 &pt_on_face, uint code, const real3 &point, const real &separation, real3 &result, real3 &normal, real &dist)
 This utility function returns true if 'point' is no farther than 'separation' from the face of this box identified by 'pt_on_face' and 'code'; and returns false otherwise. More...
 
bool chrono::collision::segment_vs_edge (const real3 &hdims, const real3 &pt_on_edge, uint code, const real3 &pt1, const real3 &pt2, real3 &locE, real3 &locS)
 This utility function calculates the closest points between the box edge identified by 'pt_on_edge' and 'code' and a line segment between 'pt1' and 'pt2'. More...
 
real3 chrono::collision::box_farthest_corner (const real3 &hdims, const real3 &dir)
 This utility function returns the corner of a box of given dimensions that if farthest in the direction 'dir', which is assumed to be given in the frame of the box.
 
real3 chrono::collision::box_closest_corner (const real3 &hdims, const real3 &dir)
 This utility function returns the corner of a box of given dimensions that if closest in the direction 'dir', which is assumed to be given in the frame of the box.
 
int chrono::collision::box_intersects_box (const real3 &hdims1, const real3 &hdims2, const real3 &pos, const quaternion &rot, real separation, real3 &dir)
 This function returns an integer indicating whether or not a box1 with dimensions hdims1 intersects (or is close enough to) a second box with dimensions hdims2. More...
 
real3 chrono::collision::GetSupportPoint_Sphere (const real &radius, const real3 &n)
 Support point for a sphere (for GJK and MPR).
 
real3 chrono::collision::GetSupportPoint_Triangle (const real3 *t, const real3 &n)
 Support point for a triangle (for GJK and MPR).
 
real3 chrono::collision::GetSupportPoint_Box (const real3 &B, const real3 &n)
 Support point for a box (for GJK and MPR).
 
real3 chrono::collision::GetSupportPoint_Ellipsoid (const real3 &B, const real3 &n)
 Support point for an ellipsoid (for GJK and MPR).
 
real3 chrono::collision::GetSupportPoint_Cylinder (const real3 &B, const real3 &n)
 Support point for a cylinder (for GJK and MPR).
 
real3 chrono::collision::GetSupportPoint_Plane (const real3 &B, const real3 &n)
 Support point for a plane (for GJK and MPR).
 
real3 chrono::collision::GetSupportPoint_Cone (const real3 &B, const real3 &n)
 Support point for a cone (for GJK and MPR).
 
real3 chrono::collision::GetSupportPoint_Seg (const real B, const real3 &n)
 Support point for a line segment (for GJK and MPR).
 
real3 chrono::collision::GetSupportPoint_Capsule (const real2 &B, const real3 &n)
 Support point for a capsule (for GJK and MPR).
 
real3 chrono::collision::GetSupportPoint_Disk (const real &B, const real3 &n)
 Support point for a disk (for GJK and MPR).
 
real3 chrono::collision::GetSupportPoint_Rect (const real3 &B, const real3 &n)
 Support point for a rectangle (for GJK and MPR).
 
real3 chrono::collision::GetSupportPoint_RoundedBox (const real4 &B, const real3 &n)
 Support point for a rounded box, i.e. a sphere-swept box (for GJK and MPR).
 
real3 chrono::collision::GetSupportPoint_RoundedCylinder (const real4 &B, const real3 &n)
 Support point for a rounded cylinder, i.e. a sphere-swept cylinder (for GJK and MPR).
 
real3 chrono::collision::GetSupportPoint_CylindricalShell (const real3 &B, const real3 &n)
 Support point for a cylindrical shell (for GJK and MPR).
 
real3 chrono::collision::GetSupportPoint_RoundedCone (const real4 &B, const real3 &n)
 Support point for a rounded cone, i.e. a sphere-swept cone (for GJK and MPR).
 
real3 chrono::collision::GetSupportPoint_Convex (const int size, const real3 *convex_data, const real3 &n)
 Support point for a generic convex shape (for GJK and MPR).
 
real3 chrono::collision::GetSupportPoint_Tetrahedron (const uvec4 indices, const real3 *nodes, const real3 &n)
 Support point for a tetrahedron (for GJK and MPR).
 
real3 chrono::collision::GetCenter_Sphere ()
 
real3 chrono::collision::GetCenter_Triangle (const real3 *t)
 
real3 chrono::collision::GetCenter_Box ()
 
real3 chrono::collision::GetCenter_Ellipsoid ()
 
real3 chrono::collision::GetCenter_Cylinder ()
 
real3 chrono::collision::GetCenter_Plane ()
 
real3 chrono::collision::GetCenter_Cone (const real3 &B)
 
real3 chrono::collision::GetCenter_Convex (const int size, const real3 *convex_data)
 
real3 chrono::collision::GetCenter_Tetrahedron (const uvec4 indices, const real3 *nodes)
 
real3 chrono::collision::SupportVertNoMargin (const chrono::collision::ConvexBase *Shape, const real3 &nv, const real &envelope)
 
real3 chrono::collision::LocalSupportVert (const chrono::collision::ConvexBase *Shape, const real3 &n, const real &envelope)
 
real3 chrono::collision::TransformSupportVert (const chrono::collision::ConvexBase *Shape, const real3 &n, const real &envelope)
 

Function Documentation

◆ box_closest_feature()

uint chrono::collision::box_closest_feature ( const real3 dir,
const real3 hdims 
)

This utility function returns a code that indicates the closest feature of a box in the specified direction.

The direction 'dir' is assumed to be given in the frame of the box. The return code encodes the box axes that define the closest feature:

  • first bit (least significant) corresponds to x-axis
  • second bit corresponds to y-axis
  • third bit corresponds to z-axis

Therefore: code = 0 indicates a degenerate direction (within a threshold) code = 1 or code = 2 or code = 4 indicates a face code = 3 or code = 5 or code = 6 indicates an edge code = 7 indicates a corner

◆ box_cylshell()

int chrono::collision::box_cylshell ( const real3 pos1,
const quaternion rot1,
const real3 hdims,
const real3 pos2,
const quaternion rot2,
const real &  radius,
const real &  hlen,
const real &  separation,
real3 norm,
real *  depth,
real3 pt1,
real3 pt2,
real *  eff_radius 
)

Analytical box vs. cylindrical shell collision function.

radius;

◆ box_intersects_box()

int chrono::collision::box_intersects_box ( const real3 hdims1,
const real3 hdims2,
const real3 pos,
const quaternion rot,
real  separation,
real3 dir 
)

This function returns an integer indicating whether or not a box1 with dimensions hdims1 intersects (or is close enough to) a second box with dimensions hdims2.

The check is performed in the local frame of box1. The transform from the other box is given through 'pos' and 'rot'.

The return value is -1 if the two boxes overlap, +1 if they are within a distance of 'separation' from each other, and 0 if they are "far" from each other. If returning -1 or +1, 'dir' contains the direction of smallest intersection (or closest separation).

This check is performed by testing 15 possible separating planes between the two boxes (Gottschalk, Lin, Manocha - Siggraph96).

If not considering a separation value, the 15 tests use an overlap of the form: overlap = r1 + r2 - D where r1 and r2 are the half-projections of the two boxes on the current direction and D is the projected distance between the box centers. If there's no overlap (overlap <= 0) in any direction, then the boxes do not intersect. Otherwise, we keep track of the direction of minimum overlap.

If considering a separation > 0, we simply use an overlap of the form: overlap = r1 + r2 - D + separation and use the exact same checks.

◆ get_edge_corners()

void chrono::collision::get_edge_corners ( const real3 pt_on_edge,
uint  code,
real3 corners 
)

This utility function fill out 'corners' with the corners of the box edge specified by 'code' and 'pt_on_edge'.

See box_closest_feature for definition of 'code.

◆ get_face_corners()

void chrono::collision::get_face_corners ( const real3 pt_on_face,
uint  code,
real3 corners 
)

This utility function fill out 'corners' with the corners of the face specified by 'code' and 'pt_on_face'.

See box_closest_feature for definition of 'code.

◆ get_face_normal()

real3 chrono::collision::get_face_normal ( const real3 pt_on_face,
uint  code 
)

This utility function returns the box face normal (expressed in the box local frame) for the face specified by 'code' and 'pt_on_face'.

See box_closest_feature for definition of 'code.

◆ point_vs_face()

bool chrono::collision::point_vs_face ( const real3 hdims,
const real3 pt_on_face,
uint  code,
const real3 point,
const real &  separation,
real3 result,
real3 normal,
real &  dist 
)

This utility function returns true if 'point' is no farther than 'separation' from the face of this box identified by 'pt_on_face' and 'code'; and returns false otherwise.

If the point is close enough, its projection onto the box face is returned in 'result' and the height of the point relative to the box face is returned in 'dist' (with a negative value indicating penetration, i.e. the point inside the box). 'normal' is set to the box face (pointing outwards). See box_closest_feature for definition of 'code.

◆ RCollision()

CH_MULTICORE_API bool chrono::collision::RCollision ( const ConvexBase shapeA,
const ConvexBase shapeB,
real  separation,
real3 ct_norm,
real3 ct_pt1,
real3 ct_pt2,
real *  ct_depth,
real *  ct_eff_rad,
int &  nC 
)

Dispatcher for analytic collision functions.

Parameters
shapeAfirst candidate shape
shapeBsecond candidate shape
separationmaximum separation
[out]ct_normcontact normal (per contact pair)
[out]ct_pt1point on shape1 (per contact pair)
[out]ct_pt2point on shape2 (per contact pair)
[out]ct_depthpenetration depth (per contact pair)
[out]ct_eff_radeffective contact radius (per contact pair)
[out]nCnumber of contacts found

◆ segment_vs_edge()

bool chrono::collision::segment_vs_edge ( const real3 hdims,
const real3 pt_on_edge,
uint  code,
const real3 pt1,
const real3 pt2,
real3 locE,
real3 locS 
)

This utility function calculates the closest points between the box edge identified by 'pt_on_edge' and 'code' and a line segment between 'pt1' and 'pt2'.

It returns true if the closest points are within the extent of the edge and the segment, respecively, and false otherwise. The closest points are returned in 'locE' and 'locS', respectively. This function uses the parametric solution of the two support lines to solve for the closest points, simplified as we work in the local frame of the box. See box_closest_feature for definition of 'code.

◆ snap_to_box()

uint chrono::collision::snap_to_box ( const real3 hdims,
real3 loc 
)

This utility function snaps the specified location to a point on a box with given half-dimensions.

The in/out location is assumed to be specified in the frame of the box (which is therefore assumed to be an AABB centered at the origin). The return code indicates the box axes that caused snapping.

  • first bit (least significant) corresponds to x-axis
  • second bit corresponds to y-axis
  • third bit corresponds to z-axis

Therefore: code = 0 indicates an interior point code = 1 or code = 2 or code = 4 indicates snapping to a face code = 3 or code = 5 or code = 6 indicates snapping to an edge code = 7 indicates snapping to a corner

◆ snap_to_box_edge()

real3 chrono::collision::snap_to_box_edge ( const real3 hdims,
const real3 pt_on_box,
uint  code,
const real3 pt_to_snap 
)

This utility function snaps the location 'pt_to_snap' to a location on the edge of this box identified by the specified 'code' and 'pt_on_box'.

The resulting location is returned. See box_closest_feature for definition of 'code.

◆ snap_to_box_face()

real3 chrono::collision::snap_to_box_face ( const real3 hdims,
const real3 pt_on_box,
uint  code,
const real3 pt_to_snap 
)

This utility function snaps the location 'pt_to_snap' to a location on the face of this box identified by the specified 'code' and 'pt_on_box'.

The resulting location is returned. See box_closest_feature for definition of 'code.

◆ snap_to_cylinder()

uint chrono::collision::snap_to_cylinder ( const real &  rad,
const real &  hlen,
real3 loc 
)

This utility function snaps the specified location to a point on a cylinder with given radius and half-length.

The in/out location is assumed to be specified in the frame of the cylinder (in this frame the cylinder is assumed to be centered at the origin and aligned with the Y axis). The return code indicates the feature of the cylinder that caused snapping. code = 0 indicates and interior point code = 1 indicates snapping to one of the cylinder caps code = 2 indicates snapping to the cylinder side code = 3 indicates snapping to one of the cylinder edges

◆ snap_to_triangle()

bool chrono::collision::snap_to_triangle ( const real3 A,
const real3 B,
const real3 C,
const real3 P,
real3 res 
)

This utility function takes the location 'P' and snaps it to the closest point on the triangular face with given vertices (A, B, and C).

The result is returned in 'res'. Both 'P' and 'res' are assumed to be specified in the same frame as the face vertices. This function returns 'true' if the result is on an edge of this face and 'false' if the result is inside the triangle. Code from Ericson, "Real-time collision detection", 2005, pp. 141

◆ triangle_normal()

real3 chrono::collision::triangle_normal ( const real3 A,
const real3 B,
const real3 C 
)

This utility function returns the normal to the triangular face defined by the vertices A, B, and C.

The face is assumed to be non-degenerate. Note that order of vertices is important!