A "pure" separating axis approach is not applicable here, since you can
not restrict the potential separating axes to the face orientations and
cross products of edge directions, as with polytopes.
You solve this problem by computing the (squared) distance of the line
segment and the box. (If the distance is greater than the capsules
radius, the objects do not intersect.) The witness points of the
distance, i.e. the closest points, construct a separating axis (or
conincide in case of an intersection).
You can use GJK for computing the distance between a line segment and a
box (my favorite hammer). However, in this case an explicit
"construction" of the Minkowski sum of the line segment and the box
might be faster (although I'd doubt it). Simply, construct all the
supporting planes (a x + b y + c z + d = 0, normal n = (a, b, c)^T
pointing outward) of faces of the Minkowski sum. These are
(a) Faces of the box offset by Max(dot(n, p), dot(n, q)) where p and q
are endpoints of the line segment. 6 in total.
(b) Cross products of the direction (p - q) and the box's principle axes
offset by the vertices. Also 6 in total.
See a pattern? These correspond with the potential separating axes in
the separating axes method. Each axis results in two parallel planes.
Next, find the closest point to the origin of the rhombic dodecahedron
formed by these 12 planes. Planes for which the origin lies on the
negative side (plane offset d is negative) are immediately discarded.
So, now are left with at most 6 planes. Select the furthest plane (the
plane for which d is the largest, if we normalized all normals). Compute
the closest point on this plane and check whether it lies inside all
other halfspaces. If it does, then this is your closest point. If not,
then compute the line of intersection of the furthest plane and the
violating plane, and compute the closest point on this line. Perform the
same check for the remaining (at most 4) faces, and compute the point of
intersection of the line and the violating plane if one exists.
There you have it. The closest point is your separating axis, and its
distance to the origin is the distance between the line segment and the
box.
As said, I would not put my money on this routine being faster than GJK
for the general case, but at least it can be parallelized a little
easier.
Gino van den Bergen
www.dtecta.com
-----Original Message-----
From: Andy Sloane [mailto:***@guildsoftware.com]
Sent: Thursday, April 15, 2004 22:48
To: gdalgorithms-***@lists.sourceforge.net
Subject: Re: [Algorithms] Capsule-OBB separating axes
Post by Per VognsenNot quite. Unfortunately this doesn't even work for testing a sphere
(the degenerate case of a capsule) against a box. Consider the
two-dimensional case, for the sake of simplicity.
Duh! Thank you, I was being naive.
Post by Per VognsenExercise: Generalize the above enumeration of separating axes for the
box-sphere case to the more general box-capsule case. :)
Hmm.. So the separating axes for the degenerate case (sphere) would be:
3 - three box axes
8 - (each vertex of box) - (sphere center)
12 - perpendicular to each edge toward sphere center
except you'd only really need to consider the nearest vertex or the
nearest edge, depending on the location of the sphere. Hmm.
Ugh! Ok, so in general we have:
3 - the three box axes
3 - (three box axes) x (line segment axis)
16 - (each vertex of the line segment) - (each vertex of box)
24 - perpendicular to each edge toward each vertex of the line segment
That's awful! "Pure" separating axis is probably not what I want here,
eh?
So, what about this:
We use a quick box-sphere intersection test, by transforming the
endpoints
of the linesegment defining the capsule into box space and using, for
instance, "A Simple Method for Box-Sphere Intersection Testing" by Jim
Avro
(Graphics Gems).
Then, once we've determined that the spheres defining the ends of the
capsule are not intersecting, the only remaining feature is the
'extrusion'
of the line segment, and then we only need to check the 6 line segment
axes... or am I missing something yet again?
-Andy
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
GDAlgorithms-list mailing list
GDAlgorithms-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=6188