Simbody
3.3
|
A 3d rectangular box aligned with an unspecified frame F and centered at that frame's origin. More...
#include <Geo.h>
Public Member Functions | |
Box_ () | |
Construct an uninitialized Box object; the dimensions will be garbage. More... | |
Box_ (const Vec3P &halfLengths) | |
Construct a Box with the given nonnegative half-dimensions. More... | |
Box_ & | setHalfLengths (const Vec3P &halfLengths) |
Change the half-dimensions of this box. More... | |
Box_ & | addToHalfLengths (const Vec3P &incr) |
Change the half-dimensions of this box by adding the given vector. More... | |
const Vec3P & | getHalfLengths () const |
Return the half-lengths of this box as a Vec3 from the center to the first quadrant vertex. More... | |
RealP | getOrderedHalfLength (int i) const |
Get lengths in order shortest to longest; 0 is shortest, 2 is longest. More... | |
CoordinateAxis | getOrderedAxis (int i) const |
Get axes in order shortest to longest; 0 is shortest, 2 is longest. More... | |
RealP | findVolume () const |
Calculate the volume of this box. More... | |
RealP | findArea () const |
Calculate the surface area of this box, ignoring degeneracy (meaning that all pairs of sides are counted even if coincident). More... | |
bool | containsPoint (const Vec3P &pt) const |
Given a point measured and expressed in the box frame, determine whether it is inside the box (we count touching the surface as inside). More... | |
RealP | findDistanceSqrToPoint (const Vec3P &pt) const |
Return the square of the distance from this box to a given point whose location is measured from and expressed in the box frame (at the box center). More... | |
RealP | findDistanceSqrToSphere (const Geo::Sphere_< P > &sphere) const |
Return the square of the distance from this box to a given sphere whose center location is measured from and expressed in the box frame (at the box center). More... | |
RealP | findDistanceSqrToAlignedBox (const Geo::AlignedBox_< P > &aab) const |
Return the square of the distance from this box to an axis-aligned box whose center location is measured from and expressed in this box frame (at the box center). More... | |
bool | intersectsSphere (const Geo::Sphere_< P > &sphere) const |
Given a sphere with center measured and expressed in the box frame, return true if the box and sphere intersect. More... | |
bool | intersectsAlignedBox (const Geo::AlignedBox_< P > &aab) const |
Given an aligned box with center measured and expressed in the from of this box, return true if the two boxes intersect. More... | |
bool | intersectsOrientedBox (const Geo::OrientedBox_< P > &ob) const |
Given an oriented box whose pose is measured and expressed in the frame of this box, return true if the two boxes intersect. More... | |
bool | mayIntersectOrientedBox (const Geo::OrientedBox_< P > &ob) const |
Given an oriented box whose pose is measured and expressed in the frame of this box, return true if the two boxes may be intersecting. More... | |
A 3d rectangular box aligned with an unspecified frame F and centered at that frame's origin.
The box has a local frame B, centered at the box center and oriented along the box edges, and B==F. We keep track of the relative edge lengths to facilitate short-to-long processing.
|
inline |
Construct an uninitialized Box object; the dimensions will be garbage.
|
inline |
Construct a Box with the given nonnegative half-dimensions.
Cost is 4 flops to sort the edges.
|
inline |
Change the half-dimensions of this box.
Dimensions must be nonnegative. Cost is 4 flops to sort the edges.
|
inline |
Change the half-dimensions of this box by adding the given vector.
The result must be nonnegative. Cost is 7 flops, including resorting the edges.
|
inline |
Return the half-lengths of this box as a Vec3 from the center to the first quadrant vertex.
|
inline |
Get lengths in order shortest to longest; 0 is shortest, 2 is longest.
|
inline |
Get axes in order shortest to longest; 0 is shortest, 2 is longest.
|
inline |
Calculate the volume of this box.
Cost is 4 flops.
|
inline |
Calculate the surface area of this box, ignoring degeneracy (meaning that all pairs of sides are counted even if coincident).
Cost is 6 flops.
|
inline |
Given a point measured and expressed in the box frame, determine whether it is inside the box (we count touching the surface as inside).
The point must be measured from the box center. Cost is about 5 flops.
|
inline |
Return the square of the distance from this box to a given point whose location is measured from and expressed in the box frame (at the box center).
If the point is on or inside the box the returned distance is zero. Cost is about 14 flops.
|
inline |
Return the square of the distance from this box to a given sphere whose center location is measured from and expressed in the box frame (at the box center).
If the sphere intersects the box the returned distance is zero. Cost is about 17 flops.
|
inline |
Return the square of the distance from this box to an axis-aligned box whose center location is measured from and expressed in this box frame (at the box center).
If the boxes intersect the returned distance is zero. Cost is about 17 flops.
|
inline |
Given a sphere with center measured and expressed in the box frame, return true if the box and sphere intersect.
We are treating both objects as solids, so we'll say yes even if one object completely contains the other. We also return true if they are just touching. Cost is about 8 flops.
|
inline |
Given an aligned box with center measured and expressed in the from of this box, return true if the two boxes intersect.
We are treating both objects as solids, so we'll say yes even if one box completely contains the other. We also return true if they are just touching. Cost is about 8 flops.
bool SimTK::Geo::Box_< P >::intersectsOrientedBox | ( | const Geo::OrientedBox_< P > & | ob | ) | const |
Given an oriented box whose pose is measured and expressed in the frame of this box, return true if the two boxes intersect.
We are treating both objects as solids, so we'll say yes even if one box completely contains the other. We also return true if they are just touching. This is an exact but fairly expensive test if the boxes are separated; if you don't mind some false positives, use mayIntersectOrientedBox() instead. Cost is about 200 flops worst case (when boxes are intersecting) although it can return false
in as few as 16 flops.
bool SimTK::Geo::Box_< P >::mayIntersectOrientedBox | ( | const Geo::OrientedBox_< P > & | ob | ) | const |
Given an oriented box whose pose is measured and expressed in the frame of this box, return true if the two boxes may be intersecting.
Only relatively cheap operations are performed at the expense of returning false positives sometimes (allegedly less than 10% of the time). If you need an exact determination, use intersectsOrientedBox(). Cost is about 75 flops worst case (when boxes appear to be intersecting) but can return false
in as few as 16 flops.