| |
|
|
||||
![]() |
||||||
| |
|
|||||
|
An OBB-Line Segment Test Testing a box and a line segment for intersection requires checking only six separating axes: the box's three principal axes, and the vector cross products of these axes with l, the line direction. Again, the vectors used for these tests do not have to be normalized, and these tests can be simplified by transforming the line segment into the box’s coordinate frame. One application of this test is to see if a camera's line of sight is obscured. Testing every polygon in a scene could be prohibitively expensive, but if these polygons are stored in an AABB or an OBB tree, a box-segment test can quickly determine a potential set of polygons. A segment-polygon test can then be used to determine if any polygons in this subset are actually obscuring the line of sight.
The function in Listing 7 assumes the line segment has already been transformed to box space. Listing 7. #include "aabb.h" const
bool AABB_LineSegmentOverlap
const VECTOR& l, //line direction ) {
} OBB to AABB conversion Converting an OBB to an AABB merely involves calculating the extents of the OBB along the x, y, and z-axes of its parent frame. For example the extent of the OBB along the x-axis is
The extents along the y and z-axes are calculated similarly. |
|
|