i
i
i
i
i
i
i
i
16.3. Bounding Volume Creation 733
these three pairs of vertices, find the pair with the largest distance between
them. Use this pair to form a sphere with its center at the midpoint
between them and a radius equal to the distance to them. Go through all
the other vertices and check their distance d to the center of the sphere. If
the vertex is outside the sphere’s radius r, move the sphere’s center toward
the vertex by (d − r)/2, set the radius to (d + r)/2, and continue. This
step has the effect of enclosing the vertex and the existing sphere in a new
sphere. After this second time through the list, the bounding sphere is
guaranteed to enclose all vertices. Code is available on the web.
Welzl [1339] presents a more complex algorithm, which is implemented
by Eberly [294, 1131] and Ericson [315], with code on the web. This algo-
rithm is expected to be linear for a randomized list of vertices (random-
ization helps find a good sphere quickly on average). The idea is to find a
supporting set of points defining a sphere. A sphere can be defined by a
set of two, three, or four points on its surface. When a vertex is found to
be outside the current sphere, its location is added to the supporting set
(and possibly old support vertices removed from the set), the new sphere
is computed, and the entire list is run through again. This process repeats
until the sphere contains all vertices. While more complex than the previ-
ous methods, this algorithm guarantees that an optimal bounding sphere
is found.
OBB Creation
OBB formation, with its arbitrary basis orientation, is even more involved
than finding a reasonable bounding sphere. One method by Gottschalk [434]
will be presented, followed by a brief explanation of another method by
Eberly [294].
It has been shown that a tight-fitting OBB enclosing an object can
be found by computing an orientation from the triangles of the convex
hull [433, 434]. The convex hull is used because it avoids using points in
the interior of the object that should not affect the orientation of the box.
Also, an integration is performed over each triangle of the convex hull. This
is done since using the vertices of the convex hull can make for bad-fitting
boxes, if, for example, several vertices clump in a small region. Here, we
will present the formulae for computing a good-fit OBB using a statistical
method. The derivation is found in Gottschalk’s Ph.D. thesis [434].
First, the convex hull of an object must be computed. This can be
done with, for example, the Quickhull algorithm [62]. This gives us, say,
n triangles defined as p
k
q
k
r
k
,wherep
k
, q
k
,andr
k
are the vertices of
triangle k,0≤ k<n. We also denote the area of triangle k as a
k
,andthe
total area of the convex hull as a
H
=
n−1
k=0
a
k
. Furthermore, the centroid
of triangle i is m
i
=(p
i
+ q
i
+ r
i
)/3, that is, the mean of the vertices.
The centroid of the whole convex hull, m
H
, is the weighted mean of the