An Algebraic Solution to the Problem of Collision Detection

Proceedings of the 2000 IEEE
International Conference on Robotics & Automation
San Francisco, CA • April 2000
An Algebraic Solution to the Problem of Collision Detection for
Rigid Polyhedral Objects
S. R e d o n
INRIA - Rocquencourt*
s t e p h a n e , r e d o n @inria. f r
A. K h e d d a r
CEMIF-SC
Universit~ d ' E v r y - France
Abstract
This paper describes a new collision detection algorithm designed for interactive manipulation in virtual
environments. Making some assumptions on objects
motion, the collision time between two objects can be
computed by solving a polynomial equation whose degree is equal to or smaller than three.
1
Introduction
The problem of Collision Detection (CD) is to report
a contact between objects when it has already occured
(discrete methods) or when it is to occur (continuous methods). This problem is encountered in various
fields, such as robotics (motion planning), computer
graphics and virtual environments.
In most of the applications, a discrete solution is
enough: the collision response depends on the objects
interpenetration. In some of them, however, for which
a precise knowledge of the objects interaction is required (in order, for example, to compute precise constraints on the objects motion), a continuous CD algorithm is necessary. This paper describes a simple algebraic continuous m e t h o d designed for rigid objects.
The term algebraic means here that an explicit formulation of the collision time can be computed, avoiding
problems inherent to numerical approaches.
1.1
Previous work
Compared to discrete methods, the number of continuous methods is relatively small. Assuming constant angular velocity, Canny [2] succeeded to compute the first instant of collision between rigid polyhedral objects by numerically finding roots of loworder polynomials. This was extended to arbitrary
*Contact address : I N R I A - R O C Q U E N C O U R T de Voluceau - 78153 Le C h e s n a y - F R A N C E
0-7803-5886-4•00•510.00©
Domaine
2 0 0 0 IEEE
S. C o q u i l l a r t
INRIA - Rocquencourt
trajectories by Gilbert and Hong [4] by using an iterative numerical method. Von Herzen, Barr and Zatz
[6] described a technique for detecting collisions between parametrically defined time-dependant curved
surfaces. Cameron [1] described a four-dimensional
(space and time) intersection testing for two moving
objects and, more recently, Cheng [3] presented a realtime continuous colhsion detection m e t h o d for their
proprietary industrial robot manipulator. All of these
methods need numerical techniques in order to compute collision times. This paper introduces a class of
arbitrary in-between motions that permits to compute
the first collision time between polyhedral objects by
solving a polynomial equation whose degree is at most
three.
1.2
Interpolating object positions
The main problem of continuous collision detection
methods is that the objects real motion (between key
positions) may not bet explicitly defined and, if well
defined, then it may be too complex to efficiently (ie
not numerically) compute the collision times.
However, given an initial and a final position for an
object, an arbitrary in-between motion can be used to
replace the real one. Provided the initial and final positions are close to each other, the difference between
the arbitrary motion and the real one will have no noticeable importance (close and noticeable importance
depending on the application)1.
Now, let A0 be a rigid object at time 0 and A1 the
same object at time 1. It is well known that there
exists a screwing V(w, s, O, if), where w is the rotation
angle, s the translation amount, and (O, if) the axis,
such as ]~(A0) = A1.
In order to use screwings in continuous methods, it is
1In a real-time application, for example, the in-betweening
can be calculated for each pair of consecutive frames, since it
w o n ' t be visible. Object positions at each frame are t h u s considered as key positions.
3733
enough to define two functions a, b: 11~2 × [0, 1] ~ R
such as, for every pair (w, s) in 1~2, the functions:
a.~,s :
[0,1]
t ~ w' = a(w, s, t)
b.~,~ :
{
[0,1] ~ ] R
t ~ s' = b(~J, s, t)
are C 1, increasing, and such as a,~,s(0) = b,~,s(0) = 0
and a,~,~(1) = w and b~,~(1) = s.
For a given screwing, this defines a class of continuous in-between screwing-based motions, whose general
form is:
~x
X
a
! i-.
b
c
Figure 1: Three possible configurations when A = 0.
[ (t, A)
A' = Y(a.,,~(t),b,~,~(t),O, ff)(A)
where A is the object at time 0 and A' the object
during the in-between motion.
In the following, a is given the simplest form, whereas
b remains somewhat free: a(w, s, t) = wt , b(w, s, t) =
sf(t), where f is C 1, increasing, and such as f(O) = 0
and f ( 1 ) = 1.
The in-between motion used in this paper is thus:
.M: {
(t,A)~
[A
0t'l] × ]1~3--~ I[~3
= V(~t, sf(t), O, ~)(A)
(1)
and the problem now consists in finding a function
f simple enough to be able to compute instants of
collision explicitly.
1.3
The scene
In the following, the objects are assumed to be polyhedral. It should be clear (see Section 4) that the CD
problem is thus reduced to two sub-problems: collision detection between two edges, and collision detection between a vertex and a planar polygon. The first
sub-problem is adressed in Section 2, and CD between
a vertex and a triangle is described in Section 3 and
extended to polygons in Section 4.
one is static, and that the in-between motion of the
first edge is .A4, given by Equation 1.
Let [a, a + u] be the first edge and [c, c + v] the second
one, where a, c, u and v are 3D vectors. The vertex
a + .Xu, where /k is within [0, 1], describes the first
edge. In the same way, the vertex c -4- #v, where # is
within [0, 1], describes the second one. The problem
of collision detection between two edges can thus be
stated in the following way: it consists in finding the
first time t in [0, 1] for which there exists (.X,#) within
[0, 112 such as .A4(t, a + )~u) = c + #v (2.1).
2.2
Solving the system
Let's recall the given information of the problem. The
screwing is characterized by the rotation angle w and
the translation amount s. While there are no restrictions on s, the angle w must be in the interval ] - r r , 7r[.
Equation 2.1 is solved in the screwing frame (O, i, j, k),
where k is the translation direction. In this frame,
Equation 2.1 becomes:
{ (ax + AUx)COSWt- (% + Auy) sinwt = c~ + # v ~
(ax +/Xuz) sinwt + (% + ~uy) cos~vt = % + #vy
az + ,Xu~ + sf(t) = cz + #vz
(2)
solved according to the values of ( w, s).
2
2.1
Collision
edges
detection
between
two
Introduction
Collision detection between two edges is the first kind
of elementary detection. It must be computed, and
can't be deduced from other detections, as it will be
done in Section 4 for two faces, for example.
Because one can always consider the relative motion
between the two edges, it is assumed that the second
2.2.1
N o m o t i o n : (w,s) = (0,0)
Within the main algorithm, it is assumed that the
detection collision function isn't used when the two
edges are in contact at the beginning of the motion.
Therefore, there won't be any collision during the inbetween motion.
2.2.2
T r a n s l a t i o n : w = 0, s # 0
Because there are no trigonometric functions, the
function f is given the simplest form: f(t) = t,
3734
¸¸¸
a
b
c
Figure 3: Planar problem in the case of a rotation.
Figure 2: Three possible cases for a rotation.
Let's detail the first two sub-problems:
and the system is solved according to the value of
A = U~Vx - u~vy, determinant of the first and the
second equations.
If A ~ 0, the single potential collision time between
the lines supporting the edges is t -- (c~ - a~ + #v~ )~u~)/s. If 0 < t < 1, and if, at this time, the contact
is located on the edges, then a collision is reported.
If A --- 0, then the projections of u and v on the plane
x O y can be parallel or null, as shown in Figure 1.
For each case, one first checks whether the projections
are merged and, if need be, the collision time(s) between the characteristic points of the edges is (are)
computed.
2.2.3
Rotation: w ~ 0 ,
s=0
The system is solved according to the values of uz and
vz, the z - c o o r d i n a t e s of u and v, which leads to three
kinds of sub-problems:
• u~ = v~ = 0: the edges are in planes parallel
to x O y (Figure 2.a). If a~ ~ cz, the planes are
distinct and there won't be any collision. If az =
c~, the problem is reduced to a planar problem
(detailed further).
• uz ¢ 0 and vz = 0: a single point of the line supporting the first edge m a y collide the second line
( )~ = ( c~ - a~ ) / u~ is uniquely determined)(Figure
2.b). T h e problem is reduced to detect a collision
between a point and an edge (which is detailed
further, too).
• u~ = 0 and v~ ~ 0: santo problem as the precedent one. This time, # = (az - cz)/v~ is uniquely
determined (Figure 2.b).
• uz ~ 0 and v~ ~ 0 (Figure 2.c): the problem c a n ' t
be simplified and the general m e t h o d is used, with
s---0.
3735
. Planar problem: Figure 3 clearly shows that it
is enough to detect a collision between the extremities of each edge with the other edge, since
the edges are not in contact at the beginning of
the motion. This problem is thus reduced to four
problems of the second kind.
. Collision between a vertex and an edge: this problem consists in finding the intersection points of
a circle (trajectory of the vertex) and an edge.
Thus, there are at most two collision instants.
2.2.4
General method
T h e general m e t h o d is used when w ~ 0 and s ~ 0,
or in the case of a rotation when the problem can't be
simplified. T h e function f is now chosen to solve the
system.
Using the well known parametrizations of the sine and
cosine functions:
1 -- 72
7- = t a n ( w t / 2 ) ,
coswt -- 1 + T2' s i n ~ t
27
1 + 72
(3)
and setting f ( t ) = t a n ( w t / 2 ) / t a n ( w / 2 ) (w is within
]-Tr, ~'[), system 2 becomes:
(a=+
~Jl+~-~ + ( a ~ +
yJl+~= = c y + t L v y
az + AUz + s tan~w/2) -- Cz • ]AVz
(4)
T h e function f is derivable, strictly increasing on [0, 1]
and f(0) = 0 and f ( 1 ) = 1. Here again, the system is
solved according to the values of uz and vz. Yet, it is
necessary to define f now, making it depend only on
the screwing p a r a m e t e r s w and s, in order to keep the
same solving methods (and, thus, the same motion),
for each element of an object moving according to a
given screwing 2.
The three possible configurations are the following:
•
=
vz
=
0:
it is a planar problem. Indeed, the sole potential collision time is given by
T = t a n ( w t / 2 ) = (c~ -- az)' ~..e_e!_~2_~.l
~
(if the general
method is used and uz = Vz = 0, then s # 0).
One then checks whether the two edges are in
contact at this time.
u~
• Vz # 0: then # = (az - c~ + Nut + S t ~ n ~ / 2 ) ) / v z.
Using this in the first two equations, and multiplying them by (1 + r2), one gets a system which
can be written as:
d
~a
x
Figure 4: The equivalent planar problem when the
supporting plane is vertical.
3
{)~A1 (7) = B1 (T)
AA2(7) = B 2 ( T )
• Uz 5¢ 0: then A = (Cz - az + # v . - St~n@~/2))/u z.
As before, this leads to a polynomial equation
whose degree is at most three.
2Finally, t h e f u n c t i o n f h a s t h e following form:
t
if w = O
else
~
tan(w/2)
3.1
a vertex
Introduction
Collision detection between a vertex and a face is the
second and last kind of elementary detection. The face
is a triangle.
Here again, one considers the relative motion between
the vertex and the triangle. It is thus assumed that
the triangle is static, and that the in-between motion
of the vertex is .Ad, given by Equation 1.
Let a be the vertex and T the triangle, where a is a 3D
vector. The problem of collision detection between a
vertex and a triangle can thus be stated in the following way: it consists in finding the first time t in [0, 1]
for which .A4 (t, a) c T.
3.2
It is i m p o r t a n t to n o t e t h a t t h e form of f d e p e n d s only on
aJ, a n d n o t on t h e p o s i t i o n of t h e edges. T h u s , all t h e edges of
a n object have t h e s a m e m o t i o n . Note, however, t h a t t h e s a m e
form will have to be used to d e t e c t a collision b e t w e e n a v e r t e x
a n d an edge, even if a s i m p l e r f u n c t i o n would have been e n o u g h
to solve t h e s y s t e m since, again, t h e m o t i o n of a n object p a r t s
m u s t n o t d e p e n d on t h e n a t u r e or t h e p o s i t i o n of t h e s e parts.
It is t r u e t h a t t h e form of f is q u i t e arbitrary. However,
t h i s form p e r m i t s to solve efficiently a s y s t e m t h a t r e s p e c t s t h e
initial a n d final c o n d i t i o n s of t h e m o t i o n . Moreover, for s m a l l
m o t i o n s , a n d t h u s for s m a l l values of w:
tan(cot/2)
tan(at/2)
between
(5)
where As and Bi are polynomials in r. Eliminating A then gives a polynomial equation in T
whose degree is at most three (after reduction,
the fourth-degree term is nil). This equation is
solved using Cardan's formulas. For each real
root Ti, one must checks whether the two edges
are in contact a.
f(t) =
Collision detection
and a triangle
Solving the system
In the screwing frame, the coordinates of the vertex
a are (az cosczt - ay sinwt, ax sinwt + ay c o s o g t , az -4sf(t)).
Ifpx+qy+rz
= d is an equation of the plane supporting T, then the problem is to find the smallest real t
in [0, 1] for which:
(pax + q a y ) c o s w t + ( q a x - P a u )
s i n w t + r ( a z + s f (t ) ) = d
(6)
_t
As before, the system is solved according to the values
of w and s.
a n d t h e t r a n s l a t i o n is d o n e at a n e a r l y c o n s t a n t speed, which
a l m o s t m a k e s .3.4 a classical s c r e w i n g (which is q u i t e a r b i t r a r y
as well).
3 O n e m u s t also check if Al(ri) or A2(Ti) is non-nil. If
Ai(Ti) = A2(Ti) = 0, t h e r e are two possibilities d e p e n d i n g on
w h e t h e r Bi(Ti) and B2(ri) are nil or not. Geometrically, t h e
nullity c o r r e s p o n d s to a p a r t i a l o v e r l a p p i n g of t h e two edges.
3736
3.2.1
N o m o t i o n : ( w , s ) = (0,0)
As for two edges, there can't be any collisions between
instants 0 and 1.
3.2.2
T r a n s l a t i o n : w = 0, s # 0
e
a
a
The function f has already been set: f ( t ) = t on [0, 1],
and Equation 6 becomes p a x + q a v + r ( a z + s t ) : d,
whose solution depends on r.
e
• If r = 0, then the supporting plane is vertical. If
a isn't in this plane at time 0, then it can't enter
in contact with T during the in-between motion.
In the opposite case, the problem is reduced to
an equivalent plane problem, shown in Figure 4:
one has to determine whether the segment a a ' ,
representing the motion of the vertex a, intersects
one of the sides of T (it is sure that a is not i n T
at time 0).
a
4
4.1
Rotation: w~0,
C o m p l e m e n t a r y collision d e t e c t i o n s
Collision detection between two triangles
There are only two kinds of contacts between a n edge
a n d a t r i a n g l e , as shown in Figure 5. Either the edge
intersects one of the sides of the triangle (Figure 5.a),
or one of the extremities of the edge enters inside the
triangle (Figure 5.b). Of course, these two kinds of
contacts are not exclusive, since the edge can be in
the supporting plane of the triangle at collision time
(Figure 5. c). Therefore, for an edge and a triangle, it
is enough to compute three edge/edge collision detections and two vertex/face collision detections. For two
t r i a n g l e s , it is thus clear that it is enough to compute
nine edge/edge collision detections and six vertex/face
collision detections.
s=0
Using the parametrizations given by Equation 3,
Equation 6 becomes:
(-pax
c
Figure 5: Two non-exclusive kinds of contacts between
an edge and a triangle.
• If r ~ 0, then there is only one potential collision
time given by t : (d - p a x - q a y - r a z ) / r s . One
has then to check whether t is in [0, 1] and, if need
be, if the vertex a is in T at this time.
3.2.3
b
-- q a v + r a ~ - d)T2+
( - 2 p a v + 2qax)~r + p a x + q a y + r a z - d : O,
4.2
Collision detection between two polygons
solved easily 4.
3.2.4
G e n e r a l m e t h o d : w # 0, s # 0
As mentionned before, the function f has already been
set ( f ( t ) = ~tan(,~/2) on [0, 1]), but the method used
before can be applied again: with parametrizations 3,
Equation 6 becomes:
rs
Ta + (-pax
The main part in detecting a collision between a vertex
and a triangle is computing the collision times between
the vertex and t h e s u p p o r t i n g p l a n e of the triangle. It
has then to be checked whether the vertex is inside the
triangle at these times. If this second phase is adapted
for polygons, it is then possible to combine tests to detect collision between polygons (the equivalent plane
problem shown in Figure 4 is easily extended to polygons).
- qau + r a ~ - d)~-2+
tan(w/2)
5
r8
Conclusion
( - 2 p a y + 2 q a x + tan(w/2~)T + pa= + q a y + r a z - d ---- O,
This paper describes an analytical continuous collision
detection m e t h o d designed for interactive manipula-
solved exactly using Cardan's formulas. For each potential collision time, one then checks whether, at this
time, the vertex is inside the triangle.
4 T h e fact t h a t the c o n s t a n t t e r m is pax + qay + r a z - d is not
surprising. Indeed, this t e r m is nil if and only if 0 is a root of
t h e polynomial, t h a t is t o s a y if t h e vertex a is in t h e s u p p o r t i n g
plane at t h e b e g i n n i n g of the motion.
3737
tion or, more generally, for slowly moving objects. It is
indeed based upon the use of an arbitrary in-between
motion, general enough to allow free objects placements at discrete instants: and simple enough to compute quickly the collision time between objects parts
(vertices, edges and faces).
5.1
References
[1] Stephen Cameron. Collision Detection by fourdimensional intersection testing. I E E E Transactions on Robotics and Automation 6(3):291-302,
June 1990.
[2] John Canny. Collision detection for moving polyhedra. I E E E Transactions on Pattern Analysis
and Machine Intelligence, 8(2), 1986.
Future work
The methods described in this paper have been implemented and seem to be "bug-free". As for most of
the existing CD techniques though, a fast rough test
has first to be computed, in order to eliminate quickly
non-pertinent (but time-consuming) elementary tests.
Hierarchical englobing structures are presently being
developed. Whereas these structures move according
to the same motion .A/I, in order to have a global continuous method, the CD problem is reduced again to
a polynomial equation whose degree is at most three,
allowing real-time manipulation of objects. This opens
numerous paths to investigate.
Thanks to the continuous method, it is thus possible to
know precisely the kind of contact occuring between
two objects. This will allow one to know precisely
the constraints on the objects and should permit an
intuitive and realistic manipulation of them.
Virtual environments generally include a force simulator in order to make the environment more realistic
(gravity, contact forces...). Most of the time, the repulsion forces are computed using the amount of interpenetration between the objects (because, most of
the time, the CD algorithm is discrete). Here, one
idea could be to establish a relationship between, for
example, the kinetic energy of an object and the collision time t: if t is close to zero, then there remains a
lot of energy to spend, at collision time.
A problem occurs with articulated objects. Since the
composition of two continuous screwings of type .h4 is
not a screwing of type .h4, it isn't possible to compute
collision detections for articulated objects: whereas
the constraints will be respected at the initial and final
time, they won't be respected during the in-between
motion. Formally, the a and b functions should be
designed to make a closed motion space, that is to
say stable for the composition law. However, this is a
general problem in robotics, most of the time solved
by moving the elements of a kinematic chain one after
the other. This solution is perfectly usable with the
m e t h o d described in this paper.
3738
[3] Harry H. Cheng. Real-time four-dimensional collision detection .for an industrial robot manipulator. Journal of applied mechanisms and robotics,
Vol. 2, No. 2, April 1995, pp. 20-33.
[4] E.G. Gilbert et S.M. Hong. A new algorithm/or
detecting the collision of moving objets. In International Conference on Robotics and Automation, pages 8-13, IEEE, 1989.
[5] E.G. Gilbert, D.W. Johnson, et S.S. Keerthi. A
fast procedure for computing the distance between
complex objects in three space. In International
Conference on Robotics and Automation, pages
1883-1889, IEEE, 1987.
[6] B. von Herzen, A. Barr, et A.H. Barr. Elastically
deformable models. In Computer Graphics (Proc.
SIGGRAPH), volume 21, pages 205-214, ACM,
August 1987.
[7] Philip M. Hubbard. Collision Detection for Interactive Graphics Applications. Department of
Computer Science - Brown University - Providence, Rhode Island 02912. CS-95-08. April 1995.
[8] Yoshifumi Kitamura, Amy Yee and Fumio
Kistfino. A Sophisticated Manipulation Aid in a
Virtual Environment using Dynamic Constraints
among Object Faces. Presence, volume 7, number
5, pages 460-477, October 1998.
[9] Ming C. Lin and Stefan Gottschalk. Collision detection between geometric models: a survey. In
the Proceedings of IMA Conference on Mathematics of Surfaces 1998.
[10] St~phane Redon. Une solution algdbrique au
probl~me de la dgtection de collision pour des
objets polygdriques. Rapport de stage de DEA
(french). September 1999.