chrono::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

cbtVector3 ProjectPointOnLine (const cbtVector3 &lP, const cbtVector3 &lD, const cbtVector3 &P)
 Project point onto line. More...
 
cbtScalar DistancePointToLine (const cbtVector3 &lP, const cbtVector3 &lD, const cbtVector3 &P)
 Calculate distance from point to line. More...
 
int SnapPointToBox (const cbtVector3 &hdims, cbtVector3 &loc)
 Snap the specified location to a point on a box with given half-dimensions. More...
 
bool PointInsideBox (const cbtVector3 &hdims, const cbtVector3 &loc)
 Check if given point is inside box (point expressed in box frame). More...
 
int FindClosestBoxFace (const cbtVector3 &hdims, const cbtVector3 &loc)
 Find the closest box face to the given point (expressed in box frame). More...
 
bool IntersectSegmentBox (const cbtVector3 &hdims, const cbtVector3 &c, const cbtVector3 &a, const cbtScalar hlen, const cbtScalar tol, cbtScalar &tMin, cbtScalar &tMax)
 
bool IntersectLinePlane (const cbtVector3 &lP, const cbtVector3 &lD, const cbtVector3 &pP, const cbtVector3 &pN, const cbtScalar tol, cbtScalar &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 cbtVector3 &sC, const cbtVector3 &sD, const cbtScalar sH, const cbtVector3 &cC, const cbtVector3 &cD, const cbtScalar cH, const cbtScalar cR, const cbtScalar tol, cbtScalar &tMin, cbtScalar &tMax)
 Utility function to intersect a segment with a cylinder. More...
 

Function Documentation

◆ DistancePointToLine()

ChApi cbtScalar chrono::bt_utils::DistancePointToLine ( const cbtVector3 &  lP,
const cbtVector3 &  lD,
const cbtVector3 &  P 
)

Calculate distance from point to line.

Parameters
lPpoint on line
lDline direction (unit vector)
Ppoint

◆ FindClosestBoxFace()

ChApi int chrono::bt_utils::FindClosestBoxFace ( const cbtVector3 &  hdims,
const cbtVector3 &  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::bt_utils::IntersectLinePlane ( const cbtVector3 &  lP,
const cbtVector3 &  lD,
const cbtVector3 &  pP,
const cbtVector3 &  pN,
const cbtScalar  tol,
cbtScalar &  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::bt_utils::IntersectSegmentBox ( const cbtVector3 &  hdims,
const cbtVector3 &  c,
const cbtVector3 &  a,
const cbtScalar  hlen,
const cbtScalar  tol,
cbtScalar &  tMin,
cbtScalar &  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::bt_utils::IntersectSegmentCylinder ( const cbtVector3 &  sC,
const cbtVector3 &  sD,
const cbtScalar  sH,
const cbtVector3 &  cC,
const cbtVector3 &  cD,
const cbtScalar  cH,
const cbtScalar  cR,
const cbtScalar  tol,
cbtScalar &  tMin,
cbtScalar &  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::bt_utils::PointInsideBox ( const cbtVector3 &  hdims,
const cbtVector3 &  loc 
)

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

Parameters
hdimsbox half-dimensions
locpoint

◆ ProjectPointOnLine()

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

Project point onto line.

Parameters
lPpoint on line
lDline direction (unit vector)
Ppoint

◆ SnapPointToBox()

ChApi int chrono::bt_utils::SnapPointToBox ( const cbtVector3 &  hdims,
cbtVector3 &  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)