2-Body Collision Detection using LRB-reps 1 Introduction - CiteSeerX

0 downloads 0 Views 130KB Size Report
other modules in the simulation, like the one controlling the dynamics BV94]. However, for .... is needed, or when a collision can be declared between real faces.
2-Body Collision Detection using LRB-reps

Carlos Gonzalez-Ochoa Department of Computer Science Purdue University West Lafayette, IN 47907-1398

1 Introduction Applications for physical-based simulation and virtual reality systems, are pushing the level of realism in the environments these systems can simulate. Not only should the environment look real but the objects simulated in them should behave as real as possible. Objects are expected to move, collide and slide as a norm, not the exception. To model this behaviour the simulator must enforce properties of non-interpenetrability between all the objects plus solving the equations to describe such movements. To properly maintain non-interpenetrability, an n-body collision detection test has to be performed at each time step of the simulation. The test not only should return whether any two or more objects collide but the region where the collision occurred. This information is important to other modules in the simulation, like the one controlling the dynamics [BV94]. However, for many applications the mayor bottleneck is computing the region of collision between 2 objects. In this systems, as the complexity of the objects increases the time it takes to the detection algorithm to resolve a collision grows at a much higher ratio. Therefore, nding an ecient 2-body algorithm that is little a ected by scalability problems is still of research interest. The basic solution to the 2-body problem, consists of a pair wise checking of all the entities of both objects to nd the faces that are interpenetrating or in contact. This solution is obviously unacceptable for objects with a large number of faces. A solution for convex objects described in [DK83], reduced the quadratic complexity to sub-linear time. The solution to the similar problem, given by Lin and Canny's [LC91], to track the minimal distance between pairs of objects provides on the average a near constant-time incremental algorithm. This algorithm, however, does not generalize well to non-convex and complex objects undergoing contact analysis. The algorithm does not provide contact region information once contact has been detected, and non-convex objects need to be convexi ed. This convexi cation results in an O(n2) complexity when n convex pieces result. For complex objects, n can be prohibitively large. For non-convex objects other methods have been suggested to enhance or completely replace the B-rep representation, such as the octree [Sam89b, Sam89a], BSP tree [Nay90], MSP tree [Van91], sphere tree [Hub94], some hierarchical grid structure [FP94], or some hierarchical bounding-volume structure possibly combined with varying levels-of-detail [AP94] added to nd which entities on the boundary are closest. Each one has advantages and disadvantages which depend on the application and the constraints imposed by it. For example, the method used by BSP trees to detect collisions is achieved by tree merging, a method with a very low cost [BNT90]. Two problems that BSP trees have are, rst, 

[email protected]

1

Figure 1: An 2D example of an LRB-rep object. The original object is shaded darker. the set-theoretical intersection can not be computed, as it yields a zero volume region when two bodies are just in contact. And second, the lack of adjacency information in the BSP tree. Is not clear how adjacency information would be encoded in the tree structure and be passed to the dynamics module. For other structures that enhances the B-rep, the collision detection test generally works by taking all the entities in the B-rep of one object and classifying them into the other object's particular structure. Although this method works for arbitrarily shaped objects, it is computational expensive when both objects are large and complex. Our algorithm exploits the properties of the LRB-rep structure [GV94], which is based on ideas of cellular decomposition, multiresolution and hypergraph structures. This structure tries to solve the associated problems of fragmentation induced by adding local details producing changes globally. The LRB-rep abstracts an object into a simpler shape. This coarse approximation of the object can be locally re ned on demand on speci c areas of interest, until locally resolving to the original object.

2 LRB-rep The LRB-rep uses ideas from Voronoi partitions and spatial decomposition. An LRB-rep of an object s, can be seen as a cellular decomposition of space with at least two cells, the rst one corresponding to the object s and the second one to the region outside the object. Additional regions are added to cover the object's detail. That is, the object is abstracted into a simpler shape by enclosing with a few big regions many smaller regions. The additional regions are represented in the LRB-rep by faces supported either by edges and vertices in the original object or new ones that are not part of the original object. The new faces are called pseudo faces, and the ones belonging to the original object are called real faces. The LRB-rep is then a cellular decomposition of space, represented by a non-manifold representation with additional information for each region. The space consist of two region, one for object s and the other for the rest of space. Additional regions adjacent to s hide its details. The union of the original object and the additional regions forms a polyhedral object that abstracts s. In each region, a topological entity called the face-collector (collector) is associated with each one of the faces in the region. The region can be of any shape and possibly have no volume as happens for regions between overlapping faces. From any exterior face of the LRB-rep, a number of face-region and region-face transitions resolves the exterior face (at a low level of detail) to an interior face (at a high level of detail). The number of transitions needed to resolve to the interior face depends on the number of faces at the highest level of detail in the local proximity and partly on how the LRB-rep was constructed. There is no unique (or canonical) LRB-rep for an arbitrarial complex object as the face-abstraction process of adding new faces to the outside is arbitrary. 2

(a)

(b)

(c)

(d)

Figure 2: A sequence of re nements of the object in gure 1.

3 Wrapper After an LRB-rep is built and while the simulation is executing, the LRB-rep remaions as a static structure. This is because the LRB-rep structure is such that a modi cation to the topology is too expensive, adding and removing elements have big overhead. Instead another structure sitting on top of the LRB-rep is used to access the LRB-rep elements and maintain a set with the valid faces that represents an approximation to the solid at any given time. This structure is called the wrapper. Geometrically, a wrapper is the boundary of a possibly larger and simpler solid that contains s is and described by it's LRB-rep. This larger solid is partitioned into a set of regions (i.e., represented by their collectors). Re ning the approximating solid to either a higher or a lower level of boundary detail is done by either adding or removing regions that are adjacent to its boundary. From a functional point of view, the wrapper provides the application with the ability to handle the LRB-rep eciently. Faces in the wrapper can be re ned or discarded without having to modify the topology or the geometry of the LRB-rep, while maintaining, if desired, a regularized approximation. The wrapper provides the operations to re ne faces bringing more detail on demand. That is adjacent regions are \merged" or discarded when the application no longer has interest on them, but on the regions beneath them. The re nement will always converge to the solid, this is proved by re ning all the additional regions thus the original object is uncovered. If a local area of the object is of interest, starting from the exterior and re ning only on the direccion of the area only a small number of regions will be needed to be re ned.

4 The 2-Body Collision Algorithm The 2-body collision detection algorithm using LRB-reps of two objects s1 and s2 requires their respective wrappers, w1, and w2. The algorithm is described as follows: Starting with the outer faces (the faces at the lowest detail) of w1 and w2 an all pair face-face intersection test is performed. Although this is an expensive test, O(n2 ), it is assumed that the number of faces at this level is very small (eg. < 10) compared with the total number of faces of the object (eg. 40; 000 faces). If a face-face intersection occurs one of these cases result.  If faces are pseudo-faces then re ne, bringing in new detail (more faces). The new faces added to each respective wrapper are then recursively tested.  If one is a real face and the other is a pseudo face, only the pseudo face is re ned and the new faces are recursively tested against the real one.  If both faces are real, the faces are stored in a list of pair-faces that will be returned to the contact analysis module. If the application requires to know only whether the objects are in collision, then the algorithm exits declaring a collision. 3

The algorithm ends when no more faces are needed to be tested. Repeated re nement of a region is avoided by a timestamp mechanism in the wrapper, a region or even an individual face can only be re ned once thus avoiding in nite loops. The termination is guaranteed by successive re nements, that starting at the lowest detail level, re ned faces are substituted by regions closer to the object, thus separating intersecting regions of the objects [GV94]. It ends when the wrappers are completely separated and no pending testing is needed, or when a collision can be declared between real faces. The time the algorithm takes depends of several factors such as the construction of the LRBreps, the area of contact and the complexity of the collision itself. Although in the worst case this algorithm is quadratic, O(n2), which can happen when the two objects are completely overlying each other; we can assume the area Fixed Object of real collision to be localized and on the A Variable Objects average case the performance of the algoB rithm to remain sub-linear. C To support this intuition with evidence D several fractal models were built. All the E models have a basic non-convex shape but F each one has a di erent global complexG ity, introduced by adding local detail. The H number of faces in the objects ranged from Table 1: Object sizes a few hundred faces to more than 43,000 faces. Object

No. Real

No. Total

Faces

Faces

Object

34,474

43,396

Object

144

168

Object

214

282

Object

2,004

2,532

Object

3,659

4,463

Object

10,534

13,224

Object

20,719

25,233

Object

34,474

43,396

Number of Collisions Collision with Object B C D E F G H

LRB-rep 2-Body Collision Detection

n

log(n)

n

2

Minimum Average Maximum 744 1,229 1,705 2,588 7,290,528 674 1,162 1,848 4,344 12,237,672 709 1,537 3,688 39,006 109,878,672 709 2,257 4,279 68,753 193,676,348 744 1,627 5,395 203,719 573,868,704 744 1,909 6,089 388,721 1,095,011,268 709 2,682 5,798 668,527 1,883,212,816 Table 2:

Results from collision of Object A to di erent objects

The fractal models were used in a series of collisions to test the performance of the detection algorithm. The tests xed the size of object A and simulated the collision against another object. This last object was varied between seven others. A run of 100 di erent collisions were performed for each di erent object. In each collision experiment the initial position of the objects was modi ed to change the point of impact and therefore the complexity of the collision. At each timestep in the simulation when the objects had a face contact (any kind) the number of face comparisons and face re nements was recorded. In Table 1, the sizes of the objects are tabulated. Notice the ratio in size between the smallest and the largest object. In Table 2, the results of the collision tests are displayed, the minimum, average 4

8000

168 Faces

282 Faces

6000

282 Faces

2532 Faces 4000

3659 Faces 10534 Faces

2000

25233 Faces

0

Frequency

No. comparisons

100

168 Faces

2532 Faces 50

3659 Faces 10534 Faces 25233 Faces

43396 Faces

Figure 3.1: Object size vs. face comparisons

43396 Faces

0

100 1000 10000 100000 Object size (No. faces) log scale

0

2000 4000 No. comparisons

6000

Figure 3.2: Distribution of face comparison for all objects

and maximum number of face comparisons are showed for each one of the objects. In gure 3.1 the results for the LRB-rep detection algorithm are graphed. In the fth and sixth columns, as a matter of comparison, is showed the number of comparisons that in theory a n log (n) and a quadratic algorithm could make. In gure 3.2 the distribution of the face comparisons is showed, it can be seen that the major face distribution grouping is around the area centered at 2000 mark, and only few spikes exist at higher values. It can be seen that the number of face comparisons do not grow as the ratio of object's size. An increase of 258 times to the global size in the tested objects re ected only 3.5 times more face comparisons that the detection algorithm perform in the worst case. On the average, the number of face comparisons roughly doubled. If the results between our algorithm and the quadratic one are compared for the largest object, we see a di erence of  6 orders of magnitude in the number of face comparisons. These results con rm our intuition. Using the LRB-rep structure to resolve faces locally, only the faces in the area of collision were re ned, therefore avoiding useless comparisons between the rest of the object. Keep in mind that the detection algorithm does not assume the objects to be convex or simple, and only uses a basic polygon-polygon intersection routine. Note that no additional spatial structures are used in the LRB-rep structure or in the collision detection algorithm. If we take into account that objects of di erent shapes can have di erent LRB-rep structures, performance of the collision detection algorithm may be better or worst. The results presented here demonstrate that the LRB-rep structure provides applications, such as the presented 2-body collision detection algorithm, a good mechanism to concentrate on a particular area of the object without taking into account the rest of the object. We believe that the presented algorithm provides a good solution to the 2-body problem. The experiments show that the algorithm performance is a ected slightly by increasing the global complexity of the models. Yet, the algorithm can still be improved if the temporal information of the objects, supplied by the simulation, is taken into account. An incremental version of the detection algorithm can be constructed and currently we are working on it.

5

References [AP94] P. Astheimer and M. Poche. Level-of-detail generation and its application in virtual reality. In G. Singh, S. K. Feiner, and D. Thalmann, editors, Virtual Reality Software & Technology: Proceedings of the VRST '94 Conference, pages 299{309. World Scienti c, 1994. [BNT90] J. Amanatides B. Naylor and W. Thibault. Merging BSP tress yields polyhedral set operations. ACM Computer Graphics, 24(4):115{124, August 1990. [BV94] W. Bouma and G. Vanecek, Jr. Modeling contacts in a physically based simulation. Computer-Aided Design, 26(6), June 1994. [DK83] D. Dobkin and D. Kirkpatrick. Fast detection of polyhedral intersection. Theoretical Computer Science, 27:241{253, 1983. [FP94] K. M. Fairchild and T. Poston. Ecient virtual collision detection for multiple users in large virtual spaces. In G. Singh, S. K. Feiner, and D. Thalmann, editors, Virtual Reality Software & Technology: Proceedings of the VRST '94 Conference, pages 271{285. World Scienti c, 1994. [GV94] C. Gonzalez-Ochoa and G. Vanecek. Locally Resolvable B-rep. Technical report, Purdue University, September 1994. [Hub94] Philip M. Hubbard. Collision Detection for Interative Graphics Applications. PhD thesis, Department of Computer Science Box 1910, Brown University, Providence, RI 02912, May 1994. [LC91] M. C. Lin and J. F. Canny. A fast algorithm for incremental distance calculation. In IEEE International Conference on Robotics and Automation, pages 1008{1014, April 1991. [Nay90] B. Naylor. Binary space partitioning trees as an alternative polytopes. Computer{Aided Design, pages 250{252, 1990. [Sam89a] H. J. Samet. Applications of Spatial Data structures: Computer Graphics, Image Processing, and GIS. Addison{Wesley, Redding, MA, 1989. [Sam89b] H. J. Samet. Design and analysis of Spatial Data Structures: Quadtrees, Octrees, and other Hierarchical Methods. Addison{Wesley, Redding, MA, 1989. [Van91] G. Vanecek, Jr. Brep-index: A multidimensional space partitioning tree (revised). International Journal of Computational Geometry and Applications, 1(3):243{262, September 1991.

6

Suggest Documents