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::collision::bt_utils::DistancePointToLine | ( | const cbtVector3 & | lP, |
const cbtVector3 & | lD, | ||
const cbtVector3 & | P | ||
) |
Calculate distance from point to line.
- Parameters
-
lP point on line lD line direction (unit vector) P point
◆ FindClosestBoxFace()
ChApi int chrono::collision::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
-
hdims box half-dimensions loc point
◆ IntersectLinePlane()
ChApi bool chrono::collision::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
-
lP point on line lD line direction (unit vector) pP point on plane pN plane normal (unit vector) tol tolerance for orthogonality test t line parameter of intersection point
◆ IntersectSegmentBox()
ChApi bool chrono::collision::bt_utils::IntersectSegmentBox | ( | const cbtVector3 & | hdims, |
const cbtVector3 & | c, | ||
const cbtVector3 & | a, | ||
const cbtScalar | hlen, | ||
const cbtScalar | tol, | ||
cbtScalar & | tMin, | ||
cbtScalar & | tMax | ||
) |
- Parameters
-
hdims box half-dimensions c segment center point a segment direction (unit vector) hlen segment half-length tol tolerance for parallelism test tMin segment parameter of first intersection point tMax segment parameter of second intersection point
◆ IntersectSegmentCylinder()
ChApi bool chrono::collision::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
-
sC segment center point sD segment direction (unit vector) sH segment half-length cC cylinder axis center cD cylinder axis direction (unit vector) cH cylinder axis half-length (cylinder halh-height) cR cylinder radius tol tolerance for parallelism test tMin segment parameter of first intersection point tMax segment parameter of second intersection point
◆ PointInsideBox()
ChApi bool chrono::collision::bt_utils::PointInsideBox | ( | const cbtVector3 & | hdims, |
const cbtVector3 & | loc | ||
) |
Check if given point is inside box (point expressed in box frame).
- Parameters
-
hdims box half-dimensions loc point
◆ ProjectPointOnLine()
ChApi cbtVector3 chrono::collision::bt_utils::ProjectPointOnLine | ( | const cbtVector3 & | lP, |
const cbtVector3 & | lD, | ||
const cbtVector3 & | P | ||
) |
Project point onto line.
- Parameters
-
lP point on line lD line direction (unit vector) P point
◆ SnapPointToBox()
ChApi int chrono::collision::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
-
hdims box half-dimensions loc point (in/out)