Graphics Reference
In-Depth Information
// for a point gives the signed distance of the point to the plane
float dist = Dot(s.c, p.n) - p.d;
// If sphere center within +/-radius from plane, plane intersects sphere
return Abs(dist) <= s.r;
}
To determine if the sphere lies fully behind (inside the negative halfspace of)
plane
π
, the test changes to:
// Determine whether sphere s is fully behind (inside negative halfspace of) plane p
int InsideSpherePlane(Sphere s, Plane p)
{
float dist = Dot(s.c, p.n) - p.d;
return dist < -s.r;
}
If instead the negative halfspace of the plane is to be considered solid for the test
with the sphere, the test changes to:
// Determine whether sphere s intersects negative halfspace of plane p
int TestSphereHalfspace(Sphere s, Plane p)
{
float dist = Dot(s.c, p.n) - p.d;
return dist <= s.r;
}
5.2.3 Testing Box Against Plane
Let a plane P be given by ( n
d . Testing if a box B intersects P can also be
accomplished with the separating-axis test. Here, only the axis parallel to the plane
normal n need be tested. Because the plane extends indefinitely, there are no edges
with which to form edge-edge axis combinations. Axes corresponding to the face
normals of the box can be eliminated from testing because the infinite extent of the
plane means the plane will never sit fully outside one of the box faces unless it is
parallel to the face, a case already handled by the plane normal axis.
Consider first the case of B being an OBB, given by the usual representation of
a center C ; local coordinate axes u 0 , u 1 , and u 2 ; and three scalars e 0 , e 1 , and e 2
(making the OBB sides 2 e i wide for 0
·
X )
=
i
2). Points R in the OBB are given by
=
±
±
±
|
| ≤
R
C
a 0 u 0
a 1 u 1
a 2 u 2 , where
a i
e i . Similarly, the eight vertices V i ,
=
±
±
±
0
i
7, of the OBB are given by V i
C
e 0 u 0
e 1 u 1
e 2 u 2 .
 
Search WWH ::




Custom Search