Graphics Reference
In-Depth Information
0
k 0 , k 1 , k 2
1, the radius r of the OBB is instead obtained by r
=
(
|
v 0
·
n
| +
|
)/2. For an axis-aligned box B , the local axes u 0 , u 1 , and u 2 are known
in advance, and thus the code can be simplified accordingly.
v 1 ·
n
| + |
v 2 ·
n
|
// Test if AABB b intersects plane p
int TestAABBPlane(AABB b, Plane p)
{
// These two lines not necessary with a (center, extents) AABB representation
Point c = (b.max + b.min) * 0.5f;
// Compute AABB center
Point e = b.max - c;
// Compute positive extents
// Compute the projection interval radius of b onto L(t) = b.c+t*p.n
float r = e[0]*Abs(p.n[0]) + e[1]*Abs(p.n[1]) + e[2]*Abs(p.n[2]);
// Compute distance of box center from plane
float s = Dot(p.n, c) - p.d;
// Intersection occurs when distance s falls within [-r,+r] interval
return Abs(s) <= r;
}
This test is equivalent to finding an AABB vertex most distant along the plane
normal and making sure that vertex and the vertex diagonally opposite lie on opposite
sides of the plane.
5.2.4 Testing Cone Against Plane
Let a plane be given by ( n
n for a point P on the plane and n
is unit. Let a cone be specified by its tip T , normalized axis direction d , height h , and
a bottom radius r (Figure 5.17). The cone is intersecting the negative halfspace of the
plane if any point of the cone lies inside the negative halfspace; that is, if there is a
point X of the cone for which ( n
·
X )
=
d , where d
=−
P
·
·
X )
<
d . For a cone only two points must be tested
for this condition.
The tip T of the cone
The point Q on the circular endcap of the cone, farthest in the direction of
n
For the second test, Q must be located. Thanks to the format the cone is given in, Q
is easily obtained by stepping from the tip along the direction vector to the circular
bottom endcap and down the endcap toward the plane:
Q
=
T
+
h v
+
r m .
 
Search WWH ::




Custom Search