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...

## ◆ DistancePointToLine()

 ChApi btScalar chrono::collision::bt_utils::DistancePointToLine ( const btVector3 & lP, const btVector3 & lD, const btVector3 & 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 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
 hdims box half-dimensions loc point

## ◆ 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
 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 btVector3 & hdims, const btVector3 & c, const btVector3 & a, const btScalar hlen, const btScalar tol, btScalar & tMin, btScalar & 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 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
 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 btVector3 & hdims, const btVector3 & loc )

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

Parameters
 hdims box half-dimensions loc point

## ◆ ProjectPointOnLine()

 ChApi btVector3 chrono::collision::bt_utils::ProjectPointOnLine ( const btVector3 & lP, const btVector3 & lD, const btVector3 & 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 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
 hdims box half-dimensions loc point (in/out)