Fast Contact Localisation Between Deformable Polyhedra ... - CiteSeerX

7 downloads 0 Views 369KB Size Report
deformable objects but in this case one has to recon- ... between the two main objects. The number of these ... composed of NA facets and Na vertices, B is composed of NB facets and ..... distance between its center and these projections. To.
Fast Contact Localisation Between Deformable Polyhedra in Motion A. JOUKHADAR & A. WABBI & Ch. LAUGIER GRAVIR / INRIA Rh^one Alpes ZIRST 655 avenue de l'Europe 38330 Montbonnot Saint-Martin FRANCE Email: [Ammar.Joukhadar,Christian.Laugier]@inria.fr

Abstract

This paper 1 presents a new approach to detect and localise contact between concave deformable polyhedra. In this case there are many contact points between two polyhedra, the proposed algorithm detect and localise the contact in linear time O(n). It returns also the direction of this contact and the value of the maximum inter-penetration between the two convex-hulls of these two polyhedra.

Key-words: physical modeling, Animation, contact detection, interaction, deformable objects, virtual reality.

1 Introduction

It is well known that collision detection is a bottle neck for a large number of geometrical based algorithms, and in particular for dynamical based simulation (a large percentage of computational time is devoted to collision detection). Several interesting results have been obtained for processing collision between rigid polyhedra: Lin & Canny[3] have proposed an incremental algorithm which, in constant time O(1), gives the positive distance 2 between two rigid and convex polyhedra in motion. This algorithm has been extended by Kotoku [7] in order to localise the contact when the distance between the two rigid and convex polyhedra is negative. Gilbert and al[4] have proposed an algorithm which calculates, in linear time O(n), the positive distance between the convexhulls of two sets of points (without calculating these convex hulls), and gives an approximation of the negative distance3 in the case of small inter-penetrations. 1 Computer Animation, June'96, Geneva, Switzerland. 2 The positive distance is the distance between the two sep-

arate polyhedra 3 The negative distance is the distance when there is interpenetration between the two polyhedra

Garcia-Alonso et al[6], proposed an algorithm which represent an object by its min-max box, by its container and by voxels. This algorithm can be used for deformable objects but in this case one has to reconstruct dynamically the representation of the object. For rigid concave polyhedra, one can divide them into many convex ones and apply one of the previous algorithms to detect contact. The problem arises when treating deformable polyhedra because their states dynamically change from concave to convex and viceversa during the motion and hence may not be statically divided into convex polyhedra. Also, it is very complicated to divide them dynamically during the motion (O(n2)). Bara & Witkin [2] divide objects into convex sub-objects that can only obey to rst order polynomialdeformation (a facet or an edge can not be curved), which guaranties that they stay convex during the simulation. So, a fast collision detection algorithm between convex objects may be applied for each combination of sub-objects to detect the collision between the two main objects. The number of these sub-object may be large when representing a highly deformable object. Volino & Thalmann [8] proposed a hierarchical algorithm which use the curvature properties of a surface in order to solve the self-collision problem.

2 Outline of our approach

Given two deformable polyhedra A and B , A is composed of NA facets and Na vertices, B is composed of NB facets and Nb vertices. Let CX be the convex hull of the polyhedron X and FXi be the ith facet of the polyhedron X . Our approach consists in detecting collision between each pair of facets (FAi ; FBj ). This requires NA  NB operations which is very expensive. So, before considering these pair of facets, we begin by eliminating from each polyhedron some facets that can not be in contact, in order to determine

two minimal sets of facets that can be a potential candidates. This elimination of facets can be made in linear time O(NA + NB ) using some parameters. These parameters can be obtained by extending the Gilbert algorithm in order to calculate the real value of the negative distance. Our algorithm returns two sets of facets that can be in collision, it returns also the amount of maximum interpenetration (between CA and CB ) and the direction of this collision. Our algorithm has the following restriction: although there are many contact points between the two polyhedra, all these contact points are in the same side, ie. that A can not be in contact with two opposite sides of B at the same time ( gure 1).

A

A B

B

1

2

Figure 1: Our algorithm is restricted to the case where, a

polyhedron can not be in contact with two opposite sides of another one. So the case 1 is acceptable but not the case 2.

3 Determining potential candidate of facets

Eliminating facets needs to use the following parameters which characterise the contact(See gure 2):  The negative distance dn: it is the smallest amount of displacement that can separate the two convex hulls CA and CB .  The contact direction ~nA=B : it is the direction in which the smallest displacement has to be performed. It goes from A to B .  The contact plane PA=B : it is the plane which the director vector is ~nA=B and passes by the closest point of CA to CB .  The impact zone ZA=B : it is the projection of the part of A, which exists in the negative side of PB=A , on PB=A . Given these three factors, one can eliminate, in linear time, all facets from the polyhedron A (resp. B )

ZA=B

FA1

FA2

~nB=A

FA3

FB4 FB3

dn FB5 FB2

FB6 ~nA=B

FB7

PB=A PA=B

FB1

Figure 2: The facets FA1 , FA2 , FB1 , FB2 , FB3 can not be in contact, because they do not have the same side of the collision. The facets FA1 , FB2 , FB5 can not be in contact because they are far from the other polyhedron. The facets FB1 , FB3 , FB6 , FB7 can not be in contact because they are far from the impact zone of the other polyhedron. Only FA3 and FB4 may be in contact. that can not be in contact with the polyhedron B (resp. A). Three criteria are evaluated for eliminating such facets:  if ~nA=B  N~FAi < 0, where N~FAi is the external normal on the facet FAi , then the facet is invisible to the polyhedron B and can be eliminated. This is the case of the facets FA1 , FA2 , FB1 , FB2 , FB3 in the gure 2.

 If Distance(FAi ; PB=A ) > 0, then the facet can not be in contact with B because CB exists, by de nition, in the negative side of PB=A . This is the case of the facets FA1 , FB2 , FB5 .  If the projection of FAi on PA=B is out of ZB=A , then the facet can be eliminated. This is the case of FB1 , FB3 , FB6 , FB7 .

After applying these three tests on each facet. The algorithm will return two sets of facets which have not been eliminated (in our case they are fFA3 g and fFB4 g). These three tests are atomic and can be made in constant time for each facet. So the time needed to perform this elimination depends on the number of facets NA + NB only. So, to obtain a linear complexity we need to be able also to obtain these parameters in linear time.

4 Determining contact parameters in extending Gilbert algorithm

Gilbert algorithm is designed to calculate the Euclidean distance between the convex hulls of two polyhedra A and B (without calculating these convex hulls) de ned only by their vertices Na and Nb in mdimensional space. The Euclidean distance between CA and CB is de ned by:

d(CA ; CB ) = minfjx ? yj : x 2 CA ; y 2 CB g = minfjz j : z 2 CA CB g CA CB = fz : z = x ? y; x 2 CA ; y 2 CB g So the distance between CA and CB is equal to the distance of their Minkowski set di erence (the Minkowski set di erence of two convex polyhedra is always a convex one) CA CB from the origin O. The algorithm of Gilbert nds the closest point P~ = P~A ? P~B from CA CB to the origin and returns P~A and P~B , so d = jPA ? PB j and ~nA=B = jPP~~BB ??PP~~AA j . Although this algorithm uses CA CB , but it does not calculate all the vertices of CA CB , which is why it can make use of the continuity of the motion of A and B in order to converge in linear time O(Na + Nb ).

A

PA

PB A

A

B

B

B

1

2

3

Figure 3: The algorithm of Gilbert gives the distance between two polyhedra and returns the two nearest points PA ;PB (1). When the two polyhedra interpenetrate (2), the algorithm may give a non correct negative distance (3), because it uses a local test to calculate this distance. When the two polyhedra are intersecting, the algorithm detects this situation and gives an approximation (but not the real value. See gure 3) of the negative distance when the interpenetration is very small. As the algorithm considers the convex hulls of concave polyhedra, it may therefore detect non-real collisions (it is possible that the two convex hulls were in contact but not the two concave polyhedra) and the amount of interpenetration between the two convex hulls can be

very signi cant without having contact between the two polyhedra. This is why this algorithm cannot be directly applied to the problem of collision detection between exible polyhedra. In the following chapter, we show how this algorithm can be used to nd the contact parameters.

4.1 Finding the contact direction

When CA and CB are separated, the contact direction ~nA=B is equal to jPP~~BB ??PP~~AAj , where PA and PB are the two closest points given by the Gilbert algorithm. When CA and CB are in contact, ~nA=B is the direction according to which we have to move CA and CB in order to separate theme with a minimum of displacement. In the space of Minkowski set di erence CA CB , the contact direction ~n is the direction in which the origin O has to be moved in order to bring it out of CA CB with a minimum displacement. The idea of our algorithm is based on the following two properties of ~nA=B , when the distance is negative:

Remark: For simpli cation purposes, the following properties are justi ed in the space of the Minkowski set di erence. But in practice, we do not calculate this di erence. We denote by ~n the contact direction between the origin and CA CB .  ~nA=B does not change after a displacement according to ~nA=B : As CA CB is a convex polyhedron, the closest feature to the origin O (when it is inside CA CB ) is a facet. So ~n is perpendicular to this facet. When O moves according to the

normal of the facet, this facet remains the closest feature from CA CB to O.  There is a compact zone Z = ~zi around nA=B ~ verifying that for every displacement according to ~zi 2 Z (which separates CA and CB ) the new contact direction (which is positive and obtained by the Gilbert algorithm) is closer to nA=B ~ than to ~zi : As CA CB is a convex polyhedron and O is inside it, it is impossible to O to be closer to a vertex than a facet which passes by this vertex, so only the point/facet contact type is possible. This type of contact corresponds to three contact types between the two polyhedra: facet/facet, facet/edge, and facet/vertex. So the closest feature to O is a facet f . Figure 4 shows that, if we displace O out of CA CB according to a vector ~zi which passes by a facet f , the new contact direction is closest to ~n (which is normal on to the facet) than ~zi , because is an obtuse angle which varies between 180o , when ~zi passes by an

edge of f , and 90 when the new contact direction is perpendicular to f . So the Zone Z is de ned by the set of vectors zi that passes by the closest facet.

~ni

z~i

~n

dpl

Z

of iteration needed to converge. So the complexity is O(I:(Na + Nb )). The gure 5 shows an example. B n~ 0A=B

B z~j

~nj

~n1A=B

A



A

O

B ~n1A=B

B

Figure 4: Inside the zone Z any displacement (~zi ,~zj ,..) of O will give a new positive contact direction (~ni ,~nj ,..) which is closer to the exact contact direction ~n. Given an initial value ~n0 2 Z of the contact direction, the two above properties allows us to nd ~nA=B using the following algorithm:

VECTOR Find Contact Direction(~n0) f Separate CA and CB according to ~n0 . Apply the Gilbert algorithm to get the new positive contact direction ~nA=B . IF ~n0 = ~nA=B THEN return ~nA=B ELSE return Find Contact Direction (~nA=B ) g

Remark: We can not nd the contact direction in looking for the intersection of ~n0 with all the facets of CA CB , because it needs a quadratic time O(Na  Nb ) (the polyhedron CA CB contains Na  Nb vertices)

and our gaol is to obtain a linear algorithm. Also, these facets are implicit, they belong to the convex hulls, and they are not speci ed in the de nition of A and B which are concave. At each iteration i, the value of ~ni0 is closer to ~nA=B than ~ni0?1, so the algorithm converges always. The complexity of the above algorithm is I times the complexity of the Gilbert algorithm, where I is the number

n~ 2A=B

A

A B n~ 2A=B

B A

~nA=B

A

Figure 5: Moving A==B in the direction ~niA=B and applying

3 the Gilbert algorithm gives us ~ni+1 A=B . In this example ~nA=B is equal ~nA=B

The behaviour of this algorithm depends on two parameters:  The initial direction ~n0 : Because of the continuity of the motion, the obtained contact direction can be used as an approximation of the contact direction in the next time step. If initially the distance between the two objects were positive then the Gilbert algorithm can give an initial value of this direction, we can use this value to calculate the contact direction when the distance is negative and use this one to calculate the contact direction in the next time step, etc... The fact that our algorithm has a local convergence (it converges always toward the facet by which passe ~n0) make it very robust for a signi cant amount

of interpenetration (see gure6). n1

n0

n1

n0

n2 n1

n2

n2

~n n3

n3

n4

1

dp dpl dpl2 dpl3 dpl4 l5

n3

2

1

Figure 6: (1) The origin goes in the depth inside CA CB : although it becomes some times closer to the other side CA CB , the algorithm converge always toward the side from which O came in, because it uses the last contact direction in order to initialise it self. (2) the origin following the border of CA CB : when ~ni passes by the convergence zone Z of a new facet, the algorithm converges toward the normal of this facet ~ni+1 .

O

 The displacement value dpl: We have to choose

the smallest amount of displacement that can separate the two polyhedra, because, as much as dpl is small, the contact direction obtained after the the displacement is closer to the real contact direction. Figure 7 illustrates this. This is why we choose this value to be proportional to the negative distance obtained in the last iteration. If this value is not large enough, the Gilbert algorithm will detect a negative value, then our algorithm will duplicates this displacement and repeats the process. The choice of ~n0A=B and dpl explained above, allowed us to converge practically very fast. In our experimentation the average value of I was very close to 1. 4.2 Finding the negative distance dn To nd the value of the negative distance dn(t), we apply a displacement dpl on the polyhedron A in the direction ~nB=A (t) and we apply the Gilbert algorithm to get the positive distance dp . Then negative distance dn is equal to dpl ? dp . 4.3 Finding the impact zone ZA=B When two polyhedra have a very di erent dimension it is very useful not to consider all facets of the big one but only those facets , which are close to the small polyhedron. This is the case for example when one polyhedron represents the ground and the other represents a wheel of a car. Also only the part of A which exists in the negative side of PB=A can be in contact with B . It is not possible to nd in linear

Figure 7:

~nB=A

~nB=A

dn

dpl

dp

Figure 8: Given the contact direction ~nB=A , the negative dis-

tance is equal to the di erence between the amount of displacement dpl and the positive distance dp : dn = dpl ? dp

time the exact projection of A on PB=A , which is why we over-estimate this projection by the convex hull of the projections of all vertices of A (which are in the negative side of PB=A ) and all intersection points between all edges of A with PB=A (see gure 9). We can nd these projections and their convex hull in linear time O(Na + NA ), but nding if a facet FBi is inside or outside ZA=B needs linear time O(n) where n is the cardinal of this convex hull which is comparable to Na . For NB facets we need NB  Na operations to eliminate facets. So another approximation of the impact zone is necessary to decrease the complexity. We over-estimate this convex hull by the smallest sphere which can includes all its vertices. The center C of this sphere is the geometrical center of all the projected points, and the radius R of this sphere is the longest distance between its center and these projections. To detect if a facet is inside or outside this sphere we need a simple distance test and the elimination complexity becomes O(NB ).

Local deformation

d

Figure 10: The collision force is the result of a local deformation at the contact area. It is proportional to d.

FBj and the part of FBj which is in front of FAi . These two projections are parallelPto ~nA=B ( gure 11. It is obvious that v = i;j v(FAi ; FBj ) and the gure 12 show a 2D example. F2

5 Collision response

When two objects collide with each other, they locally deform ( gure 10). Consequently, they store potential energy, which will be transformed into kinematic energy when these objects return to their initial forms. So the collision force is proportional to the amount of deformation. When these two objects are rigid the \impulse based method" can give an estimation of the collision force. When these objects are deformables, the local deformation is estimated by measuring the inter-penetration volume between these two objects \penalty method" and the collision force can be given by:  ~ v