450 Chapter 10 Distance in 3D
Ray and Tetrahedron
Use the line-tetrahedron algorithm for computing the closest line points with param-
eters I =[t
min
, t
max
](with possibly t
min
=t
max
). Define J =I ∩[0, ∞).IfJ =∅, the
ray-tetrahedron distance is the same as the line-tetrahedron distance. The closest ray
points are determined by J .IfJ =∅, the ray origin P is closest to the tetrahedron.
Segment and Tetrahedron
Use the line-tetrahedron algorithm for computing the closest line points with pa-
rameters [t
min
, t
max
] (with possibly t
min
= t
max
). Define J =I ∩ [0, T ]. If J =∅, the
segment-tetrahedron distance is the same as the line-tetrahedron distance. The clos-
est segment points are determined by J .IfJ =∅, the closest segment point is P when
t
max
< 0orP + T
ˆ
d when t
min
>T.
10.9.4 Linear Component to Oriented Bounding Box
In this section we discuss the problem of computing the distance between a linear
component and an oriented bounding box (OBB). A linear component is defined as
a base point and a direction vector:
L(t) = P + t
d
An OBB is defined as a centerpoint C; three orthonormal orientation vectors ˆu, ˆv,
and ˆw; and three half-extents h
u
, h
v
, and h
w
, as shown in Figure 10.46.
The naive approach would compute the squared distance between the line and
each of the six faces and take the minimum of these; however, this would be quite
expensive because of the arbitrary orientation of the faces and also would fail to
exploit the fact that each face is parallel or orthogonal to every other face.
The approach we take here is analogous to that taken for the problem of comput-
ing the distance of a point to an OBB, as described in Section 10.4.2.
The OBB’s centerpoint C and ˆu, ˆv, and ˆw define a frame. Observe that, relative
to that frame, the OBB is an axis-aligned box centered at the origin, whose sides are
each parallel to either the x-, y-, or z-axis. If we transform the line {P ,
d} into this
frame, then we can exploit this axis-aligned, origin-centered nature of the OBB and
compute the closest point, and the distance to it, more efficiently.
Given the OBB’s center C and ˆu, ˆv, and ˆw, a point P ’s coordinates in that frame
can be computed as
P
=
[
(P − C) ·ˆu(P− C) ·ˆv(P− C) ·ˆw
]