recode: an image-based collision detection algorithm

12
THE JOURNAL OF VISUALIZATION AND COMPUTER ANIMATION J. Visual. Comput. Animat. 10, 181–192 (1999) vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RECODE: an Image-based Collision Detection Algorithm By George Baciu,* Wingo Sai-Keung Wong and Hanqiu Sun vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv Object interactions are ubiquitous in interactive computer graphics, 3D object motion simulations, virtual reality and robotics applications. Most collision detection algorithms are based on geometrical object-space interference tests. Some algorithms have employed an image-space approach to the collision detection problem. In this paper we demonstrate an image-space collision detection process that allows substantial computational savings during the image-space interference test. This approach makes efficient use of the graphics rendering hardware for real-time complex object interactions. Copyright 1999 John Wiley & Sons, Ltd. Received July 1999 KEY WORDS: image-based collision detection; object interference; motion simulation Introduction Autonomous object interactions and navigation in a 3D virtual environment often require fast object interference tests, efficient and accurate computation of collision points, as well as identifying the points of contact for a possible response action. Aiming for both generality and high performance, a new breed of collision detection algorithm is currently being developed. This is motivated by the fact that object-space collision detection methods are generally dependent on the geometrical structure of objects, exhibits a high complexity even for simple combinations of poly- hedra, are limited to planar bounding surfaces and are often costly to run, either owing to preprocessing or owing to run-time searches for closest features. By com- parison, image-based collision detection methods are much simpler to implement, exhibit a high degree of robustness with respect to object geometry and have a great potential to exploit the hardware-assisted rendering features of the current graphics boards. While some work has been done in this area, 14 much remains to be investigated to improve and refine these methods. The paper is organized as follows. In the following section we outline the background ideas, stressing the difference between image-space and object-space collision detection methods, together with the motivation and main contributions of this work. In the third section we give a perspective of some of the most relevant and recent work on collision detection methods and classify them accord- ing to the image and object-based division. In the fourth section we give the details of our image-based algorithm. In the fifth section we describe the experiments we performed and the performance evaluation of our algor- ithm in the context of the fastest algorithms currently available. In the final section we draw some conclusions and propose some directions for further research work in the area of image-based collision detection. Background In practice, any computational process for object inter- actions in a 3D environment takes us further away from the hardware rendering rates. As a fundamental task, the collision detection process should not add much overhead to the actual scene rendering itself. Our main goal is to make optimal use of the hardware rendering capabilities of conventional graphics workstations in order to achieve efficiency and flexibility within the collision detection process. We propose an effective use of the image rendering buffers during the rendering process to perform collision tests and compute collision points after reducing the possible regions of interference by object-space culling based on a combination of both aligned and oriented *Correspondence to: G. Baciu, Computer Science Department, The Hong Kong University of Science and Technology, Clear Water Bay, Kowloon, Hong Kong. E-mail: gbaciu@cs.ust.hk. Contract/grant sponsor: RGC; Contract/grant number: HKUST 598/94E. vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv CCC 1049–8907/99/040181–12$17.50 Copyright 1999 John Wiley & Sons, Ltd.

Upload: george-baciu

Post on 06-Jun-2016

215 views

Category:

Documents


2 download

TRANSCRIPT

THE JOURNAL OF VISUALIZATION AND COMPUTER ANIMATIONJ. Visual. Comput. Animat. 10, 181–192 (1999)

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

RECODE: an Image-based CollisionDetection Algorithm

By George Baciu,* Wingo Sai-Keung Wong and Hanqiu Sunv v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

Object interactions are ubiquitous in interactive computer graphics, 3D object motionsimulations, virtual reality and robotics applications. Most collision detectionalgorithms are based on geometrical object-space interference tests. Some algorithmshave employed an image-space approach to the collision detection problem. In thispaper we demonstrate an image-space collision detection process that allowssubstantial computational savings during the image-space interference test. Thisapproach makes efficient use of the graphics rendering hardware for real-timecomplex object interactions. Copyright � 1999 John Wiley & Sons, Ltd.

Received July 1999

KEY WORDS: image-based collision detection; object interference; motion simulation

Introduction

Autonomous object interactions and navigation in a 3Dvirtual environment often require fast object interferencetests, efficient and accurate computation of collision points,as well as identifying the points of contact for a possibleresponse action. Aiming for both generality and highperformance, a new breed of collision detection algorithmis currently being developed. This is motivated by the factthat object-space collision detection methods are generallydependent on the geometrical structure of objects, exhibitsa high complexity even for simple combinations of poly-hedra, are limited to planar bounding surfaces and areoften costly to run, either owing to preprocessing orowing to run-time searches for closest features. By com-parison, image-based collision detection methods are muchsimpler to implement, exhibit a high degree of robustnesswith respect to object geometry and have a great potentialto exploit the hardware-assisted rendering features of thecurrent graphics boards. While some work has been donein this area,1–4 much remains to be investigated toimprove and refine these methods.

The paper is organized as follows. In the followingsection we outline the background ideas, stressing thedifference between image-space and object-space collision

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

Copyright � 1999 John Wiley & Sons, Ltd.

detection methods, together with the motivation and maincontributions of this work. In the third section we give aperspective of some of the most relevant and recent workon collision detection methods and classify them accord-ing to the image and object-based division. In the fourthsection we give the details of our image-based algorithm.In the fifth section we describe the experiments weperformed and the performance evaluation of our algor-ithm in the context of the fastest algorithms currentlyavailable. In the final section we draw some conclusionsand propose some directions for further research work inthe area of image-based collision detection.

Background

In practice, any computational process for object inter-actions in a 3D environment takes us further away fromthe hardware rendering rates. As a fundamental task, thecollision detection process should not add much overheadto the actual scene rendering itself. Our main goal is tomake optimal use of the hardware rendering capabilities ofconventional graphics workstations in order to achieveefficiency and flexibility within the collision detectionprocess.

We propose an effective use of the image renderingbuffers during the rendering process to perform collisiontests and compute collision points after reducing thepossible regions of interference by object-space cullingbased on a combination of both aligned and oriented

*Correspondence to: G. Baciu, Computer Science Department, The HongKong University of Science and Technology, Clear Water Bay, Kowloon,Hong Kong. E-mail: [email protected].

Contract/grant sponsor: RGC; Contract/grant number: HKUST598/94E.

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

CCC 1049–8907/99/040181–12$17.50

G. BACIU, W. S.-K. WONG AND H. SUN

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

bounding boxes. Our approach involves the dimensionreduction of the 3D space, leading to a simple image-spacetest based on a minimal overlapping region (MOR). TheMOR of two objects is illustrated in Figure 1. We notethat MOR(A,B) corresponds to the projection of thebounding box of the region of intersection of two objectsA and B. This is obtained from the projections of thecandidate object pairs on to the viewing plane. Thecandidate object pairs are the pairs of objects whoseobject-space bounding boxes overlap. Our experimentsindicate that the overhead added to the hardware render-ing process by the collision detection and the determi-nation of the contact regions is relatively small onaverage. Further tests show a consistent performanceimprovement with respect to some popular object-spacecollision detection algorithms. The algorithm exhibits thesame degree of robustness in finding all the closestfeatures and contact points as I-COLLIDE, whileoutperforming in some cases RAPID and Q-COLLIDE.

We make no assumptions about the motion of objectsin the scene and there is no differentiation between thestates of a collision event. For example, there is no need todifferentiate between objects just before a collision, oncontact or penetrating each other. Hence there is no needto construct special pseudo Voronoi regions and identifyspecial cases whenever a collision event is detected due tosurface penetration. Furthermore, this approach benefitsfrom a variable image-space resolution. This allows us todynamically trade off accuracy for computational time.

In our current work the only assumption implied isthat the basic object primitives or blocks are convex.This assumption imposes absolutely no limitations onhierarchical structures, articulated bodies or non-convexcompositions of multiple convex blocks.

Previous Work

Solutions to the collision detection problem can be classi-fied according to the scene sampling in the time domain.This can be considered as either temporally global or

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

Copyright � 1999 John Wiley & Sons, Ltd. 182

temporally local. Within each temporal classification thespatial sampling for collision detection can be classifiedinto (1) object-space and (2) image-space interference tests.

Object-space Collision Detection

For the object-space interference test, research spans avariety of techniques from topological analysis to compu-tational geometry. Some precomputation is generallynecessary in order to identify an interference structure,either locally or globally. Data structures such as BSPtrees,5 octrees,6,7 voxel grids8 or hierarchical orientedbounding boxes9 are built for the spatial localization ofregions of potential interference.

Studies of the object-space interference test range fromtemporal and spatial localizations6–21 to global space-timeanalysis.22 The techniques that tend towards a globaltemporal and spatial analysis are generally morerobust. However, these techniques require completeknowledge of the space-time trajectories. Therefore theyare memory-bound and computationally prohibitive. Fur-thermore, in an interactive dynamic scene with auton-omous moving objects the full motion trajectories ofobjects are not generally known in advance. A similarsituation arises in an interactive navigation through avirtual environment.

In order to achieve interactive rendering rates, localmethods, both in time and in space, are more suitable. Inthe last few years some of the most significant contribu-tions in this area, both theoretical and practical, havebeen packaged in a series of fast, general-purposecollision detection software systems such as RAPID,20

I-COLLIDE,18 Q-COLLIDE23 and V-COLLIDE.24 Most ofthis work is based on the seminal work of Lin andCanny,14 who proposed an efficient computation of theclosest feature set between object pairs.

The separating axis theorem21 has made the eliminationof object pairs in the collision detection tests fast andpractical. Now it is possible to efficiently bound objectswithin more tightly fit oriented bounded boxes (OBBs)than aligned bounded boxes (ABBs).9 This dramaticallyimproves the performance for collision tests.

Exploiting the temporal and geometric coherence hasreduced the all-pairs testing of arbitrary polyhedral objectsfrom O(N2) to O(N2+S), where N is the number ofobjects in the scene and S is the number of pairwiseoverlaps18 when the coherence is preserved. This result isextremely useful when the relative orientation betweenobjects does not change and collisions may occur due to

Figure 1. MOR of two objects A and B

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

J. Visual. Comput. Animat. 10: 181–192 (1999)

IMAGE-BASED COLLISION DETECTION

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

translational motion alone. However, in many applica-tions, objects change their relative orientation, triggering arecomputation of the closest feature sets.

The separating vector technique has been shown toimprove the bounding box overlap tests.23 In that workthe authors also reported that the closest feature determi-nation may add computational overhead when objectsrotate and the feature sets need to be dynamically changedall the time.

The intrinsic complexity of object-space collisiondetection methods arises from the following.

1. Increased geometric complexity will always result ina significant computational overhead in collisiondetection algorithms, regardless of their efficiency.

2. Special cases must be accounted for, e.g. pseudoVoronoi regions for penetrating surfaces.

3. Complex data structures must be maintained at alltimes, e.g. Voronoi regions, sorted lists, etc.

4. The entire collision detection process takes placeonly in the object space, and much of the informa-tion associated with rendering the scene, stored inthe frame buffer, the Z-buffer and other availableimage buffers, is not used.

These reasons prompted us to search deeper into therendering process for simpler, more efficient and moreelegant collision detection methods that accommodate thehigher complexity of virtual environments. This directedus to look into image-space collision detection methods.

Image-space Collision Detection

The area of image-space collision detection has recentlyopened new avenues for improving the performancebounds.3 The image-space interference test is based onprojecting the object geometry on to the image plane andperforming the analysis in a dimensionally reduced spacewith the depth map maintained in an image buffer such asthe Z-buffer.

Little has been reported on image-space interferencetechniques. The pioneering work of Shinya and Forque1

and Rossignac et al.2 led to a simpler and more efficientalgorithm for interference detection of interacting complexsolid objects. The premise of this work is based on anenhancement in the graphics hardware support. Thisrequires checking the change in the stencil buffer statefrom one frame to the next at the hardware level. If thishardware-assisted test were available, the algorithm pro-posed by Myszkowski et al.3 would be a very practicalsolution to the interference problem between complex

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

Copyright � 1999 John Wiley & Sons, Ltd. 183

solid objects. However, such hardware enhancements arenot currently available.

As our previous experiments show,4 without thehardware-assisted stencil buffer check the collision detec-tion becomes prohibitively slow owing to the very largenumber of redundant memory accesses required to simu-late the change in the stencil buffer state. However, wehave found that it is still practical to use the conventionalstencil buffer and Z-buffer for collision detection providedthat we reduce the region for testing the stencil bufferstate.4 We have improved upon the work done in Refer-ence 4 by (1) further reducing the time for the collisiontest, (2) introducing hierarchical support and (3) handlingsimple non-convex shapes. Hierarchical support refers tothe decomposition of a complex object into its convexconstituents maintained in a tree structure together withthe hierarchical structure of embedded bounding boxes.These are successively checked for interference fromthe top level of the hierarchy down to the individualbounding boxes of the convex constituents.

By fully investigating the relative performance merits ofexisting collision detection systems, we have found thatthe image-based collision detection approach is not onlypractical from the point of view of conventional renderinghardware, but it is also preferred in an enhanced hardwarearchitecture. This is because, when a collision is detected,the computation of the region of interference still requiresa full inspection of the stencil buffer contents. In this workwe focus on image-based interference region computa-tions and, through practical examples, show that it ispossible to perform this task for complex hierarchicalobjects close to frame rendering rates.

The RECODE Algorithm

Our work has been motivated by the results reported byMyszkowski et al.3 We start with the assumption that thebasic primitive blocks of a hierarchical structure areconvex. This ensures that a ray passing through any pixel(x,y) may intersect a basic block at most two points.

We have implemented this algorithm in a general-purpose collision detection system called RECODE(REndered COllision DEtection).

In RECODE we reduce the three-dimensional collisiondetection problem to a one-dimensional interval test alongthe Z-axis based on the principle that a potential interfer-ence at the frame buffer resolution exists if

Rxy(A)∩Rxy(B)�� and Iz(A)∩Iz(B)�� (1)

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

J. Visual. Comput. Animat. 10: 181–192 (1999)

G. BACIU, W. S.-K. WONG AND H. SUN

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

where Rxy(X) is the xy-region occupied by the orthogonalprojection of object X, and Iz(X) is the z-interval occupiedby the orthogonal projection of object X on to the z-axis.

In order to illustrate the basic mechanism of RECODE,we establish the following definitions: MOR(A,B) is theminimum overlapping region of the projection of thevolume occupied by the overlapping bounding boxes ofobjects A and B; VFA is the frame buffer viewportallocated for rendering object A; VZA is the correspond-ing Z-buffer viewport where a depth map (either Zmax orZmin) of object A is stored; VSA is the corresponding maskfor the stencil buffer viewport of object A; VSC is thecorresponding counter in the stencil buffer viewport ofobject A.

The convention for testing the Z-values of two pointsP1 and P2 is as follows: if Z1<Z2 is true, then P1 is closerto the eyepoint than P2 on an orthogonal projectorthrough the pixel (x,y). The algorithm is based on countingthe number of faces of two objects overlapping pixel (x,y)over the interval [Zmin, Zmax(A)]. This implies a singleZ-buffer test

Z(B)�Zmax(A) (2)

where, in a normalized orthogonal viewing volume,Zmin(X) is the minimum Z-value of object X, Zmax(X) is themaximum Z-value of object X, and Z(X) is the Z-value ofthe currently rendered polygonal face of object X.

As shown in Figure 2, first we determine MOR(A,B)and set the rendering viewport VFA to correspond only tothe region covered by MOR(A,B). In the Z-buffer we storethe maximum Z-values of object A by turning off writinginto the frame buffer and rendering A over VZA. This isdone by the function RenderSetZ(A,�) in the algorithmshown in Figure 2. The function RenderSetZ generates the

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

Copyright � 1999 John Wiley & Sons, Ltd. 184

depth map of all the points on the back faces of A bysetting Z(x,y) if Z (A)�Z. This map is then used asreference in the first rendering pass in order to establish aclass of the possible cases of B overlapping A along theZ-axis.

For convex blocks, RECODE tests against eight inde-pendent cases as illustrated in Figure 3. With respect tothe values of Amax�Zmax(A) found in the Z-buffer overVZA, the function RenderTestZ(B,�) uses test (2) in orderto generate any one of the eight possible cases given inFigure 4.

The stencil buffer mask VSA will contain one of thevalues in the set {0, 1, 2, 3} depending on the relativedepth of the faces of objects A and B in the interval [Zmin,Zmax] at (x,y). The stencil buffer over VSA is initialized tozero. If there are no objects at pixel (x,y), then thecorresponding stencil value remains zero. If at least one

Figure 2. The logical flow of RECODE

Figure 3. Possible Z-interval cases and the corresponding stencilbuffer values

v

Figure 4. Testing B against Amax

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

J. Visual. Comput. Animat. 10: 181–192 (1999)

algorithm

IMAGE-BASED COLLISION DETECTION

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

object overlaps pixel (x,y), then the corresponding stencilvalue is incremented to one. In case 1 no face of B overlapspixel (x,y) where object A has a value of Amax. In case 2the range on the Z-axis covered by object B at (x,y), [Bmin,Bmax], does not overlap the interval [Zmin, Amax]. In bothcases 1 and 2 there is no face of B that crosses over intothe interval [Zmin, Amax]. Hence the stencil value at (x,y) isone. In cases 3 and 4 the interval occupied by B overlaps[Zmin, Zmax]. That is, only one face of B crosses over Amax.Hence the stencil value at (x,y) is incremented to two. Incases 5–7 the range occupied by object B lies in theinterval [Zmin, Amax]. That is, two faces of B cross overAmax. Notice that cases 4 and 5 correspond to object Bbeing larger than A and to object A being larger than Brespectively. The details of this algorithm are given inFigure 5.

In the new algorithm we minimize the stencil buffer areathat is required in order to compute the interferenceregions and introduce a hierarchical decomposition oflarger, possibly non-convex structures.

For computing the contact region, we must ensure thatthe depth buffer contains the values of the boundaries ofobject B. In the original algorithm3 the depth values of theboundaries of object A are returned. This happens whenthe second rendering is required. However, for the contactpoints we must have the depth values of the upperboundary of B and the lower boundary of B.

Results

It is well known that comparing collision detection algo-rithms in general can be a very difficult task. As we werebeginning to look into other collision detection algo-rithms, it has become clear that a thorough experimen-tation process has to be established first. A search throughthe literature has not revealed any comprehensive bench-marks that can be used to effectively compare differentcollision detection algorithms. Since we are not currentlyaware of a complete set of benchmarks, nor of rigorousprocedures for testing general-purpose collision detectionalgorithms, we devised some simple measures ofperformance based solely on time, specifically CPU time.These are easy to implement and include in a main driverthat co-ordinates the selection of the specific collisiondetection algorithm. In order to take accurate measures,we implemented a benchmarking environment that con-siders the exact same initial conditions, object geometryand motion paths, both rotation and translation, for allalgorithms.

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

Copyright � 1999 John Wiley & Sons, Ltd. 185

The most difficult task is to keep the number ofcollisions the same or at least within a very narrow rangefrom one algorithm to another. In other words, we mustensure that the motion states do not change significantlyfrom one algorithm to another. For this reason, performinga collision response of any kind may disrupt the testenvironment. Since the motion states of all objects shouldbe maintained the same in all tests, we did not include any

v v

Figure 5. RECODE: an image-based collision detection

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

J. Visual. Comput. Animat. 10: 181–192 (1999)

G. BACIU, W. S.-K. WONG AND H. SUN

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

collision response action, but merely stop the simulation inthe case of a controlled experiment, or let the objectspenetrate each other on an undisturbed motion path forrandomly placed objects in space. Of course, this penetra-tion should be minimal with respect to the object sizes.Therefore we usually stopped the simulations after 100 orat most 500 frames.We have included a microsecond resolution timer andmeasured the total time that each algorithm took in eachframe and the time that each algorithm spent in perform-ing collision detection alone. It is important to observe thetime patterns for both the frame rendering and collisioncomputations, mainly to understand whether the devia-tions from a uniform rate are due to rendering alone orcollision computations. All the time measurements weredone on an SGI Octane workstation powered by a195 MHz R10000 processor with 192 MB of mainmemory.

Comparisons with PreviousImage-based Algorithms

First we would like to answer the question of howsignificant the improvement of RECODE is over theoriginal algorithm of Myszkowski et al.3 These data werecollected on an SGI Indigo2 Extreme workstation with a150 MHz R4400 processor. The data correspond to thenine hierarchical objects shown in Figure 6 for a totalpolygon count of 126 600. For this we include Table 1 forreference. The MIN, MAX and FULL columns correspond

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

Copyright � 1999 John Wiley & Sons, Ltd. 186

to (1) the intersection of the overlapping projections of thebounding boxes, (2) the union of the overlapping projec-tions of the bounding boxes and (3) the entire screen spacerespectively.

During the process of collision detection a significantamount of time is taken to read and check the contents ofthe stencil buffer. It is obvious that checking the entirestencil buffer for interference testing (FULL) leads to avery significant delay of 18·1 s per single buffer read.Testing the stencil buffer from a maximum overlappingregion (MAX) of two objects requires 43·5 ms. This delayis reduced to 35·2 ms when the minimum overlap area(MIN) is used.

Most of the pixels read from the stencil buffer do notcorrespond to a contact area of the objects. The ratio ofthe stencil buffer size to the contact area size is21 760 000:31 in FULL, 498 883:31 in MAX and15 812:31 in MIN. However, the ratio of the depth buffersize to the contact area size is very close, 36:31 in all threecases.

Relative to the original algorithm proposed byMyszkowski et al.,3 whose performance is given in theFULL column, the performance improvement ratio is472:3·1 or approximately 152:1. This is possible due to thereduction of the contact area check over a full screento a much reduced rectangular box given by the MORstructure.

Qualitative Analysis of RECODEPerformance

Figure 7 illustrates three different experiments on thefollowing convex shapes: (a), (b) flat ellipsoids; (c), (d)truncated cones with spherical caps; (e), (f) cones. The barcharts in Figure 8 show the relative performance of theRECODE algorithm as the complexity of the scene,measured as the number of triangular patches, increasesfrom 3600 to 1 152 000 triangles. The darker portions ofbar charts 1 and 2 show the collision time overhead. Thisis the time taken by all the collision computations alone ontop of the rendering time (the lighter portions of the bars).These charts demonstrate two features of the RECODEalgorithm: (1) the collision detection overhead is boundedby the rendering rates, both overall and on average; (2)the collision detection pattern remains very smooth as thecomplexity of the scene increases. This is shown by thestandard deviation charts 3 and 4. This means that duringthe interactive animation sequence there are no prolongedinterruptions in the display rate, as the RECODE algor-ithm maintains the same standard deviation from the

Figure 6. A scene with multiple hierarchical objects

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

J. Visual. Comput. Animat. 10: 181–192 (1999)

IMAGE-BASED COLLISION DETECTION

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

average collision time as the rendering time itself. This isa very important aspect in collision detection algorithms,since it determines the overall quality of the animationwhen collision detection is turned on.

General Comparison against OtherAlgorithms

We performed experiments with I-COLLIDE, RAPID(with all feature pairs turned on), RAPID1 (with only onefeature pair turned on), RECODE and Q-COLLIDE. Thetests are based on measuring the frame time and collisiontime for 100 cones randomly placed in space, but main-taining the same motion paths for all algorithms. As wevary the number of triangles, we observe thatQ-COLLIDE performs the best, both on average andoverall timings, while RECODE is the next best performer,followed in order by I-COLLIDE, RAPID and RAPID1.We observe at this point that in all our experiments with

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

Copyright � 1999 John Wiley & Sons, Ltd. 187

Figure 7. 100 objects in random motion

Area read MIN MAX FULL

Number of:Box–box tests 1661Collision detection tests 26Stencil buffer read 34Contacts 6

Size (pixels):Stencil buffer read 15 812 498 883 21 760 000Depth buffer read 36Contact area 31

Time (s):Total collision detection 0·91 11·3 469Total stencil buffer read 0·34 10·6 464Total comp. contact area 0·005 0·006 0·007Total box–box test 0·033 0·035 0·035Avg. collision detection 0·035 0·044 18·1Avg. stencil buffer read 0·010 0·031 13·6

Time (�s):Avg. comp. contact area 0·9 0·9 1·1Avg. per box–box test 19·8 21·3 21·3

Time (s):Simulation time 3·1 13·5 472

Plain animation (replay) 2·1Time steps 36

Table 1. Performance of MIN, MAX and FULL stencil buffer tests

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

J. Visual. Comput. Animat. 10: 181–192 (1999)

G. BACIU, W. S.-K. WONG AND H. SUN

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

v v v v v v v v

Copyrigh

Figure 8. Collision statistics for random objects and controlled experiments

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

t � 1999 John Wiley & Sons, Ltd. J. Visual. Comput. Animat. 10: 181–192 (1999)188

IMAGE-BASED COLLISION DETECTION

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

random object placement, Q-COLLIDE shows the besttimings, both overall and on average. However,Q-COLLIDE and RAPID tend to be less robust thanI-COLLIDE and RECODE, and in some cases fail com-pletely to detect many collisions, for example in the caseof cones or pointed structures.

In this respect we have noticed some interesting behav-iour. Specifically, in some simple controlled cases thehigh-performance collision detection algorithms such asRAPID and Q-COLLIDE tend to exhibit very largestandard deviations and often fail to detect collisions. Inorder to observe these effects more closely, we developeda simple controlled test called the comb experiment.

The Comb Experiment

The comb experiment consists of two rows of cones withthe same geometric parameters and aligned at the base.We call one row of cones a comb. Various types ofcontrolled motion patterns may be produced by movingone row with respect to the other. However, the mostdesired property of the comb is that we can control thepoints of collision very precisely. For example, since thetip of each cone will sit on the bounding box of the cone,we can observe the collision detections without thebounding boxes of a pair of cones ever intersecting untilthe collision event. We can also generate a motion patternthat produces no collisions but has the bounding boxesoverlap at all times, causing the algorithm to compute theclosest features all the time. While the translation of thecombs with respect to each other keeps the closest featureset constant, their rotation will cycle through all thepossible closest features. Thus the combs can exerciseevery feature of the collision detection algorithm indepen-dently in a controlled fashion. Next we describe the twomost significant comb experiments.

The two combs can be set up to (a) align the cone tipsthrough their axes or (b) offset the cone tips of the twocombs. The cases in which the cones produce interestingpatterns in the performance of collision detection algo-rithms are (1) pure translation and (2) pure rotation of onecomb with respect to the other. We set up twocombs with only five cones each. The most interestingresults we obtained are for cases (a.1) and (a.2) in Figures9 and 10.

In the comb rotation case (Figure 9) we observe theperformance of I-COLLIDE, RAPID, RECODE andQ-COLLIDE. RECODE (broken curve) maintains the bestperformance in all cases above 10 000 triangles, both onthe overall frame and collision times and on the average

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

Copyright � 1999 John Wiley & Sons, Ltd. 189

frame and collision times (Figure 8, charts 5 and 6). This isfollowed in order by I-COLLIDE, Q-COLLIDE andRAPID. The standard deviation (charts 7 and 8) ofRECODE is also the lowest among all algorithms as thenumber of triangles increases.

In the comb translation case (Figure 10), interestingly,Q-COLLIDE cannot find any collision, even though thereare exactly five points of collision between the two combs(due to the five cones in each comb). Therefore we couldnot generate a performance curve for Q-COLLIDE. Thecurves we observed were for I-COLLIDE, RAPIDand RECODE. Again we noticed that above 10 000triangles, RECODE maintains the lowest collision detec-tion time, both overall and on average, followed byI-COLLIDE and RAPID. The standard deviation is also thelowest for RECODE, followed by I-COLLIDE and thenRAPID.

Figure 9. Comb experiment: controlled rotation of aligned combs

Figure 10. Comb experiment: controlled translation of alignedcombs

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

J. Visual. Comput. Animat. 10: 181–192 (1999)

G. BACIU, W. S.-K. WONG AND H. SUN

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

Hand Grasping

For a more typical example we generated the handgrasping sequence shown in Figure 11. Table 2 shows theRECODE performance data set for the hand graspingsequence. In this table, NTR is the total number oftriangles for the scene, TNF is the total number of framesthat the sequence took until all fingers reached a contactpoint with the object grasped, TTF is the total time(including rendering and collision detection) in secondsfor all frames, ATF is the average time per frame in milli-

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

Copyright � 1999 John Wiley & Sons, Ltd. 190

seconds, DTF is the standard deviation of the frame timein milliseconds, TTC is the total collision time in secondsfor the entire sequence, ATC is the average collision timein milliseconds and DTC is the standard deviation of thecollision time in milliseconds.

As we increase the number of triangular patches in themodel, we note that the collision time maintains a fairlylow overhead on top of the rendering time alone. Forexample, from 1860 to 76 032 triangles the averagerendering time goes from 50·1 to 666 ms, but the averagecollision time alone stays well bounded between 17·0 and118·6 ms. The standard deviations for collision detectionalone are maintained under the standard deviation for theframe times. This again indicates a smooth motionsequence.

Conclusions

The results above show that the collision detection inRECODE is bounded by the rendering rates. It is obviousthat the total collision time cannot be bounded in general,as rendering itself is not bounded with the increase in thenumber of objects. However, much of the computationaltime for complex collision patterns can be permeatedthrough the rendering pipeline. In this context we canintroduce a set of parameters to control either the level ofrefinement and accuracy of the collision detection or theanimation time. This flexibility is greater than that given

Figure 11. Hand-grasping actions: initial and final states

NTR TNF TTF(s)

ATF(ms)

DTF(ms)

TTC(s)

ATC(ms)

DTC(ms)

1860 75 3·78 50·1 10·9 1·3 17·0 7·32592 72 4·04 56·7 10·2 1·4 19·9 7·43744 72 4·90 67·8 11·3 1·6 22·0 8·14896 89 6·82 76·9 13·8 2·0 22·8 9·77200 72 6·91 78·6 14·2 1·9 27·0 9·99792 71 8·52 118·6 15·3 2·3 31·8 11·7

10 944 72 9·18 128 15·6 2·4 34·0 12·714 400 72 11·3 156 17·7 2·7 37·5 14·418 720 72 13·7 190 19·2 3·0 41·1 15·621 600 71 15·2 215 21·5 3·3 47·0 18·528 512 71 19·3 272 26·0 3·9 55·3 22·033 632 71 22·6 318 31·2 4·5 63·4 24·942 768 68 26·8 393 34·0 5·2 76·5 30·663 248 68 38·1 550 44·6 6·8 99·7 40·676 032 69 45·8 666 53·4 8·2 118·6 49·9

Table 2. Collision detection performance for two hands grasping a ball

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

J. Visual. Comput. Animat. 10: 181–192 (1999)

IMAGE-BASED COLLISION DETECTION

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

by object-space collision detection alone, since it allows anadditional degree of freedom on the discretization of spaceby simply adjusting the viewport for rendering thecandidate objects for collisions.

In conclusion, we have shown that it is possible toperform collision detection of complex objects at framesrendering rates comparable with the rates of the bestcollision detection algorithms available. We have alsoobserved that among the collision detection algorithmswe have tested, I-COLLIDE and RECODE are the mostrobust, reporting an equivalent number of collisions foreach test. However, RECODE is much simpler to imple-ment and can accommodate a larger class of objects,including surface primitives that can be rendered directlyin hardware.

This promotes a relatively new direction of research inoptimal image-based collision detection algorithms, basedon considering various strategies to compute and mini-mize the MOR between two objects. One such possibilityfor convex objects is to use the separating plane itself asthe image projection plane as well as in reducing theobject rendering time by considering the rendering of theclosest features only, rather than the entire object.

ACKNOWLEDGMENT

Support for this work was provided by RGC grant HKUST598/94E.

References

1. M. Shinya and M. Forque, ‘Interference detection throughrasterization’, The Journal of Visualization and ComputerAnimation, 2, 131–134 (1991).

2. J. Rossignac, A. Megahed and B. O. Schneider, ‘Interactiveinspection of solids: cross-section and interferences’, Compu-ter Graphics (SIGGRAPH ’92), 26(2), 353–360 (1992).

3. K. Myszkowski, O. G. Okunev and T. L. Kunii, ‘Fast collisiondetection between computer solids using rasterizing graph-ics hardware’, The Visual Computer, 11, 497–511 (1995).

4. G. Baciu and S.-K. W. Wong, ‘Rendering in object interfer-ence detection on conventional graphics workstations’,in Proceedings of Pacific Graphics ’97, IEEE, New York, 1997,pp. 51–58.

5. W. C. Thibault and B. F. Naylor, ‘Set operations onpolyhedra using binary space partitioning trees’, ComputerGraphics (SIGGRAPH ’87), 21(4), 153–162 (1987).

6. M. Moore and J. P. Wilhelms, ‘Collision detection andresponse for computer animation’, Computer Graphics (SIG-GRAPH ’88), 22(4), 289–298 (1988).

7. Y. Yang and N. Thalmann, ‘An improved algorithm forcollision detection in cloth animation with human body’,

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

Copyright � 1999 John Wiley & Sons, Ltd. 191

First Pacific Conference on Computer Graphics and Applications,1993, pp. 237–251.

8. A. Garcia-Alonso, N. Serrano and J. Flaquer, ‘Solving thecollision detection problem’, IEEE Computer Graphic andApplications, 13(3), 36–43 (1994).

9. S. Gottschalk, M. Lin and D. Manocha, ‘OBBTree: a hier-archical structure for rapid interference detection’, ComputerGraphics (SIGGRAPH ’96), 30, 171–180 (1996).

10. J. F. Canny, ‘Collision detection for moving polyhedra’, IEEETransactions on Pattern Analysis and Machine Intelligence,PAMI-8, 200–209 (1986).

11. B. Chazelle and D. P. Dobkin, ‘Intersections of convexobjects in two and three dimensions’, Journal of the ACM,34, 1–27 (1987).

12. E. G. Gilbert, D. W. Johnson and S. S. Keerthi, ‘A fastprocedure for computing the distance between objects inthree-dimensional space’, Journal of Robotics and Automation,4, 193–203 (1988).

13. B. V. Herzen, A. H. Barr and H. R. Zats, ‘Geometric collisionfor time-dependent parametric surfaces’, Computer Graphics(SIGGRAPH ’90), 24(4), 39–48 (1990).

14. M. C. Lin and J. F. Canny, ‘Efficient collision detection foranimation’, Third Eurographics Workshop on Animation andSimulation, Cambridge, September, 1992.

15. J. Snyder, A. R. Woodbury, K. Fleischer, B. Currin and A. H.Barr, ‘Interval methods for multi-point collisions betweentime dependent curved surfaces’, Computer Graphics (SIG-GRAPH ’93), 27, 321–334 (1993).

16. M. J. Zyda, D. R. Pratt, D. Osborne and J. G. Monahan,‘NPSNET: real-time collision detection and response’, TheJournal of Visualization and Computer Animation, 4, 13–24(1993).

17. S. Bandi and D. Thalmann, ‘An adaptive spatial subdivi-sion of the object space for fast collision of animatedrigid bodies’, Eurographics ’95, Maastricht, August, 1995,pp. 259–270.

18. J. Cohen, M. Lin, D. Manocha and M. Ponamgi, ‘I-COLLIDE:an interactive and exact collision detection system forlarge-scale environments’, in Proceedings of ACM Interactive3D Graphics Conference, ACM, Monterey, CA, 1995, pp.189–196.

19. P. M. Hubbard, ‘Collision detection for interactive graphicsapplications’, IEEE Transactions on Visualization and ComputerGraphics, VCG-1, 218–228 (1995).

20. M. Ponamgi, D. Manocha and M. C. Lin, ‘Incrementalalgorithms for collision detection between general solidmodels’, in Proceedings of ACM/SIGGRAPH Symposium onSolid Modeling, ACM, Los Angeles, CA, 1995, pp. 293–304.

21. S. Gottschalk, ‘Separating axis theorem’, Technical ReportTR96-024, Department of Computer Science, UNC ChapelHill, 1996.

22. S. Cameron, ‘Collision detection by four-dimensional inter-section testing’, IEEE Transactions on Robotics and Automation,RA-6, 291–301 (1986).

23. K. Chung and W. Wang, ‘Quick collision detection ofpolytopes in virtual environments’, in Proceedings of ACMSymposium on Virtual Reality Software and Technology, ACM,Hong Kong, 1996, pp. 125–132.

24. T. Hudson, M. Lin, J. Cohen, S. Gottschalk and D. Manocha,‘V-COLLIDE: accelerated collision detection for VRML’, inProceedings of VRML ’97, ACM, Monterey, CA, 1997.

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

J. Visual. Comput. Animat. 10: 181–192 (1999)

G. BACIU, W. S.-K. WONG AND H. SUN

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

Authors’ biographies

George Baciu received a BMath degree in applied mathematicsand computer science and MASc and PhD degrees in systemsdesign engineering at the University of Waterloo, Canada. He iscurrently with the Department of Computer Science at the HongKong University of Science and Technology where he has beenon the faculty since 1993. His research interests are collisiondetection and topological analysis for computational multibodydynamics problems, mesh generation and image synthesis forlarge-scale virtual environments, simulation and entropy optimi-zation methods in probabilistic systems. He is a member of IEEEand ACM.

Wingo Wong received a BEng degree and an MPhil degree incomputer science from the Hong Kong University of Science andTechnology (HKUST) in 1996 and 1999 respectively. He is

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

Copyright � 1999 John Wiley & Sons, Ltd. 192

currently pursuing a PhD degree at the same university. Hisresearch interests are collision detection in 3D environments,volume rendering and image-based rendering.

Hanqiu Sun received a BS degree in electrical engineering fromHuazhong University of Science and Technology, China. Shereceived an MS degree in electrical engineering from theUniversity of British Columbia and a PhD degree in computerscience from the University of Alberta, Canada in 1992. Dr Sunjoined the Computer Science and Engineering Department ofCUHK in August 1996. She has published more than 50 refereedpapers in international journals, book chapters and conferences.Her current research interests include interactive behaviouralanimation, virtual reality, hypermedia, computer-assisted sur-gery, internet-based visualization and navigation, and roboticssimulation.

v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v

J. Visual. Comput. Animat. 10: 181–192 (1999)