chrono::collision::bt_utils Namespace Reference

Description

Utilities for Bullet-based collision detection.

Classes

class  ChConvexHullLibraryWrapper
 Wrapper for using and exporting the Bullet implementation of the convex hull library. More...
 

Functions

btVector3 ProjectPointOnLine (const btVector3 &lP, const btVector3 &lD, const btVector3 &P)
 Project point onto line. More...
 
btScalar DistancePointToLine (const btVector3 &lP, const btVector3 &lD, const btVector3 &P)
 Calculate distance from point to line. More...
 
int SnapPointToBox (const btVector3 &hdims, btVector3 &loc)
 Snap the specified location to a point on a box with given half-dimensions. More...
 
bool PointInsideBox (const btVector3 &hdims, const btVector3 &loc)
 Check if given point is inside box (point expressed in box frame). More...
 
int FindClosestBoxFace (const btVector3 &hdims, const btVector3 &loc)
 Find the closest box face to the given point (expressed in box frame). More...
 
bool IntersectSegmentBox (const btVector3 &hdims, const btVector3 &c, const btVector3 &a, const btScalar hlen, const btScalar tol, btScalar &tMin, btScalar &tMax)
 
bool IntersectLinePlane (const btVector3 &lP, const btVector3 &lD, const btVector3 &pP, const btVector3 &pN, const btScalar tol, btScalar &t)
 Utility function to intersect a line with a plane Plane equation: pN.X = pN.pP Line equation: X = lP + t * lD Solution: t = pN. More...
 
bool IntersectSegmentCylinder (const btVector3 &sC, const btVector3 &sD, const btScalar sH, const btVector3 &cC, const btVector3 &cD, const btScalar cH, const btScalar cR, const btScalar tol, btScalar &tMin, btScalar &tMax)
 Utility function to intersect a segment with a cylinder. More...
 

Function Documentation

◆ DistancePointToLine()

ChApi btScalar chrono::collision::bt_utils::DistancePointToLine ( const btVector3 &  lP,
const btVector3 &  lD,
const btVector3 &  P 
)

Calculate distance from point to line.

Parameters
lPpoint on line
lDline direction (unit vector)
Ppoint

◆ FindClosestBoxFace()

ChApi int chrono::collision::bt_utils::FindClosestBoxFace ( const btVector3 &  hdims,
const btVector3 &  loc 
)

Find the closest box face to the given point (expressed in box frame).

Returns +1, +2, +3 (for a "positive" face in x, y, z, respectively) or -1, -2, -3 (for a "negative" face).

Parameters
hdimsbox half-dimensions
locpoint

◆ IntersectLinePlane()

ChApi bool chrono::collision::bt_utils::IntersectLinePlane ( const btVector3 &  lP,
const btVector3 &  lD,
const btVector3 &  pP,
const btVector3 &  pN,
const btScalar  tol,
btScalar &  t 
)

Utility function to intersect a line with a plane Plane equation: pN.X = pN.pP Line equation: X = lP + t * lD Solution: t = pN.

(pP-lP) / pN.lD

Parameters
lPpoint on line
lDline direction (unit vector)
pPpoint on plane
pNplane normal (unit vector)
toltolerance for orthogonality test
tline parameter of intersection point

◆ IntersectSegmentBox()

ChApi bool chrono::collision::bt_utils::IntersectSegmentBox ( const btVector3 &  hdims,
const btVector3 &  c,
const btVector3 &  a,
const btScalar  hlen,
const btScalar  tol,
btScalar &  tMin,
btScalar &  tMax 
)
Parameters
hdimsbox half-dimensions
csegment center point
asegment direction (unit vector)
hlensegment half-length
toltolerance for parallelism test
tMinsegment parameter of first intersection point
tMaxsegment parameter of second intersection point

◆ IntersectSegmentCylinder()

ChApi bool chrono::collision::bt_utils::IntersectSegmentCylinder ( const btVector3 &  sC,
const btVector3 &  sD,
const btScalar  sH,
const btVector3 &  cC,
const btVector3 &  cD,
const btScalar  cH,
const btScalar  cR,
const btScalar  tol,
btScalar &  tMin,
btScalar &  tMax 
)

Utility function to intersect a segment with a cylinder.

Segment assumed to be parameterized as sP = sC + t * sD, with -sH <= t <= sH. Cylinder given by its center cC, axis direction cD, halh-lengh cH, and radius cR. Assume |sD| = |cD| = 1. (1) Find tMin and tMax where the segment supporting line intersects cylindrical surface by finding points on segment at a distance cR from the cylinder axis line. (2) Clamp result to cylinder end-caps. (3) Clamp result to segment length.

Parameters
sCsegment center point
sDsegment direction (unit vector)
sHsegment half-length
cCcylinder axis center
cDcylinder axis direction (unit vector)
cHcylinder axis half-length (cylinder halh-height)
cRcylinder radius
toltolerance for parallelism test
tMinsegment parameter of first intersection point
tMaxsegment parameter of second intersection point

◆ PointInsideBox()

ChApi bool chrono::collision::bt_utils::PointInsideBox ( const btVector3 &  hdims,
const btVector3 &  loc 
)

Check if given point is inside box (point expressed in box frame).

Parameters
hdimsbox half-dimensions
locpoint

◆ ProjectPointOnLine()

ChApi btVector3 chrono::collision::bt_utils::ProjectPointOnLine ( const btVector3 &  lP,
const btVector3 &  lD,
const btVector3 &  P 
)

Project point onto line.

Parameters
lPpoint on line
lDline direction (unit vector)
Ppoint

◆ SnapPointToBox()

ChApi int chrono::collision::bt_utils::SnapPointToBox ( const btVector3 &  hdims,
btVector3 &  loc 
)

Snap 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

Parameters
hdimsbox half-dimensions
locpoint (in/out)