Rapid detection of shallow penetration between non-convex polyhedra by KRISHNAN SRIRAM B. Tech, Indian Institute of Technology, Madras, 1999 (Gold Medalist) SUBMITTED TO THE DEPARTMENT OF MECHANICAL ENGINEERING IN PARTIAL FULFILMENT OF THE REQUIREMENTS FOR THE DEGREE OF MASTERS IN MECHANICAL ENGINEERING C~fn- ..J at the MASSACHUSETTS INSTITUTE OF TECHNOLOGY 24 September 2001 © 2001 Massachusetts Institute of Technology. All Rights Reserved. MA ACHusms INSTITUT Of TECHNOlOGY I LIBRARIES ~. A ~ Author ......................................... ~4••~~~ •••• ~ •• ':'"•••.,........~ •••••••••••••••••• Department of Mechanical Engineering /J /) 24 September 2001 Certified by ................................ / .......-...{J ..-.... <:.J•••••••••••••••••••••••••••••••••••••••••••• -Prof. Sanjay E Sarma Cecil and Ida Green Associate Professor,Dept of Mech. Engg Thesis Supervisor Accepted by .......................................~ ___ .. _._ .. _______________________________ ....... . Prof. Ain A. Sonin Chairman, Department Committee for Graduate Students MASSACHUSETTS INSTITUTE OF TECHNOLOGY [ JUl 0 8 2003 LIBRARIES 1 AR~HlVES 2 Rapid detection of shallow penetration between non-convex polyhedra by Krishnan Sriram Submitted to the Department of Mechanical Engineering in partial fulfillment of the requirements for the degree of Master of Science in Mechanical Engineering. Abstract Several engineering problems and applications in computer graphics, robotics and haptic simulations are related to the problem of interaction between solids in the virtual environment. While collision "detection" refers to checking if two objects have a non-empty intersection set, we are more interested in the topic of collision "avoidance" where correction measures are also proposed to remove two objects from collision. Some of the challenges in this topic include the computational complexity of existing algorithms for handling non-convex polyhedra, the difficulty in implementing purely mathematical algorithms in an engineering problem and also in tuning the collision algorithm to match the requirements of graphics and haptics applications. Based on the real-world applications, we restrict our attention to shallow penetration between solids. We use solid models in the form of a boundary representation. The data structures are built, while being aware of errors introduced in floating point arithmetic. A bounding volume hierarchy is introduced to identify locations where collisions are not expected to occur, so that computations could be restricted to other specific locations. Accuracy of any collision avoidance method is related to verifying proximity between the various geometric entities. Proximity is determined by computing the Voronoi diagram in the solids and we have incorporated Voronoi verification both implicitly and explicitly. This has been the main contribution of this thesis where we have incorporated "depth information" in the form of surface offsets and also identified the connection to Voronoi diagrams. Wherever penetration occurs, we compute the depth of penetration and use all the depth values to compute an overall collision avoidance schema. Our collision avoidance approach is based on a weighted correction method. Such a correction method attempts to reduce the extent of penetration between the two solids and brings the objects out of collision within a few iterations. Our research has resulted in a new collision algorithm which is not dependent on the convexity of the objects and which matches the requirements of graphics and haptics applications. Thesis Supervisor: Prof. Sanjay E Sarma Title: Cecil and Ida Green Associate Professor, Department of Mechanical Engineering. 4 This thesis is dedicated in fond memory of my physics teacher Prof S. Balasubramaniam 6 Acknowledgements This work was supported by the Suzuki Motor Corporation. I thank them for their financial support. It has been my privilege to have worked with Prof. Sanjay Sarma as my research advisor. Sanjay has been a friend, a motivator and a mentor to me; inspiring me to set the bar high and guiding me in reaching the goals set forth. Sanjay's contagious enthusiasm at work and his emphasis on professionalism have helped in molding me for the better. I am greatly indebted to him for his patience and his encouragement during the entire course of my Masters' work. I wish to express my gratitude to our research colleagues at Suzuki Motor Corporation Mr. Yoshitaka Adachi, Mr. Akio Ikemoto and Mr. Takahiro Kumano. I was moved by their hospitality during my stay at Yokohama during the summer of 2000. Their constant support and hard work have contributed significantly to the successful completion of this project. I thank Prof. Samir Nayfeh, Prof. David Trumper and Prof. Krzystof Marciniak for their kind words of advice. My labmates have been an integral part of my stay at MIT. I thank my lab seniors Mahadevan Balasubramaniam, Stephen Ho, Taejung Kim, Seung-Kil Son and Elmer Lee for educating me and taking me through the initial steps of research. Kirti Mansukhani proof-read my thesis and I appreciate her kind assistance. I have enjoyed many spirited discussions with Prahladh Harsha, Venkatesan Guruswami, Harish Rajaram, John Dunagan, Kripa Varanasi and Laurence Vigeant-Langlois, which helped me in my research. Appa, amma and Suji have always instilled faith and confidence in me and encouraged me during my highs and lows. The Almighty God knows how many times they have believed in me when I myself didn't. I am also happy to have great friends as Alan, Rama, Amy, Jaya and Olga to egg me at all times to do things better. 8 Contents Chapter 1 Introduction - - - - - - - - - - - - - - - - - - - - - - 15 1.1 Geom etric interference ......................................... 1.2 Where do we apply 3D object separation? .......................... 1.2.1 Connection to Linear Programming ......................... 1.2.2 Robotic Path Planning .................................... 1.2.3 Collision Free 5-Axis tool path generation .................... 1.2.4 Real time interaction with haptic systems ..................... 1.3 Overview of the thesis ......................................... 15 15 16 16 16 17 17 Chapter 2 Background - - - - - - - - - - - - - - - - - - - - - - 19 2.1 Real World objects vs. Mathematical models ........................ 2.1.1 Object representations and their complexity ................... 2.1.2 Object as raw data ...................................... 2.1.3 Representation of the surfaces of objects ..................... 2.1.4 Representation as combination of solid shapes ................. 2.2 Collision detection between solid models ........................... 2.3 Computationally efficient object representations ..................... 2.3.1 Dobkin-Kirkpatrick hierarchy for convex objects ............... 2.3.2 Common Bounding volumes ............................... Convex hull ......................................... Alpha shapes ........................................ Axis-Aligned Bounding Box ............................ Octree ............................................. Oriented Bounding Box ................................ K-Discrete Orientation Polytope ......................... 2.4 History of Separation Algorithms ................................. 2.4.1 Closest pair problems between pointsets ...................... 2.4.2 Minkowski separation of convex objects ...................... 2.4.3 Gilbert Johnson Keerthi algorithm .......................... 2.4.4 Steven Cameron's work on enhanced GJK .................... 19 20 20 21 23 26 27 29 29 30 31 31 33 34 35 37 37 37 38 39 2.4.5 Dobkin-Kirkpatrick hierarchy for overlap detection [Dobkin 85] 2.4.6 2.4.7 2.4.8 2.4.9 2.4.10 Edelsbrunner's idea of min/max distance between convex objects . . 39 Collision detection algorithms in robotic applications ........... 39 C J Ong's Growth Distances ............................... 40 Lin-Canny's algorithm for incremental distance computation ..... 41 Pseudo-Voronoi diagram idea of Ponamgi [Ponamgi 97] ........ 42 . . 39 2.4.11 Detection is easier than computation - the caveat ............... 43 2.4.12 Pellegrini's Batched Ray Shooting algorithm .................. 2.4.13 Mirtich's V-clip algorithm [Mirtich 98] ...................... 2.4.14 Space-Time Bounds and 4-D Geometry ...................... 43 43 44 2.4.15 Collision detection among multiple moving spheres [Kim 98] 2.4.16 Impulse-based approach .................................. 2.4.17 Adaptive Distance Fields and Volume rendering ............... 2.4.18 Real-time 5-Axis collision detection ......................... 9 .... 45 45 46 46 Idea of a generic tool model ............................. 47 Modelling common milling tools with the same set of parameters 47 Constant shoulder diameter tools ........... .............. 47 Tools with taper ..................................... 49 2.4.19 Collision Detection between 3D polyhedra .................... 50 2.4.20 Surveys of Collision Detection algorithms .................... 50 2.5 Motivation for our work ....................................... 50 Chapter 3 Summary of Explored Concepts - - - - - - - - - - - - 53 3.1 Decomposition of the surface .................................... 3.2 Algebraic approximation of discrete points on a surface ................ 3.3 Voronoi diagrams ............................................ 3.3.1 Shell rather than a solid .................................. 53 54 55 55 Chapter 4 Our Approach - - - - - - - - - - - - - - - - - - - - - 57 4 .1 Input ........................................................ 4.1.1 Solid models .......................................... 4.1.2 Algorithm input ........................................ 4.2 Data structures and models ..................................... 4.3 Pre-processing .............................................. 4.4 Homeomorphism and Shallow Voronoi diagrams ..................... 4.4.1 W hy shallow penetration? . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.2 Voronoi diagrams as an expanding wavefront ................. 4.5 Offset surfaces .............................................. 4.5.1 Offset of an algebraic surface .............................. 4.5.2 Offset of a triangulated surface ............................. Averaged surface normal approach ....................... Localized paraboloid normal ............................ Offset of planes approach ............................... 4.6 Bounding volumes with depth information .......................... 4.6.1 . . . . . 57 58 59 59 60 60 ... 61 61 61 62 62 63 63 63 64 Where do the bounding volumes of surface representations fail? . . . 64 4.6.2 Add depth to bounding volumes using offset .................. 4.7 Implicit Voronoi Verification - Our Conjecture ...................... 4.8 Explicit Voronoi Verification - A Robust Approach ................... Chapter 5 Penetration detection and avoidance - 65 66 67 - - - - - - - - - 69 5.1 Outline . . .................................. .......... 69 5.2 Sizes of data structures ........................................... 69 5.2.1 Broad phase ................................. 70 ........... 5.2.2 N arrow phase ................................ ........... 71 5.2.3 Adaptive approach in updating bounding volumes and object models 72 5.3 Collision Avoidance ................................ 72 ........... 5.4 Measures of complexity of collision detection algorithms ... ........... 73 Chapter 6 Results- - - - - - - - - - - - - - - - - - - - - - - - - 77 6.1 Implementation of our algorithm ....................... 6.1.1 Philosophy of bounding volumes ................ 6.1.2 On the choice of directions of a k-DOP ............ 6.1.3 Shallow penetration ........................... 10 .......... ........... ........... ........... 77 78 80 80 6.1.4 Efficient coordinate transformation .......................... Transformation of the dynamic object ..................... Transformation of the bounding volumes................... Broad decision trees .................................. 6.2 Applications ................................................ 6.3 Scope for future work ......................................... 81 81 81 82 82 83 References - - - - - - - - - - - - - - - - - - - - - - - - - - - - 85 Appendix A : Terminology ........................................... Appendix B : Inaccuracy in the update of k-DOPs ......................... Appendix C : Tangency of Voronoi parabola in a tapered tool ................ 11 91 95 97 12 List of Figures Figure Figure Figure Figure Figure Figure l 2 3 4 5 6 Representation of a cube - - - - - - - - - - - - - - - - - - - - - - - 20 Polygon soup model - - - - - - - - - - - - - - - - - - - - - - - - - 21 Voxel model of a hand and the actual geometric model - - - - - - - - 23 Binary Space Partition tree model of a cylinder capped with a hemisphere 24 CSG model of a cylinder capped with two hemispheres - - - - - - - - 25 Swept volume and Extrusion of a polygon in x-y plane moving along a line with non-uniform velocity - - - - - - - - - - - - - - - - - - - - - - - - - 26 Figure 7 Two objects don't overlap if their bounding volumes don't overlap - - - 28 Figure 8 Figure 9 Figure 10 Figure 11 Figure 12 Figure 13 Figure 14 Figure 15 Figure 16 Figure 17 Figure 18 Figure 19 Figure 20 Figure 21 Convex hull of a set of points in R2 - - - - - - - - - - - - - - - - - - 30 Axis-aligned bounding box tree - - - - - - - - - - - - - - - - - - - - 32 Quadtree representation of an object - - - - - - - - - - - - - - - - - 33 An octree model and the corresponding tree - - - - - - - - - - - - - - 34 Oriented and Axis Aligned Bounding Box for the same shape - - - - - 35 The various k-DOPs - - - - - - - - - - - - - - - - - - - - - - - - - 36 8-DOP update between orientations - - - - - - - - - - - - - - - - - - 37 Minkowski difference between a pentagon and a triangle - - - - - - - 38 S-tope of two robotic arms [Pobil 96] - - - - - - - - - - - - - - - - 40 Parametrizing the growth and shrinking of a rectangle - - - - - - - - - 41 Boundary and Co-boundary for a vertex and a face - - - - - - - - - - 42 Common milling tools - - - - - - - - - - - - - - - - - - - - - - - - 47 Modelling the cutter tip of milling tools shown in [Figure 19] - - - - - 48 Correction directions for various Voronoi regions within an axially symmetric tool - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 49 Tapered portion of a cutting tool - - - - - - - - - - - - - - - - - - - 49 Convex decomposition is not unique - - - - - - - - - - - - - - - - - 54 Surface representation is a "Shell" - - - - - - - - - - - - - - - - - - 55 STL file format and syntax - - - - - - - - - - - - - - - - - - - - - - 59 A surface patch is homeomorphic to a planar triangulation - - - - - - - 60 Offset of a curve - - - - - - - - - - - - - - - - - - - - - - - - - - 62 Localized paraboloid around a vertex in a tessellation. The normal for the vertex is found from the normal to the paraboloid. - - - - - - - - - - - 63 Objects are overlapping even though bounding boxes don't - - - - - - 65 When combined with offset surface, bounding volume carries depth information - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 66 Bounding box encloses the original triangle and its "image". It also implicitly bounds the Voronoi planes the extremes.- - - - - - - - - - - - - - -- 67 Very close to the surface, the Voronoi planes can be associated with a distinct edge on the tessellation.- - - - - - - - - - - - - - - - - - - - - - -68 The diagonals of the rhombus drawn with the two normal vectors as adjacent sides are directly related to the Voronoi plane between the planes whose normals are n, and n 2 - - - - - - - - - - - - - - - - - - - - - - - - - - 68 Figure Figure Figure Figure Figure Figure Figure 22 23 24 25 26 27 28 Figure 29 Figure 30 Figure 31 Figure 32 Figure 33 Figure 34 Broad phase and narrow phase of our collision detection algorithm - - - 71 Figure 35 Iterative nature of our collision avoidance scheme - - - - - - - - - - - 73 Figure 36 Voronoi diagram for the tapered portion of a cutting tool - - - - - - - - 97 13 14 Chapter 1 Introduction 1.1 Geometric interference The computation of spatial relationships between geometric objects is a fundamental problem in many areas as robotics, computer-aided design, circuit design and layout, computer graphics and virtual reality. The problem of intersection detection has been the focus of several algorithms and applications. Intersection detection amounts to determining whether two geometric objects share a non-empty intersection and if so, to compute a measure of the same. It is broadly classified into two realms: First, detecting whether two geometric objects are intersecting and second, computing some measures of intersection between the two intersecting objects. While there is extensive work in the area of detecting intersections between geometric objects, there has been very little work in the topic of computing measures of penetration. In this research, we study the problem of detecting penetration between non-convex polyhedra in three dimensional space and computing measures of correction which shall remove their state of overlap and intersection. We present a collision avoidance algorithm which is oblivious to specific properties of the object such as convexity, size or shape etc. We have used surface representations of objects as input and have invented techniques to ensure accuracy when we handle surface representations in collision detection algorithms. Several efficient optimization techniques have also been implemented in the algorithm to increase the computational efficiency. 1.2 Where do we apply 3D object separation? Detecting intersections, or Collision Detection has surfaced in several engineering problems. Some of these problems, which served as motivation for the current research, are presented here. 15 1.2.1 Connection to Linear Programming The problem of detecting separation between three dimensional convex objects can be modelled as a linear programming problem. If two convex objects are separated in Rd, then there exists a hyperplane which separates the two objects. The problem of detecting if a solution exists in Rd for a point satisfying simultaneous constraints against several hyperplanes is equivalent to the problem of determining whether two convex bodies are not intersecting in Rd. Megiddo [Megiddo 83] proposed that linear programming can be solved in linear time when the dimension is fixed. Megiddo addressed the Separability Problem, which is the problem of separating two sets of Rd by means of a hyperplane. The separability problem in Rd is solvable by linear programming in d variables. Megiddo [Megiddo 83] presents a linear time algorithm for linear programming when d 3. Shamos [Shamos 1975] conjectured that "...the proper attack on a geometry problem is to construct those geometric entities that delineate the problem... ". This is true in many cases when fundamental geometric entities such as convex hull, the voronoi diagrams are useful. Unfortunately, this conjecture led Shamos to the wrong result that linear programing necessitated constructing the convex hull and was not solvable in a time better than Q(n log n). Megiddo contradicted Shamos' lower bound for linear programming in fixed dimensions. 1.2.2 Robotic Path Planning Collision detection is an essential component of robotic path planning and control, where it helps to steer the robot away from its surrounding obstacles. In path planning, the problem is one of finding a path for the robot through an environment of obstacles such that at no instance does the robot collide with any object in the surrounding environment. For the path planning problem, computing a feasible path amidst all the obstacles is itself quite complex. Additionally, if one has to find the optimal path, the problem is more complicated. A common approach is to detect collisions of the entire swept volume in a given time duration against the environment. However, this approach proves to be ineffective when multiple objects are moving simultaneously. Another approach proposed is an equivalent 4-dimensional problem which is very effective with elementary primitives such as spheres. When we have complex objects, such an approach is exhorbitantly expensive. Another solution to the problem involves the creation of the C-space (configuration space) and identifying feasible regions in the same. We observe that in all these approaches to path planning, detecting collisions and intersections between the objects forms the crux. 1.2.3 Collision Free 5-Axis tool path generation Balasubramaniam [Balasubramaniam 99] proposed the idea of Collision free 5-Axis tool path generation. It amounts to generating tool paths for 5-axis machining such that at any instant, the cutting tool or the holder and spindle does not collide with the finished surface and remove material unnecessarily. Current tool path generation software suffer from this problem, called gouging. Current commercial software packages create a toolpath without checking if the tool or any part of the tool holder gouges against the final fin- 16 ished product. A collision free 5-Axis toolpath will have to first check for collisions between the tool, the tool holder, the spindle and other machine parts against the final shape of the finished object. This is accomplished by checking for collision between the solid model of the tool and the solid model of the workpiece, for each configuration of the tool. Balasubramaniam and Ho [Balasubramaniam 00] present an integrated approach employing a haptic interface to generate collision-free 5-Axis tool path generation software. 1.2.4 Real time interaction with haptic systems Haptic systems mimic the sense of touch. A user holds the haptic probe or glove and moves around in space and the haptic device provides force feedback at each location. Virtual reality simulations involving force-feedback devices depend immensely on collision detection algorithms. These simulations attempt to create the forces which are typically created in a physical system. Detecting collisions between the objects in the virtual world and determining realistic contact forces are necessary in order to fake physical systems using virtual reality. Haptic systems impose strict conditions on the accuracy of the collision detection algorithm, so that the forces generated are as realistic as possible. Research on human interaction with haptic devices has proven that a force update rate of 1000 Hz is essential for a vibration-free experience of the human operator. As a result, haptic systems are a particular application of collision detection algorithms which impose very stringent requirements on both the accuracy and speed. In summary, the problem of detecting intersections between objects, though mathematical in nature, has a diverse set of applications. These applications, such as path planning, Separability problem, haptics are seemingly unrelated. Path planning algorithms require mere reporting of the intersections while haptic applications require computing measures of correction. However, cumulatively they refine the statement of the collision detection and avoidance problem. We are able to better define our problem of detecting penetration between non-convex polyhedra by understanding such requirements imposed by the applications. 1.3 Overview of the thesis Chapter 2 presents the background for this research. While studying geometric interference between 3D objects, it is necessary to be familiar with geometric modeling techniques and the complexity involved with the collision detection problem. Section 2.1 introduces solid modeling techniques and Section 2.2 elaborates on the complexity of using different solid models for the collision detection problem. The problem of geometric interference detection and collision detection as it is more commonly referred to, has been the topic of a great deal of contemporary research. Section 2.4 has a brief description and comparison of the various algorithms that have been proposed for this problem. Chapter 3 lists the initial concept development. Though most of these concepts were not adopted in the final design of our algorithm, they played an important role in the understanding of the problem, and are presented here for sake of completeness. 17 Chapter 4 explains the details of our algorithm. Chapter 5 includes the pseudocode for the algorithm and the various analyses that were performed on the algorithm. Chapter 6 presents the conclusions and the main contributions of this thesis. 18 Chapter 2 Background The objective of our research has been to detect measures of penetration between two generic three dimensional solids and to provide corrective measures to disengage two objects under intersection. By the term "generic solids", we imply that no specific assumption is made about the solids or their mathematical representations thereof. The algorithm should be able to receive as input any representation of the solids. No assumptions should be made such as that the solid is a CSG model. In the first half of this chapter, we introduce the notion of geometric modelling of three dimensional solids. Understanding the applicability of various solid modeling techniques for applications of collision detection and the optimizations that are done to save computational effort are detailed next. The remainder of the chapter discusses the bulk of research that has been carried out in related areas. We provide a summary of contemporary research and clearly delineate the uniqueness and importance of our research. 2.1 Real World objects vs. Mathematical models Geometric modelling involves the mathematical representation of real-world solid objects. The objects we are typically concerned with in engineering range from machine elements having a simple geometry to complex assemblies such as ships and aircrafts which have a very complicated geometry. Shapes and geometry, while being obvious for human perception, have to be represented so that computers can recognize them and mathematical operations could be performed on them. Geometric modelling attempts to provide a complete, flexible and unambiguous representation of an object. We present here the common methods of representing three dimensional solids as mathematical models. Each object representation has its own set of applications. We observe that there isn't "an exact representation" available for a generalized 3-D solid. Even a simple part like a shaft has fillets, undercuts and chamfers, which are very difficult to represent accurately. For most engineering applications, the exact representation turns out to be computationally complex and cumbersome. Since exact representa- 19 tions are generally too difficult to handle, mathematical models at varying degrees of abstraction and complexity are used to suit the application. 2.1.1 Object representations and their complexity Jordan Brouwer Separation theorem states that "any solid object divides space into two regions the interiorand exterior". The boundary between the interior and the exterior of the solid is the surface of the solid. Current mathematical models for solid object representation provide ways of representing geometric entities on the surface of an object or provide a set of geometric primitives which combine to define the solid in three dimensional space. The following sections describe the various methods employed for object representation. These methods are classified based on the level of abstraction and richness of information about the object. 2.1.2 Object as raw data In this method of representation, a lump-sum collection of entities represents the object. There may not be an explicit relationship defined between individual data elements. The topology of the solid is not also explicit from the raw data set. Point Cloud A point cloud is an unstructured set of points, without any connectivity and topology information. In three dimensions, a solid could be defined using a cloud of points scattered on its surface. The point cloud would then typically consist of a set of n points, given by their x,y,z coordinates. A point cloud has no additional topological information apart from the location of points on the surface. Given only the coordinates, one is not able to infer any additional detail about the surface. There is no topology information available because the set of points is stored in no sequence or order. There is no distinct division between interior and exterior.In common parlance, one finds that a point cloud is not a water-tightrepresentation. A water-tight representation of an object is one which makes a clear distinction between interior and exterior. Given a query point and a point cloud, one is not able to immediately tell if the point is within the point cloud or not. Further, the query point could move between the points of the point cloud and go undetected. The absence of connectivity and topology information makes the point cloud unsuitable for many applications. Point Cloud Wireframe Figure 1 Representation of a cube 20 Polygon soup In a polygon soup representation, the surface of the solid is approximated with a set of polygons. The surface itself is the union of all these polygons. The polygon soup is an unstructured set and the representation carries no information on connectivity. The adjacency information of each polygon, edge or a vertex is not explicitly available. If it is known apriori that the given surface has no abnormalities such as tears or holes, then a polygon soup provides a clear demarcation between the interiorand exterior.It is similar Array of pointers to Polygons Object Polygon Vertex 1 Vertex 2 ... Vertexk Figure 2 Polygon soup model to a point cloud with the only difference that the point is replaced by a planar polygon. Range Image A range image is a set of points in three dimensions mapped to pixels of an image. The object representation is obtained from an image processing tool such as a scanner. This representation is particularly suited for applications in computer graphics, optical scanning and imagery. Range images carry the information of distance from the graphics viewport to the objects. While there isn't specific information about the interior of the objects, it is possible to infer insideness and outsideness. 2.1.3 Representation of the surfaces of objects Section 2.1.2 presented objects as an unstructured data set. Given the nature of such a representation, one has to extrapolate all additional information from the data. In this section we discuss object representation methods which clearly delineate the surface of objects. Surface of real world objects are smooth and continuous. Surfaces whose properties are known ahead, for eg. design surfaces, can be represented as a continuum in the form of algebraic functions. Surfaces for which there are no properties known ahead, for instance a mechanical assembly, are converted into tessellations and polygonal meshes. This is a linear approximation of the surface where the curved sector between a set of 21 points is approximated with a polygon through those points. Such an approximation is commonly carried out in engineering applications such as Finite Element method and computer graphics rendering. B-Rep B-rep stands for boundary representation. Any closed homogenous 3-D solid could be represented completely by its surface. Boundary representation is a set of adjacency relationships among the topological entities on a surface. The winged-edge representation is one of the ubiquitous boundary representations. Another equally popular representation scheme is the indexed mesh, where the surface is represented as a mesh passing through vertices and carrying their adjacency information. Weiler [Weiler 85] and Woo [Woo 85] discuss the efficiency of various B-Rep data structures from the point of view of spacetime complexity. Meshes A mesh is a set of connected polygonally bounded planar surfaces. These polygons could represent a part or the whole of the surface. The set of polygons sharing an edge or a vertex is directly available in the form of adjacency lists. But there is no explicit information about surface abnormalities such as holes and tears. As such, a mesh need not represent a closed surface. If one is sure that the solid has no holes or tears, then the mesh contains the unambiguous separation between interiorand exterior.If each edge is shared by exactly two polygons and each vertex by at least three polygons, then it can be proven that the surface has no abnormalities such as a tears or non-manifoldness. Parametric surfaces Parametric surfaces are continuous surfaces defined by coordinates of points on them, which themselves are functions of a parameter. A parametric surface is represented by the set of coordinates r = (x, y, z) of points on it such that x = x(t), y = y(t), z = z(t), where t is any real parameter. Common types of parametric surfaces include Bezier surfaces, Bspline surfaces and tensor product spline patches, such as NURBS. Implicit surfaces An implicit equation is any algebraic equation defined on a set of variables, of the form f( ) = 0. In R 3 , an implicit equation is of the formf(x,y,z) = 0 where x, y, z represent the cartesian coordinates in space. Points (xo,yo,zo) that satisfy f(x,y,z) = 0 form a surface in space. This surface is called an implicit equation defined surface, or implicit surface. The advantange of implicit surfaces lies in the clear demarcation of interior and exterior. Usually, f( ) > 0 refers to the exterior of the surface. Further, if f(x,yz)= 0 represents the implicit surface, then n =_ Vf 1A1(xo, YO, ZO) 22 represents the surface normal at a given point (xo, yo , zo). For a point not on the surface, f(xo, yozo) is the distance from the point to the surface. Implicit surface representation could include a continuous algebraic surface or a set of piecewise continuous algebraic surface patches. Implicit equations, while being excellent tools for mathematical analysis of curves and surfaces, do not have a significant role in collision detection applications. There are not many real world solids which can be very precisely represented by a set of implicit surfaces. The problem of fitting a smooth surface to a given set of points has been a topic of contemporary research [Krishnamurthy 98] . When modelling interference detection between axially symmetric objects and an unknown terrain (environment), implicit surfaces prove very useful and accurate[Ho 99] . These problems have applications in numerically controlled machining, probing virtual environments etc. 2.1.4 Representation as combination of solid shapes In this section, we present object representation where three-dimensional entities serve as building blocks. Some of these basic three dimensional entities include cube, sphere, cylinder, cone and half-spaces. Voxel The voxel model of solids is also referred as the Spatial Occupancy Enumeration model. The solid is modeled by a uniform grid of volumetric sample cells, called voxels. This object representation is memory intensive. Space is divided into voxels and the object is classified by each voxel being inside/outside or partially inside the object. Each voxel is characterized by the coordinates of a single point, either a specific corner or the centroid of the voxel. Figure 3 Voxel model of a hand and the actual geometric model 23 BSP tree BSP tree, or Binary Space Partition tree, divides space in a binary fashion. The BSP tree representation consists of a tree whose root node includes the universe of space available and each child node having of a set of decision equations progressively partitions space. Such a division is carried on until the desired region occupied by the object is reached. The union of all the leaf level nodes constitutes the object being modelled. Figure 4 shows an Binary space partition model of an object in the form of a cylinder capped with a hemi-sphere. BSP trees need not be balanced, i.e., all the leaf level nodes need not be at the same depth in the tree. x =0 x>O x 0 y +z x2 2 y2+z2-1 4=0 -1=0 y +z 0 ->0 x2 +y 2+z2 -4 0x-6= 0 x60/X : intenio r] 0 exterio r 1 -6 >0 0 Figure 4 Binary Space Partition tree model of a cylinder capped with a hemisphere CSG Constructive Solid Geometry is a hierarchy of regularized Boolean operations applied to a set of standard geometric primitives. The CSG model of a solid is in the form of a tree, whose leaf nodes are the geometric primitives and internal nodes are Boolean operators. In some variants of CSG, transformations in the form of rotation and translation are also applied to the geometric primitives. Figure 5 has an example of a CSG model of a cylinder with two hemispherical ends. CSG is a useful and concise technique for solid modelling. The conciseness also results in some of the shortcomings of this representation. Firstly, there is not an explicit boundary information in a CSG model. The boundary information has to be specifically extracted from the geometric primitives. The procedure becomes additionally complicated 24 when some parts of the geometric primitives get altered in the final solid model due to the Boolean operations. Any overlap detection query requires boundary information of the solid and hence, CSG yields itself unsuitable. Further, CSG has a limited range of solid models that can be represented. The geometric primitives are typically bounded by a number of lower order algebraic surfaces. In particular, CSG can not be used to model freeform surfaces, which are commonly encountered in machining processes. Third, converting from a B-Rep to a CSG model amounts to "pattern recognition", which is a difficult problem to solve. As an attempt to use CSG models in overlap detection, Cameron introduced the idea of S-bounds [Cameron 91] . C QuI U U Figure 5 Constructive solid geometry model of a cylinder capped with two hemispheres Swept volumes and extrusions A swept volume is defined as the volume included within an object following a trajectory in space. It represents the region in space which is traversed by an object in motion. 25 With specific reference to robotic path planning, swept volumes are used to determine collision free paths and also to determine feasibility of a particular path. - Extrusion Swept-Volume 20 10 Yas 0 Xais Figure 6 Swept volume and Extrusion of a polygon in x-y plane moving along a line with non-uniform velocity For dynamic environments, overlap of swept volumes offers only a necessary condition for two objects to intersect. If two objects in a dynamic environment undergo collision, then their swept volumes over the time period involving collision must intersect. However, the intersection of the swept volumes does not guarantee that the objects have undergone collision. Extrusions are created by adding the dimension of time to the object. As the object moves, its configuration information (position & orientation) are time-stamped. The extrusion of a 2-D object is a three dimensional solid and a 3-D object's extrusion is four dimensional. Extrusion depends closely on the object's motion because the velocity of the object is reflected in the shape of the extrusion. For the same path in space, a faster object will have a smaller extrusion volume than a slower object. Figure 6 is a case of non-uniform velocity being reflected in the parabolic shape of the time stamp. In a dynamic environment, overlap of extrusions of two objects is a necessary and sufficient condition for two objects to intersect. If the extrusions of two objects overlap, then at some instant of time, there exists a region in space which is common to both the objects and this implies that the moving objects are intersecting. However, detecting overlap in higher dimensional space is very complicated. 2.2 Collision detection between solid models Detecting intersections between geometric shapes is an oft repeated problem in robotics, path planning, computer graphics, virtual reality simulations of dynamic environments. The problem of collision detection addresses the question, "Given two solids 26 represented by their mathematical models, do they share a common interior?". At the very least, the answer to this question is a BOOLEAN variable: yes or no. Typically, one is also interested in the correction measures that have to be adopted once the occurence of collision has been reported. Measures of the extent of penetration between objects will have to be found out, so that appropriate collision avoidance schemes could be developed. Our research has focussed on the problem of penetration detection between non-convex solids. This section presents the various methods of object representation and their effectiveness for collision detection and avoidance. Collision detection problems have two areas of applications: static and dynamic environments. The static case is encountered in mathematical problems when we check for intersection among two sets. A static case algorithm is run once and it determines whether the two sets are intersecting or not. The problem could involve constructing the intersection set as well. Engineering applications of collision detection typically involve a dynamic environment. In a dynamic application, the collision detection algorithm runs several times over and over. The static application of collision detection can be considered as a restricted and particular case of some dynamic application. In a dynamic application, we typically have a moving object interacting with a static object. Should both the objects be in motion, we could alternately consider the relative motions, so that we end up with a "moving" object and a "static" environment. The moving object's model is constantly transformed, i.e., the position and orientation of the coordinate frame fixed to the moving object changes with time. The geometric model chosen to represent the moving object should be capable of handling these transformation operations rapidly and accurately. Our discussion is restricted to collision detection in a dynamic environment. For penetration detection, an indirect requirement would be that we have at least one of the solid models being watertight,i.e., at least one of the representations should be able to clearly demarcate interior and exterior of the solid so that we can check for intersection infallibly. This observation negates using point cloud representation for both solids, as there is no clear demarcation of the boundary. Given a query point P and a point cloud object A, P could pass easily between the points of A without being detected for penetration. Implicit surfaces, when used to represent solids clearly differentiate interiorand exterior Pentland and Williams [Pentland 89] proposed using implicit functions to represent solids and evaluating inside-outside functions for collision detection. Krishnan et al have presented efficient algorithms for curved models composed of either spline surfaces and algebraic surfaces undergoing rigid motion [Krishnan 97] . Intersection detection between parametric surfaces boils down to the question of robust and accurate mathematical operations on polynomials. There are four common techniques: subdivision methods, lattice methods, tracing methods and analytic methods. There are several robust algorithms implementing interval arithmetic that solve the problem of intersection detection between parametric surfaces [Maekawa 99] [Patrikalakis] . 2.3 Computationally efficient object representations Section 2.1 presented methods that are commonly used for modelling geometric objects such as solids and surfaces. The spatial relationship between real-world solids that 27 we are interested in, collision detection, has been introduced in Section 2.2. Applications of collision detection demand rapid and accurate mathematical operations to be performed on the geometric models. These computations on solid models are limited to a particular portion of the solid rather than the whole. The models presented in Section 2.1.1 represent the objects reliably, but fail to accomodate fast computations and queries. One is faced with the task of performing computations on the entire object's representation rather than a part of it. Thus, alongside having several object representations, there is also the need to have computationally efficient representations corresponding to each of these object models. Approximation has been an abuse of terminology to refer to these representations. We prefer to use the term computationally efficient representations,to better emphasize the philosophy. Merriam Webster dictionary defines approximationas "a mathematical quantity that is close in value to but not the same as a desired quantity". In our problem, we like to have representations of the objects which carry as much information about the object and yet, are not so computationally complicated as the given object model. Approximations do not imply that the representation is computationally less complex. And thus, to reflect the true implication, we use the term computationally efficient representations. Hierarchical representation is one such efficient method. The given object model is represented by a hierarchy of shapes with progressive refinement and accuracy. Hierarchical representation has been used to coarsely represent the objects, to decompose the space they occupy in a simplified manner and to consider accurate details only at certain specific instances. The hierarchical representation of an object begins with a very coarse model of the object. At each successive step, the representation gets refined to match the object's surface and shape with an improved accuracy. A hierarchical representation allows for both a recursive and an iterative programming technique. In collision detection applications, hierarchical representations prove to be an efficient mathematical tool because (i) in many cases, interference or a non-interference situation can be easily detected at the first few levels of the hierarchy and (ii) the refinement of representation is only necessary in parts where collision could possibly occur. In essense, (i) enables eliminating potential non-solution cases from being tested by the collision algorithm. Figure 7 shows an example of this case. (ii) provides for an adaptive and efficient use of the computational power available. .. ....... - Figure 7 Two objects don't overlap if their bounding volumes don't overlap 28 The computationally efficient representation should match the underlying object's geometry as closely as possibly and should also be tight fitting. Alongside having a high accuracy, one should consider other operational parameters such as the core and verbosity, depending on the application. In collision detection algorithms, efficacy of the object representation and the bounding volume representation should be evaluated from the perspective of overlap detection as well as update time. The computational effort required for determining whether representations of two objects are overlapping and the time required for updating the object's representation from one orientation to another are the key criteria. From the point of view of overlap detection, the object representation should yield itself to answer the query whether two objects overlap, very fast and accurately. For overlap detection, basic geometric shapes such as spheres, cylinders and boxes require very little effort. Geometry of most objects is not as simple and as we try to bound the underlying object more accurately, the time required for overlap detection increases. The trade-off between accuracy and time for overlap detection is a topic for further investigation. The other parameter of importance is the update time. Most collision algorithms have applications in a dynamic environment, where the position, orientation and even size and shape of the objects could vary with time. In a dynamic environment, the geometric models of the object should be updated to match the current configuration. This necessitates that any efficient representation of the object thereof be updated. Even though the bounding volume normally has lesser number of primitives than the actual object, care should be taken that at no stage in the hierarchy, the bounding volume takes more time to update than the sub-set of the actual object that it encloses. 2.3.1 Dobkin-Kirkpatrick hierarchy for convex objects Dobkin and Kirkpatrick developed a hierarchical representation for convex objects in d- dimensions. At the highest level of the hierarchy, the convex object is represented by an affine flat in d-dimensions. An affine flat is defined as the smallest independent set that encloses the given set of points in d-dimensions. There are two types of hierarchies: vertex-adding-hierarchies and face-adding-hierarchies. In the vertex-adding-hierarchy, facets of the affine flat are broken up progressively, with the addition of new vertices from the object, until one reaches the object itself. In the face-adding-hierarchy, polygonal faces are added to the affine flat sequentially, until the object model is obtained. At a fundamental level, both these hierarchies are similar: they both start with the smallest enclosing set for the given object and progressively add elements (vertices or faces) to it. It is easy to note that this hierarchy is iterative for the sake of programming. At any stage in the hierarchy, if no overlap is reported, then it is clear that the underlying objects are not overlapping. This is the crux of the Dobkin-Kirkpatrick hierarchical approach for overlap detection among convex objects. 2.3.2 Common Bounding volumes The term bounding volume applies to a volume which completely encloses an object or its subset, and indicates the space occupied by the object using fewer primitives. The bounding volume hierarchy is a powerful tool for performing collision detection between objects. In general, the bounding volume hierarchy is applicable for object representations 29 in arbitrary n-dimensional spaces. But here, we restrict our discussion to objects in R3 , i.e. real world 3-D solids. We observe that if two bounding volumes don't overlap, then the underlying objects can't overlap. This key idea behind bounding volumes is expressed in Figure 7. This helps to identify cases of non-overlap and eliminate them from further consideration. If one can sub-divide the bounding volumes and check repeatedly only for those areas where the bounding volumes collide, there is substantial savings in the time and computational effort. In programming parlance, this method falls into the recursive category. From the point of view of geometry, the aspect ratio of a bounding volume is also important. The aspect ratio compares how "fat" the volume is along two mutually orthogonal directions. It is usually preferable to have a bounding volume hierarchy with a near uniform aspect ratio, i.e. the bounding volumes at various levels of the hierarchy are geometrically similar. 2.3.2.1 Convex hull For a set S c R , the convex hull CHs is defined as the smallest convex set CHs c R such that S c CHs- Convex hull is the tightest fitting bounding volume for a given object. In the case of a convex object, its boundary and its convex hull coincide. Q0 2 Figure 8 Convex hull of a set of points in R Computation of convex hull takes O(n log n) time where n is the number of vertices in the object [Shamos 85] . The Quickhull algorithm [Barber 96] is a robust implementation for computing the convex hull of a set of points in arbitrary dimensional space. It is available as the software package QHULL. Convex hull is a powerful mathematical idea and figures in a wide variety of applications. The convex hull is defined by a set of hyperplanes which define the boundary. Since the location and orientation of these hyperplanes is arbitrary, the problem of overlap detection between convex hulls is computationally intensive. Overlap detection among convex hulls is akin to overlap detection among convex objects and is an 0(n) operation. Update of a convex hull between orientations amounts to transformation of all vertices (or at least the boundary vertices) and is an 0(n) operation. Convex hulls, thus, have not been employed directly as bounding volumes. 30 Indirectly though, one finds convex hulls being applied to handle a few special cases. Pobil's algorithm uses a convex hull of a set of spheres [Pobil 96] . Ponamgi computes the convex hull to handle the initial stages of overlap detection among non-convex objects [Ponamgi 97]. 2.3.2.2 Alpha shapes Alpha shapes are a generalization of the convex hull and a subgraph of the Delaunay triangulation. Given a finite point set, a family of shapes can be derived from the Delaunay triangulation of the point set; a real parameter, (X controls the desired level of detail and abstraction. The set of all real (X values leads to a whole family of shapes capturing the intuitive notion of "crude" versus "refined" shapes of a point set. With the (X value increasing from 0 towards infinity, the alpha shape migrates from a point set into the convex hull. Alpha shapes are useful mathematical tools in surface reconstruction and sub-surface modelling. They are used in visualizing a point set or a solid with cavities. Alpha shapes face the same problem as convex hulls in terms of overlap detection and update time. Their use in collision detection is not very clear. 2.3.2.3 Axis-Aligned Bounding Box Axis-Aligned Bounding Boxes (AABB) are bounding volumes resembling rectangular boxes ( i.e., rectangles in two dimensions and cuboids in three dimensions). Each axis aligned bounding box is infallibly represented as a set of intervals, along the defining directions of x, y and z, because of their rectangular nature. The advantage of employing axis aligned bounding boxes lies in their ease of overlap detection. The following lemma leads to the reason why overlap detection is easy among AABB. Lemma Two axis-alignedbounding boxes are not overlapping if their intervals along any of the defining directionsare not overlapping. Proof: If the intervals along a particular direction are not overlapping, then there exists a plane normal to this direction which separates the bounding boxes and hence the lemma. Interval trichotomy dictates that given two intervals <a,, b1 > and <a2 , b2 > such that ai < bifor i = 1,2, then one and necessarily only one of the following is true (i) a1 > b2 (ii) a2 > b, (iii) the two intervals overlap. Thus, with sets of two comparisons between interval endpoints along each of the defining directions, one is able to verify if the axis-aligned bounding boxes are overlapping or not. Update of axis-aligned bounding box is O(n) time, if one resorts to updating all the geometric primitives and then keeping track of the extremes along the defining directions. Figure 9 shows a bounding volume hierarchy with AABB such that at the leaf level, we have the bounding box bounding a unique triangle. When we try to bound triangles, it is almost unavoidable that even leaf-level bounding volumes will not be disjoint. Note that in Figure 9, bounding boxes at the same level in the hierarchy are overlapping. 31 This is a direct consequence of the convex nature of the AABB. The edge between two triangles is present in two different bounding boxes at the same level in the tree. The edge, being a convex subset of each of the bounding boxes, proves the overlap between them. .ED E:1 WEM ~EJ EE~ Figure 9 Axis-aligned bounding box tree 32 2.3.2.4 Octree Octree is an axis-aligned bounding box hierarchy specifically in R3. Each element box of an octree consists of a cube. The root node is a cube enclosing the entire object array, while the children of the root node correspond to the octants of the cube. As a result, all the bounding volumes are similar in geometry and their linear sizes differ by powers of 2. For the sake of sub-division, each cell has a label: FULL, EMPTY or MIXED. An octant cell is labelled FULL if its entire volume is inside the object, EMPTY, when its entire volume is outside the object and MIXED, when the octant cell intersects with the object's boundary and contains part of th e object's interior as well as exterior. Further sub-division of an octant is suspended if it is FULL or if it is EMPTY. An octant cell is subdivided into its children only if its label is MIXED. Octree is hence not a balanced tree. Figure 10 illustrates this idea on a quad-tree, which deals with two dimensional spatial divisions. For the sake of clarity, only one quadrant was divided. Figure 11 shows the first three levels of an octree representation of a shape in space. Note that subdivision occurs only when the cell's label is MIXED. The sub-division of octrees result in subsets which are geometrically similar to the parent objects. This is because each element of octree is divided equally along the three directions x, y and z. If the division along the individual directions are not equal, k-d trees are obtained [Beckmann 90] . The octree representation has much lower memory requirement compared to a spatial enumeration representation [Section 2.1.4]. At the same time, it is more complex to access the information about the object in an octree form. Figure 10 Quadtree representation of an object 33 Actual Model Tree representation Mixed Full Empty Figure 11 An octree model and the corresponding tree 2.3.2.5 Oriented Bounding Box Oriented bounding box, or OBB, is a rectangular bounding box which tries to match and follow the geometry of the enclosed object to the maximum extent possible. The idea of OBBs have been used before in ray tracing applications. The coordinate axes of the oriented bounding box for a set of points, are the same as the principal axes obtained from the ellipsoid of inertia of these points. The OBB's shape for a particular object is independent of its spatial orientation. By computing the mean and covariance of the set of all points on the surface of the object, the three orthogonal axes of the Oriented bounding box can be found. Since the presence of a dense cluster of points in the interior of the object could skew the computation of the mean and variance, computing the convex hull and using the vertices on the hull alone to compute the OBB has been suggested [Gottschalk 96] . As noted earlier, choice of a particular bounding volume is decided based as well on the complexity of overlap detection and on the complexity of transformation. Computing and update in a dynamic environment of OBB runs in 0(n) time. Checking for overlap among OBBs were carried out with 144 tests, by testing each of the 12 edges of either box against the 6 faces of the other box. This method proved to be quite expensive. Gottschalk [Gottschalk 96] have improved on the performance of the overlap detection algorithm among OBBs by detecting overlap along a set of 15 directions and by applying a Separating Axis Theorem. A separating axis for a pair of convex polytopes is defined as an axis such that a plane normal to this axis separates the polytopes. Two disjoint 3-D convex polytopes can always be separated by a plane which is parallel to a face of either polytope or parallel to an edge from either polytope. According to the Separating Axis theorem, two convex polytopes are disjoint if and only if there exists a separating axis orthogonal to a face of either polytope or orthogonal to an edge from each polytope. The publicly available collision detection library RAPID uses OBB trees at the heart of a collision detection 34 system. Gottschalk reports that using OBBs has a faster performance than AABBs for collision detection [Gottschalk 96] . Figure 12 compares OBB to AABB for the same object. The OBB tends to align itself along a major dimension and follows the shape of the underlying object. OBB AABB Figure 12 Oriented and Axis Aligned Bounding Box for the same shape 2.3.2.6 K-Discrete Orientation Polytope k-Discrete Orientation Polytopes (k-DOP) are a go-between to Axis-aligned bounding boxes and Oriented bounding boxes. The axis aligned bounding boxes have a quick overlap detection test, but fail to bound the object shape very tightly. This leaves the collision detection routine to check a large number of primitives at the leaf level of the bounding volume hierarchy. The oriented bounding boxes are very tight and localize the collision detection test among primitives to a small set, but they cost a lot of computation effort for overlap checking and update. The k-DOPs bound the object from a set of k-different directions. When k equals 6, we get the axis-aligned box. Commonly employed k-DOPs have been 14-, 18- and 26- DOP [Held 98] . If we consider a cube, it has 6 faces, 8 corner vertices and 12 edges. By having the bounding planes associated with these faces, vertices, edges or unions of them we get the various k-DOPs. For example, a 14-DOP has planes parallel to the 6 faces and one plane along each body diagonal of the cube, corresponding to each vertex. Figure 13 carries images of the 6-, 14-, 18- and 26-DOP. These images illustrate the typical geometry associated with the various k-DOPs. It should be noted here that the k-DOPs could be skewed depending on the shape of the underlying object. "Tribox" [Crosnier 99] is a synonym for an 18-DOP, involving the vertices and the face diagonals of a cube. While avoiding the inaccuracy of AABBs, the k-DOPs also overcome the shortcoming of OBBs by having the directions for overlap tests known apriori. 35 14-dop 6-dop 26-dop 18-dop Figure 13 The various k-DOPs The main advantage of k-DOPs lies in their ease of update. When the underlying object undergoes a transformation, the k-DOP is not recomputed for the entire object. Instead, the k-DOP associated with the object alone is transformed and bounded along the k-directions. Figure 14 shows an 8-DOP bounding the object and how the bounding volume is computed after a rotation. It can be proven that the newly computed k-DOP will never be more accurate than the initial k-DOP [Appendix B]. There is definitely a tradeoff between this ease of update and the small loss of accuracy. Held proposed the idea of k-DOPs and addressed some of the key issues involved in using a bounding volume hierarchy of k-DOPs for collision detection. They report that a hierarchy of 14-DOP and 26-DOP has a faster performance than OBBs for collision detection applications [Held 98] . 36 Figure 14 8-DOP update between orientations 2.4 History of Separation Algorithms Historically, separation algorithms have been studied prior to penetration detection algorithms. There isn't a common metric based on which one could compare the various separation algorithms that have been proposed. There have been two kinds of algorithms: for intersection detection - "Given two static objects, do they share a common interior?" and collision detection algorithms - "Will geometric interference occur between two objects in motion?" Distance computation algorithms have envisaged to compute the minimum separation between objects. As a direct outcome, one can infer that two objects are under collision when the separation between them evaluates to zero. Each algorithm has its own domain of operation and hence, there is no common metric to compare all the algorithms. We present the various algorithms grouped according to their underlying philosophy. 2.4.1 Closest pair problems between pointsets Geometric closest point problems have been a popular topic in computational geometry. We mention some of the popular problems here to provide a more complete overview of separation detection algorithms. Given a set of points in a plane, the Closest pair problem tries to compute the pair of points which are closest among them. This amounts to computing the minimum euclidean distance between any two points in the set. The Allpoints nearest neighbor problem tries to compute the nearest neighbor to each point in the set. It is obvious to note that closest pair of points in a set is a subset of all the solutions to the all-points nearest neighbor problem. The Post office location problem deals with dividing a map into postal districts so that each districts represents all the points that are closer to a particular point compared to any of the other points. For solving the closest pair problem and other related problems, the Bentley-Shamos divide-and-conquer algorithm and the planar sweep algorithm are commonly employed. 2.4.2 Minkowski separation of convex objects For two convex sets A and B, the Minkowski difference is the set defined by 37 A-B = x-yI(xe A)q(ye B) 10 10- 8- a- 4- 4- 22 0- 0- 0 10 4 10 4 4 10 2 4 210 2 0 2 4 4 8 1 Figure 15 Minkowski difference between a pentagon and a triangle If A has m elements and B has n elements, then it is obvious that A-B has mn elements. The Minkowski difference of two convex polyhedra is convex [Grunbaum 67] . Cameron and Culley [Cameron 86] have given a proof that the minimum separation of two convex sets A and B is the smallest distance from the origin to any point in the Minkowski difference set A-B. Further, Cameron defines the Minkowski difference method for distance computation as a configuration space problem [Cameron 96] . The element of this set A-B which is closest to the origin could be found in 0(mn) time. Though this result seems easy to understand and interpret, the computational complexity of this approach is O(n2 ) as Minkowski operator takes up to n2 time. A key result here is that not all elements of the Minkowski difference will be on the boundary. Tracking the closest point to the origin typically restricts our search space to the points on the boundary. There are two well known algorithms which use this idea to expedite their search - the GJK algorithm and the Cameron-Culley algorithm. 2.4.3 Gilbert Johnson Keerthi algorithm The Gilbert Johnson Keerthi algorithm [GJK 88] is among the first linear time algorithms for determining the distance of separation between convex objects in d-dimensions. The GJK algorithm computes distance between objects as the minimal Euclidean distance between any pair of subsets, one belonging to each object. The algorithm is based on the Minkowski difference between two convex sets and provides an efficient method for tracking the closest point to the origin in the Minkowski convolution set. The GJK algorithm searches for a simplex, defined by vertices of the Minkowski difference set to identify the closest to the origin. Cameron [Cameron 96] has shown a theoretical analysis of the Gilbert-Johnson-Keerthi algorithm. The GJK algorithm has a "tracking step" when the closest point from the 38 Minkowski set to the origin is determined. Cameron has shown that the tracking step of the GJK algorithm takes about a hundred arithmetic computations. 2.4.4 Steven Cameron's work on enhanced GJK Cameron modified the GJK algorithm with the hill climbing algorithm and tracking algorithm. Both these algorithms employ efficient techniques to compute the boundary vertices on the Minkowski set difference for two convex objects in motion. One is able to quickly identify the point on the boundary of the Minkowski difference that is closest to the origin. As discussed in Section 2.4.3, the complexity of GJK algorithm is linear in the number of vertices of the convex objects. By adding the result from coherence to it, one is able to keep track of the closest point from origin in the Minkowski difference in constant time [Cameron 97] . "Coherence" simply means that when the relative motion between the two objects is very small compared to the principal dimension of the convex objects, then the new closest pair is in the vicinity of the earlier pair. Applying the coherence idea to GJK algorithm, Cameron proves that when the objects move incrementally relative to one another, the point in the Minkowski difference closest to the origin is most likely to move from its current feature to its neighbor and not too far. Thus the enhanced GJK runs in expected constant time. The first computation does occur in linear time. It gets amortized as we opt for a longer sequence of orientations to be tested for collision. 2.4.5 Dobkin-Kirkpatrick hierarchy for overlap detection [Dobkin 85] Dobkin and Kirkpatrik [Dobkin 85] proposed a linear time algorithm for the separation of convex polytopes. The algorithm takes as input two convex polytopes in a static environment. A hierarchy of convex objects is built and they are progressively tested for overlap detection. This hierarchy has been discussed before in Section 2.3.1. The DobkinKirkpatrick hierarchy is an efficient approach to detect interference among convex objects. However, the very mathematical nature of the algorithm makes itself difficult to implement in common applications. The Dobkin-Kirkpatrick hierarchy is typically used in a static case of collision detection [Refer "Collision detection between solid models" on page 26.]. 2.4.6 Edelsbrunner's idea of min/max distance between convex objects Edelsbrunner discusses the problem of minimum and maximum distance between convex polygons [Edelsbrunner 85] . While the problem of minimum distance is one of O(log n) time, the maximum distance between two convex polygons takes up O(n+m) time, where n and m. An important result discussed here is that the closest pair of features between two disjoint convex sets is unique, while there may be several farthest pairs between two convex sets. 2.4.7 Collision detection algorithms in robotic applications Angel Pobil's algorithm for collision detection for path planning applications computes the spherical extension of polytopes [Pobil 96] . Each polytope is enclosed with a sphere and the entire object is represented as a convex hull of spheres. The ease of distance computation and penetration detection between spheres gives strength to this 39 approach. Spherical extension reduces the range of objects that could be handled by such a system. Objects with sharp corners and a significant gradient along their surface can't be very accurately modelled using spherical extensions. Figure 16 S-tope of two robotic arms [Pobil 96] It is obvious that spheres are very crude approximations for most objects. Considering the time period of development of this algorithm - the 80's, we find that computation power at that time was small enough to warrant such coarse approximations. However, present day processors have a clock speed exceeding 1 GHz and can handle much more complicated representations. In contemporary research, we are more interested in handling near accurate object representations than coarse approximations. For path planning for robotic applications, C-space representation too is used. The configuration space (C-space) for moving objects is typically given by the time stamping the coordinates. C-space is where we encounter swept volumes and extrusions [Section 2.1.4]. One has to search the C-space for collision free paths and it tends to be a laborious process. Distance maps are bounded regions in the physical space, which correspond to subsets of the feasible region in the C-space. Computing the distance maps and moving sequentially along them is a proposed method for finding an optimal path from the source to destination amidst moving obstacles [Kimmel 98] . 2.4.8 C J Ong's Growth Distances Ong [Ong 93] studied the properties of penetration distances and proposed the new idea of growth distances. In a single formulation of a growth distance, one is able to model both the separation and penetration between object models. One of the restrictions in this approach is that it is applicable only to convex objects. Convex objects in R3 are assumed to grow out of a single point. A growth parameter cY parametrizes the size of the object. The growth parameter cy = 1, for the actual size of the object. When (Y < 1, the object has shrunk compared to its actual size and when Y > 1, the object has expanded compared to its actual size. Figure 17 shows an example of parametrizing a rectangle by this growth distance approach. 40 I I 1.5 G r ---------------------------- I -------------------------- =1.2 1 ~= 0.8 0 0.6 = 0.4 I- - -- Figure 17 Parametrizing the growth and shrinking of a rectangle Let PA be any point in the object A with respect to which the convex object is "grown". Then the growth model A(Y) is given by, A(s) = {PA + a(A -{pA})} In such a parametric model, the two objects A and B are expanded or shrunk until their boundaries just touch each other. Depending on whether the objects expand or shrink, one is able to determine if the objects are under separation or under penetration. An interesting challenge is to estimate the extent of separation/penetration from the growth parameter. A common rule of thumb employed is to use the radius of minimum enclosing sphere and scale it by the growth parameter. Ong's result indicate good correlation between such a scaling and the actual extent of penetration distance. 2.4.9 Lin-Canny's algorithm for incremental distance computation Lin and Canny [Lin 93] provided an algorithm for finding the separation between convex objects in worst case linear time. Their algorithm detects the closest pair of features between two convex objects in constant time for incremental changes in the positions of objects. Their work has had an important role in exposing the power of convexity. For each convex polyhedron, Lin computes the boundary and co-boundary of the various primitives, namely vertex, edge and face. During the pre-processing stage, the boundary and co-boundary of all the vertices, edges and faces are evaluated [Figure 18]. Should the size of a particular face's boundary become large, or if the size of the co-boundary of a vertex or edge is large, then the volume is sub-divided into smaller cells. This ensures that the size of the boundary and co-boundary is small and hence, can be regarded constant. 41 Co-boundary Vertex Boundary Face Figure 18 Boundary and Co-boundary for a vertex and a face The algorithm considers a pair of candidate features and computes the distance between them. Then each feature is evaluated against the co-boundary of the other, to determine if there is any other feature on the boundary that is closer still. Thus, the algorithm walks to a closer feature, if it exists. The algorithm continues thus and finally, we end up with the pair of closest features between the objects. For a pair of features to be nearest to each other, each of them must satisfy the conditions of the co-boundary of the other. The above condition also ensures the termination of the algorithm, provided the initial pair of convex objects are not completely interwined. As seen from the description of the Lin-Canny algorithm, the running time is related to the size of the boundary and coboundary of the pair of candidate features. The constanttime for the algorithm is obtained by ensuring that any feature's boundary and co-boundary has near constant size. The Lin-Canny algorithm has been used as part of various algorithms for detecting collisions among convex objects. This algorithm is useful only to the extent of detecting separation distance. The algorithm determines the separation between objects or returns the information that the two objects are intersecting. 2.4.10 Pseudo-Voronoi diagram idea of Ponamgi [Ponamgi 97] Ponamgi, et al [Ponamgi 97] have presented an incremental algorithm for collision detection between general polygon models in a dynamic environment. In any dynamic simulation, there are three distinct realms of computation - collision detection, contact area determination and collision response. In essence, one has to identify a collision between the objects, locate the zone of contact and then provide some means by which the objects move away from collision. Ponamgi's work addresses the first two of these, namely, collision detection and contact area determination. Ponamgi et al have identified a potential flaw in an earlier algorithm [Lin 93] and have proposed this algorithm as a correction to the same. This work draws strength from coher- 42 ence combined with incremental computation. The algorithm is capable of handling nonconvex polygon models also. The convex hulls of the objects are determined and bounding volume hierarchies of AABBs are employed to identify potential collision cases. Additional data structures have been proposed to distinguish between the non-convex objects and their convex hull. At a finer level, the areas of intersection are computed and the features under collision are found out. Pre-processing in this algorithm mainly involves finding the Voronoi regions on the exterior of the polygon models. To handle cases of objects penetrating one another, a new concept called pseudo internal Voronoi regions has been defined. These pseudo Voronoi regions are crude approximations to the actual Voronoi regions in the interior of the polyhedron. These pseudo-voronoi regions help avoid the infinite loop in Lin's algorithm and provide a useful technique for the "detection" problem. 2.4.11 Detection is easier than computation - the caveat Dobkin explained that the problem of detecting intersection is much less complex compared to constructing the intersection set [Dobkin 80] . This result is easy to understand as well. Detecting intersection between two objects amounts to identifying atleast one witness such as a point or line which is common to the two given objects. Constructing the intersection region amounts to identifying all such witnesses which are common to the objects. Hence, the computation of the intersection region to be computationally more intensive than detecting intersection. Based on a similar argument, we can expect the computation of a measure of intersection to be more complex compared to detecting intersection. The reason is that we have to be aware of every witness such as a point or line under intersection to compute a measure of intersection. 2.4.12 Pellegrini's Batched Ray Shooting algorithm This algorithm reports the only sub-quadratic algorithm for collision detection between two non-convex polyhedra. - +46 In time 0 ((n + m)3 ), it is possible to decide whether two non-convex polyhedra of complexity m and n intersect. This is the only known sub-quadratic algorithm for nonconvex collision detection. 2.4.13 Mirtich's V-clip algorithm [Mirtich 98] The Voronoi-clip algorithm performs collision detection between polyhedra based on a boundary representation [Mirtich 98] . V-clip has been proposed as an improvement over the Lin-Canny algorithm [Lin 93] . The V-clip algorithm avoids the case of infinite loop in Lin-Canny algorithm when the two objects penetrate. It is also a more robust implementation. The Voronoi region in the exterior of a polyhedron is computed as a pre-processing step. The V-clip algorithm relies on the following theorem: 43 Theorem: Two objects are closest to one another if and only if they both satisfy the other's Voronoi region's criteria. Based on this theorem, one could start with a pair of features, one from each object and progressively clip each feature to a more closer one, until we obtain the closest set of features. If not, we obtain the information that the objects are penetrating. Mirtich has compared the V-clip algorithm with the Lin-Canny algorithm [Lin 93] and the enhanced GJK algorithm [Cameron 97] and has reported a better performance for V-clip based on the number of floating point operations. 2.4.14 Space-Time Bounds and 4-D Geometry Simulations of a dynamic environment involve computing the location of various moving objects in a given time-period. A common approach to dynamic simulation is to divide the time-period into a series of small time steps and then to compute the updated locations and orientations of objects through numerical integration over these time steps. At the beginning of each time step, the simulation has a collision detection routine that checks if there exists collision between objects and alters their velocities accordingly. The main concern is to develop techniques to speed up such simulations, while being realistic at the same time, so that the simulation does not miss any collision between objects. Canny [Canny 86] derives functions of a time variable that express how various convex polytopes change over time. When the function evaluates to zero, it implies that two objects are under collision. By finding the roots of these functions, one is able to identify all instances in time when there is a collision. Hubbard's algorithm [Hubbard 95] detects collision between objects in an interactive dynamic environment. It implements spatial representations based on space-time bounds.. Such an approach is also called four-dimensional overlap testing. To detect whether two objects in dynamic motion are colliding, we have to find instances of time t when both objects share some common point (x, y, z) in space. When we represent the objects in four dimensions by including the time signature, we will have to find all common coordinates <x, y, z, t > between them, and hence the name four-dimensional overlap testing. Space-time bounds are four dimensional sets which enclose all possible configurations of the object under a given time period. Hubbard proposes two heuristic algorithms for computing intersection between the space-time bounds. When intersection is reported between space-time bounds, a more refined intersection detection test is applied to a hierarchy of sphere trees which bound the object more accurately. Thus one is able to identify intersections between the objects in four dimensions and report collisions in the dynamic environment. Sphere tree, though very loose fitting as a bounding volume, has the advantage that the resolution of the tree is independent of the geometric complexity of the object. Hubbard's algorithm implements time-critical computing, where there is a trade-off between accuracy and computational resource (time) available. Based on the time available for computation, the depth of the sphere tree is decided and thus the accuracy of collision detection is based on it as well. 44 2.4.15 Collision detection among multiple moving spheres [Kim 98] A dynamic environment could involve a set of objects moving along a pre-determined time-dependent path, unless they undergo collision. The problem of a fixed time-step of integration in a simulation of a ballistic system of spheres, has been circumvented by computing the earliest instance in future when two spheres could collide and advancing the simulation until that time instance [Kim 98] . This algorithm draws strength from the fact that collision detection between spheres is a trivial computation. Spatial tiling is used to expedite the process of checking collision between spheres. Spatial tiling amounts to dividing space into box-like elements, similar to the spatial occupancy enumeration approach [Section 2.1.4]. Spatial tiling enables the simulation to maintain sets of spheres which are in proximity and which could be expected to collide in the near future. Kim's collision detection incorporates the kinetic theory of molecules to identify the appropriate and efficient sub-space sizes for the tiling. A dynamic simulation for spheres is efficiently created with such an approach. There is difficulty to implement the same, for common three dimensional shapes as distance computation between them is non-trivial. Relating the spatial tiling size to the kinetic theory of molecules is an interesting idea, which could be employed in other physics-based simulations as well. 2.4.16 Impulse-based approach Baraff has discussed the problem of computing contact forces between non-penetrating rigid bodies [Baraff 89] [Baraff 94] . Instead of adopting the conventional method of computing contact forces by means of an optimization formulation, Baraff's algorithm is a feature-based algorithm which maintains a separating plane that embeds a face of one of the polyhedra, or one edge from each polyhedra. The polyhedra are disjoint if and only if such a separating plane could be found. The algorithm performs a direct analytical calculation of the contact forces between non-penetrating rigid bodies which could have contact friction as well. Mirtich introduced a new approach to dynamic simulation, termed the impulse based simulation [Mirtich 96] . Impulse-based simulation tries to achieve physical accuracy as well as computational efficiency. Conventional approach to getting physical accuracy in a simulation involves a constraint-based method, using Lagrangian formulation. Constraint -based approaches often involve several variables and large number of computations thereof. For some dynamic simulations involving frequently occuring collisions, constraint-based approaches could become very slow. Impulse-based simulation has been proposed as a way of overcoming the shortcomings of the constraint-based methods. Impulse-based dynamics involves no explicit constraints. Collisions between objects are modelled as an instantaneous transfer of impulse between objects. Continuous contact is handled using trains of impulses applied to the objects. Objects are assumed to be convex and as union of convex sets and at the heart of this approach, the Lin-Canny incremental distance computation algorithm [Lin 93] is used to compute the distance between pairs of objects. Based on this distance and on the relative velocities between the objects, a conservative estimate is placed on the time of impact (TOI). The TOI values for various objects are stored in a heap and one is able to identify 45 the earliest time at which a collision could possibly occur. The simulation is run using numerical integration until this earliest time of impact is encountered. Collisions between objects are modelled as a transfer of impulse under realistic conditions of friction, possible sliding contact or static contact. During collision, the changes in velocity are instantaneous and the impulse transfer determines the new initial conditions for the next integration step, until the next earliest time of impact. Impulse based simulation, as reported by the author himself, is not a panacea for dynamic simulations. There are physical examples where impulse-based simulation would be computationally inefficient and expensive. Depending on the actual physical system, one should make a choice between an impulse-based approach and a constraint based approach. 2.4.17 Adaptive Distance Fields and Volume rendering Gibson [Gibson 00] studied the idea of rendering based on volume information. Traditionally computer graphics has used the surface information for rendering purposes. Volume information adds greater content in the information and also helps model properties which behave as a field. For eg., refractive index of a solid could be a field g(x, y, z) in R3 Such a behavior is easily captured under volume rendering. The idea of Adaptive distance fields is applied on a layer of octree based divisions. Each vertex of an octree cell is attributed a distance metric. The derivative of this distance function gives the direction along which the distance is closest. Trilinear interpolation is used to compute the distance of any point within a particular voxel. By this, we are able to capture the distance values anywhere within a particular solid. This distance computation could be suitably used in collision detection and avoidance algorithms. 2.4.18 Real-time 5-Axis collision detection Ho [Ho 99] implemented a real-time haptic system between three-dimensional real world solids. Haptic systems using force-feedback devices usually consist of a dynamic object exploring a static terrain. In Ho's system, the dynamic object is an axisymmetric object in the form of a cutting tool. The terrain is any generic three-dimensional solid. Ho's approach involves collision detection of an implicit equation defined binary space partition tree against a point cloud. A bounding volume hierarchy employing k-DOPs is used to expedite the collision detection process. Ho's system makes efficient use of Voronoi diagram in a plane. An axi-symmetric object can be modelled as the surface of revolution of a two-dimensional curve. Proximity information of a query point inside the three-dimensional axisymmetric object is obtained in the following manner. The query point undergoes a transformation to the plane of the two-dimensional curve. Then, by checking against a BSP tree composed of Voronoi equations, the portion of the boundary of the tool nearest to the query point is obtained. For the cutting tool vs. stock collision detection, the proximity information for all points reported inside the tool is obtained. Then, a weighted, iterative approach is employed to compute the collision correction scheme. Ho's algorithm is among the first fully three-dimensional real-time collision detection systems. The accuracy of the algo- 46 rithm is guaranteed by using implicit equations, which clearly demarcate inside vs. outside. Ho has also observed that triangle set methods such as those in [Ponamgi 97] [Held 98] are capable of collision detection, but fall short when we attempt to detect penetration. 2.4.18.1 Idea of a generic tool model As an extension to Ho's work, we implemented the idea to a larger set of cutting tools. The motivation was primarily to prepare the geometric model of cutting tools, given the geometric dimensions. Upon preparing the geometric model, the pre-processing defines the Binary Space Partitioning schema for that particular cutting tool. Once these two steps have been performed, we can apply Ho's collision detection algorithm as a black box and we are able to perform collision detection between a large variety of cutting tools and any generic three-dimensional terrain. 2.4.18.2 Modelling common milling tools with the same set of parameters Common milling tool libraries involve three large families: flat nosed milling tools, ball end milling tools and bull-nosed milling tools. These three tools differ mainly in the cutter tip geometry. In a flat nosed milling tool, the cutting edge is a flat surface of cylinder. The ball end milling tool has a hemispherical end at the apex of a cylinder, acting as the cutting edge. In a bull-nosed milling tool, we find the geometry to be a go-between of a flat nosed tool and a ball end tool. The end portion of a cylinder has its corners rounded off, but not without retaining a small portion of the flat. Flat end mill Ball end mill Bull-nosed end mill Figure 19 Common milling tools 2.4.18.3 Constant shoulder diameter tools In the initial phase of this research, we extended Ho's algorithm to handle a library of milling tools. Milling tools are classified into a set of families, namely Flat end mill, Ball end mill and Bull nosed end mill. This classification is based on the cutter tip geometry. Further we also classify tools in the way their diameters vary. Most tools have the shoulder diameters monotonically increasing. However we do encounter the situation of the shoulder diameter decreasing. While is it not true for cutting tools that the shoulder diameter should decrease, our modelling environment for the tool also includes the tool holder and the spindle parts. As a consequence, our Tool could in theory have diameter decreasing in between also. 47 For modelling milling tools, each portion of the tool where the diameter remains constant is modelled as a cylinder. Even though the cutting edge is not uniform throughout the periphery, the surface of revolution is a cylinder because the tool is spinning. The tool is an axi-symmetric surface of revolution of a planar curve. The cylindrical portion of the tool will be a rectangle in this 2-D diagram. The three families of milling tools that we modelled [Figure 19] differ only in their cutter tip geometry. We developed a common methodology to model all three types. Consider the 2-D curve for the cutter tip. It resembles the curve shown in Figure 20. r Cutting edge h Axis of tool II-- I -I Figure 20 Modelling the cutter tip of milling tools shown in [Figure 19] For the cutter tip alone, we define three variables: the h, r . h is the height of the curve. In actual dimensions, h will be the radius of the cutting tool. r is the corner radius. 1 is the length of the cutting portion of the cutter tip. Using such a model, it is obvious that the three types of milling tools differ only in the way r compares with h. Table 2.4 summarizes the same. Milling tool r Flat end mill 0 Ball end mill =h Bull nosed end mill 0< r<h Table 2.4 Mathematical model of the three milling tool families 48 4 -a. 4 -A--# 7:: Figure 21 Correction directions for various Voronoi regions within an axially symmetric tool 2.4.18.5 Tools with taper Figure 22 Tapered portion of a cutting tool 49 A set of less common tools include those with taper. While their presence and applications are unique, their computational complexity is reasonably high. Figure 22 represents the Voronoi diagram within a tapered region of the cutting tool. This Voronoi diagram defines the local Binary Space Partition schema for point location and proximity queries. Appendix C explains how the diagram in Figure 22 and Figure 21 truthfully represent the Voronoi diagram within the respective cutting tools. 2.4.19 Collision Detection between 3D polyhedra Collision detection between 3D polyhedra has surfaced as the title of several journal papers and articles. However, on closer perusal, one finds that most of these algorithms deal with convex polyhedra. In other instances, convex decomposition has been introduced to handle non-convex polyhedra. Dobkin [Dobkin 90] mentions a quartic upper bound on collision detection between non-convex polyhedra. 2.4.20 Surveys of Collision Detection algorithms Jimenez [Jimenez 00] provides a good window into existing collision detection algorithms. As noted in this survey, there isn't any algorithm for detecting actual contact points between two non-convex polyhedra under intersection. Lin [Lin 98] provide a comprehensive survey of collision detection between geometric models. Both these surveys, independent in their own right, have focused on collision detection and not much on penetration analysis and correction techniques. It adds further weightage to the fact that there are very few algorithms which talk about Collision detection and correction. The term Collision detection has been quite frequently abused in literature to refer only to the problem of detecting penetration between objects and also providing means of correcting. We propose the ideas of Collision Detection and Collision Avoidance. 2.5 Motivation for our work In this chapter, we have presented a brief background about solid modelling with specific reference to interference detection applications, about efficient representations to expedite the computations in an algorithm and also about a few algorithms proposed towards other related problems. From the literature survey, we understand that the definition is unclear about "collision detection". Hence, for the discussion in the following chapters, we propose these definitions: Collision detection amounts to detecting interference and overlap between solid objects. These include a BOOLEAN response whether the objects overlap or not and also, the spatial location of the various geometric entities in overlap. Distance computation algorithms could also be classified as collision detection algorithms. These algorithms attempt to compute the minimum distance between two objects. When it is reported that the distance of separation is zero, overlap between the objects is reported. Collision avoidance is the set of all actions taken upon detecting collision, so that the extent of overlap is reduced. 50 Section 2.4 presents several key algorithms that solve related problems. Our focus has been on collision detection and collision avoidance between non-convex polyhedra. We made no specific assumptions or restrictions about the solid models used in our algorithm. This way, we hoped to develop an algorithm which would handle convex and non-convex polyhedra alike. As a summary, we present here the key attributes of some of the earlier algorithms and approaches. These algorithms enabled us understand the problem better. It is important to Algorithm/Approach detection/ avoidance? Megiddo's algorithm detection Linear programming GJK algorithm detection Minkowski difference between convex objects Space-time bounds detection Four dimensional overlap test Dobkin-Kirkpatrick's algorithm detection Hierarchy of convex polytopes Pobil's algorithm detection S-topes, spherical extensions to objects Ong's growth distances avoidance Penetration distances and metrics Lin-Canny algorithm detection Constant time distance computation for incremental motions V-clip algorithm detection Robust implementation of LinCanny, convex decomposition I-COLLIDE detection Convex hull computation of nonconvex polyhedra and pseudoVoronoi diagram Keerthi-Sridharan algorithm avoidance Negative distance between convex objects Adaptive Distance fields avoidance Distance fields and depth information Ho's haptic system avoidance Implicit equation defined axisymmetric objects Main idea Table 2.1 Summary of a few key algorithms note here that there isn't a common yardstick to compare all these algorithms. Each algorithm employs a different combination of approaches and has a specific set of applications. These applications are varied for the algorithms and it is not practical to compare the same algorithm's performance under different circumstances as well. 51 We attempted some of these methods as part of our initial concept development. Chapter 3 presents the highlights of these methods and also brings out the reason why they weren't exactly applicable to our problem. 52 Chapter 3 Summary of Explored Concepts This chapter presents several of the ideas which were attempted during the early stages of our research on the problem of penetration detection between non-convex polyhedra. These ideas served as the initial concept development and analyzing these ideas have proven to be the foundation of our research. For the sake of completeness, we present these ideas as a precursor to our algorithm and contributions. In the initial phase of our research, we attempted to perfom point location of a set of points within a tessellated surface. This attempt involved sorting the various vertices on the surface along several directions and then performing point location of each query point within these sorted arrays. However sorting alone takes O(n log n) time and hence we did not pursue the idea further due to its enormous computational time. 3.1 Decomposition of the surface A non-convex surface/solid is sometimes converted into a collection of convex surface patches/solid sub-entities. This method is commonly referred to as decomposition. There are many algorithms which perform collision detection by incorporating convex decomposition in the heart of their routine [Quinlan 94] [Mirtich 96] . Their typical approach is to decompose the given objects into convex subsets and then to apply the known algorithms for convex object separation. Convex decomposition, though ubiquitous, has some disadvantages. Firstly, convex decomposition is not necessarily unique. A single solid could have multiple sets of convex decompositions. For example, convex decomposition of a sphere could include anything from the whole sphere to a collection of individual portions on its surface [Figure 23]. 53 Figure 23 Convex decomposition is not unique There are common engineering solids for which convex decomposition is not feasible. For example, consider (i) the inside of a torus and (ii) a cube from which a cylinder has been cut out. Convex decomposition and subsequent distance computation between the respective convex sub-sets detects collisions correctly. Computing an extent of penetration is not very obvious though. There is not much information about the relative location of the various convex subsets in a particular solid. When we have many pairs of convex subsets reporting an overlap, it is difficult to identify which of those overlaps are more significant compared to the others. In these instances, estimating the extent of penetration is not so easy. Convex decomposition falls prey to the fact that the number of convex subsets in the worst case could be 0(n2 ), where n is the number of geometric primitives of the non-convex solid [Chazelle 97] . Chazelle, et al have proven that the minimal convex decomposition of any non-convex solid is an NP-hard problem [Chazelle 95] . Based on these two results, we decided not to adopt convex decomposition as part of our algorithm. 3.2 Algebraic approximation of discrete points on a surface A common difficulty encountered in penetration detection is a closed form solution of the depth of penetration of a point or a geometric primitive inside a surface represented by a cloud of points. Since depth measures against algebraic surfaces (for both the cases of implicit as well as parametric) are defined by closed-form equations, we attempted to create algebraic function approximations to surface patches. The idea was to come down to the level of leaves in the bounding volume hierarchy and then use the algebraic function to determine the depth. Fitting algebraic surface equations to a set of discrete points has been solved recently. Krishnamurthy has developed an energy-based formulation involving the points to obtain the NURBS surface patches. This method is robust enough to handle millions of points and obtain near-accurate surface fitting to it [Krishnamurthy 98] . The trade-off in this approach is between the accuracy and the number of points for which the surface fitting is performed. We like to narrow the search for possible collisions to a highly localized region and hence will prefer a small set of points in the bounding vol- 54 _M ume leaves. The algebraic surface approximation is accurate and robust mainly when the number of sample points is sufficiently large. Understanding of this trade-off is not very clear and has a lot of scope for further investigation. 3.3 Voronoi diagrams Voronoi diagrams are one of the fundamental data structures used in proximity queries. A Voronoi diagram is defined as the locus of allpoints which are closer to a particular geometric entity than any other The Voronoi diagram for points in a plane is easily understood as the division of the plane into polygonal regions such that the interior of each polygon is closer to a particular point in the plane than any other point. Extending this idea to lines and curves in a plane, we obtain "entity Voronoi diagrams". A classic example for the computation of an entity Voronoi diagram is in tool-path generation for contour milling operations [Sarma 99] . Construction of the Voronoi diagram in R 2 is O(n logn) while it is more complicated in higher dimensions. Further, it is a well known result that complexity of Voronoi diagram in R 2 is linear in the number of vertices. Fortune's algorithm is a very efficient tool for computing the voronoi diagrams in 2-dimensions [de Berg 97] . The problem of computing the Voronoi diagram in higher dimensions is usually tackled by converting it into a problem in lower dimensions and then proceeding recursively [Shamos 85] . The computation of Voronoi diagram in 3-dimensions along with its maintenance in an efficient data structure is a challenging problem. Aurenhammer provides a comprehensive survey of Voronoi diagrams with particular applications in geometric searching, file searching in databases etc [Aurenhammer 91] . 3.3.1 Shell rather than a solid We chose surface representations as input models to our algorithm. The characteristic of a surface representation is that its a two dimensional entity. Our research draws strength from the finding we refer as "shell". It is common knowledge in computer graphics and molecular modelling that a surface representation does not carry any information about its interior. As a result, we realize that our data set is not evenly distributed in the R3 space. The set of points is like a shell on an object. We conjecture that this point set would match a two dimensional planar surface more than a three dimensional solid. Figure 24 Surface representation is a "Shell" 55 For our problem we rely on Voronoi diagrams as a possible data structure for proximity queries. Our object models are surface representations instead of volume representations. Voronoi diagram on the surface of the polyhedron would be such a partition of the space inside the polyhedron that each region inside will have a unique polygon on the surface which is closest to it compared to any other polygon. The complexity of a two-dimensional Voronoi diagram is linear in the number of vertices. From the resemblance to a shell, we can expect our required Voronoi diagram also to have a linear complexity. Teller et al have proposed algorithms for computing the Voronoi diagram for a set of triangles in three dimensions [Teller 99] . We restrict our attention to areas very close to the surface and we avoid the far-interior of the polyhedron. For a pair of planar surfaces the Voronoi diagram between them is the angle bisector plane between them. The Voronoi diagram close to the surface is linear in size compared to the number of vertices on the surface and it involves a straight-forward computation, based on the given surface normal values. In our algorithm, we employ the Voronoi diagram both implicitly and explicitly in the form of angle bisector planes. Details of this pre-processing are described in Chapter 4. 56 Chapter 4 Our Approach In Chapter 3, it has been shown that ideas such as sorting, algebraic function-approximation and convex decomposition, though common in computational geometry, are not easily applicable to our problem of penetration detection between non-convex polyhedra. In our research, we address the problem of collision avoidance. It involves the problem of reporting collision between objects, identifying the locations of collision and then proposing correction measures. Given two solid models, we address the following questions: At a given instant, with the position and orientation of one of the objects specified, do the two objects share a common interior? If they do so, then what is the smallest translation applied in any direction that will separate the objects from their state of intersection? Chapter 2 has a brief discussion regarding the applicability of various solid models to the problem of collision detection. In our proposed solution to the problem, we treat one of the solids as a polygon soup and the other as a cloud of points. We have implemented a collision detection scheme which is accurate to the resolution of the objects. No collision goes unreported. False positives, i.e., when the algorithm reports a collision while in reality, there isn't one, are detected and appropriately handled. The collision avoidance scheme involves computing the penetration depth of entities and implementing an iterative procedure for computing a global correction. The global correction vector is a translation which when applied to the dynamic object, reduces the extent of its penetration and in a few iterations, brings the objects out of collision. Our algorithm is restricted to shallow penetration and it assumes that the interpenetration is not larger than a pre-defined depth value. Should the solids be penetrating more than this depth, the output of the algorithm could become unpredictable. 4.1 Input In this section, we discuss the input to our algorithm. Our algorithm attempts to detect and correct shallow penetration between two generic solid models. The input to our algo- 57 rithm is of two kinds: one is the solid model input for the object models and the other is the input of the motion of the dynamic object. 4.1.1 Solid models We assume nothing about the geometry of the input solid models. This enables the algorithm to accept both convex and non-convex objects. There are linear time algorithms available for collision detection algorithms among convex solids [GJK 88] [Dobkin 85] [Lin 93] [Pentland 89] . The requirement of convexity limits the number of objects to which it can be applied. Most engineering solids are non-convex. The usefulness of the convexity property has been the driving force behind collision detection approaches using convex decomposition, as explained in Section 3.1. The input solid model file format that we use is a Stereo-lithography Tessellation Language (STL). STL format is very common in applications such as 3-D Printing and Rapid prototyping. Other popular file formats for 3-D CAD models include IGES, STEP, ACIS, Parasolid and 2-D models such as DXF and DWG. The STL file format specifies the 3-D object as a boundary representation constructed entirely of triangular facets. The triangulation might seem quite verbose; however, the efficiency of STL format lies in this simplicity. The most basic planar entity - a triangle is used to describe every detail. The STL file format of an object contains a list of triangles, each triangle contains information about its vertex coordinates and the outward surface normal. Each triangle is represented by 9 floating point numbers corresponding to the x, y and z coordinates of its three vertices and its outward surface normal. The representation has an advantage that the triangles are independent of each other. The flaw in such a representation is that the vertex coordinates are repeated for each triangle that they belong. A vertex shared by n adjacent triangles is represented n times in floating point. Floating point operations and their instabilities have been dealt with by a number of researchers in the past decade. Figure 25 shows a section of an STL file, depicting the schema of this representation. Repeated arithmetic operations on floating points accumulates error [Goldberg 91] . A single vertex could get duplicated because its coordinates appearing as part of different triangles could get altered during computations. The error accumulation causes geometric discontinuities in the 3-D object model in the form of tears, holes and isolated vertices and the representation might no longer conform to that of a closed 3-D solid. The inside-outside information of the object's surface is sometimes lost, tripping the collision detection algorithm. The problem was avoided by converting the representation into that of an indexed mesh. This is explained in the following section on data structures used by our algorithm. 58 solid ascii facet normal 0-.94280904.33333333 outer loop vertex 0 -. 866-.50 vertex 0 +.866 -. 50 vertex 0 0 1.414 endloop endfacet endsolid Figure 25 STL file format and syntax Our algorithm is oblivious to the convexity property of the object and thus it handles non-convex polyhedra as well. 4.1.2 Algorithm input We assume nothing about the motion of the moving-object over the unexplored terrain. The collision detection algorithm compares a moving-object against a static terrain. The initial input to the algorithm pertains to the modelling environment, where solid models of the objects are handled. The run-time collision avoidance algorithm follows the preprocessing stage. During run-time, the model of the moving-object has to be first instanced. It requires as input the position and orientation of the object-specific coordinate frame associated with the moving object. The position and orientation could be pre-speci- fled as in the case of a path of a robot or it could be obtained in real-time from position sensors. For our algorithm, we employ a haptic interface to provide the position and orientaiton information at each time step. As the user moves the probe around, the position and orientation information is fed to the algorithm. Thus, the input to the run-time algorithm is not pre-specified and we don't make any specific assumptions about the same. 4.2 Data structures and models Our algorithm performs penetration detection between two polyhedral models, one of which is a triangulation and the othe is treated as a point cloud. The input solid models are in STL file format. Section 4.1.1 explains why we can't employ the same data structure as is given in the input STL file. We avoid this problem of repetition of vertex coordinates with an indexed mesh representation. The vertex coordinates of all the points are stored just once. The indexed mesh representation contains the minimal storage of floating point values necessary for the object model. Edges are stored in terms of pointers to their endpoint vertices and triangles have a list of pointers to their edges and vertices. Geometric operations such as adjacency, vertex identification are all obtained from the pointers and array indices. This way, we avoid errors introduced by floating point arithmetic [Goldberg 91] . 59 4.3 Pre-processing Mathematicians look at pre-processing as a measure of overload on the algorithm. In a purist's opinion, excessive pre-processing means an inefficient approach. The ideal goal always is to develop algorithms which have efficient run-time performance while having pre-processing limited to a very small value. Our research envisages to implement penetration detection algorithm on a haptic interface, which run in real-time computing environments. We transfer as much computation to the pre-processing phase as it saves on our real-time algorithm's running time. There are several examples of collision detection algorithms which shift a bulk of the computation to the pre-processing stage [Dobkin 85] [Lin 91] . We follow the oft repeated path of computing the relevant Voronoi diagram during the pre-processing stage. Along with it, we also compute the bounding volume hierarchy for the geometric models. Here, the assumption is that memory retrieval during run-time does not take too much time compared to the rest of the computation. 4.4 Homeomorphism and Shallow Voronoi diagrams Figure 26 A surface patch is homeomorphic to a planar triangulation Voronoi diagram is a powerful tool for accurately detemining the closest neighbor. Voronoi diagrams on the surface of a polyhedron have been regarded as quite complex. While this is partly true, it is also true that the complexity of the Voronoi diagram is 60 largely due to the behaviour far in the interior of the polyhedron where the intersection of several planes occur and the individual Voronoi cells become not so intuitively obvious. When we consider a portion of the surface, a surface patch as we prefer to define it, it is homeomorphic to a planar triangulation. Figure 26 displays this example of homeomorphism. As a result of this homeomorphism, we find that the Voronoi diagrams are not very complicated when we restrict our attention to regions very close to the surface. We define these regions as shallow regions, i.e., those regions where the depth from the surface is a small fraction of a major dimension of the object. Further, we restrict our focus to shallow depths inside the surface, and we are not interested in computing the intersections of the various Voronoi planes deep within the object and avoid their complex behavior. 4.4.1 Why shallow penetration? The problem of detecting large penetration values, though very challenging computationally, does not have very many applications. Penetration between real world objects is a mathematical concept. When one considers real world solids, they collide and either (i) break or (ii) undergo change of shape and size. Real world solids don't penetrate into each other when they collide. Penetration is used as an efficient tool to model the contact forces between colliding objects. Penetration detection combined with a penalty-based approach is used commonly for computing contact forces between objects. While it is reasonable to expect objects to collide near their surface, physical reality occludes real world solids from interwining with each other. Based on this, we have addressed the problem of shallow penetration detection between non-convex polyhedra. 4.4.2 Voronoi diagrams as an expanding wavefront Traditionally the construction of the Voronoi diagram has been regarded as an expanding wave-front originating simultaneously from each of the entities for which the Voronoi diagram is constructed. In classical Voronoi diagram construction problems like the Post Office Location Problem [Shamos 85] the wavefront begins at each of the sites of the post office. The boundary of the postal districts is determined by the earliest instant when an expanding wavefront encounters another wave from a different site. When such an encounter occurs, the portion of boundary between these two sites is defined. Such a naive approach helps us understand the true nature of the Voronoi diagram of a set of points in a plane. While we consider computing the Voronoi diagram of entities such as lines and curves, we can adopt a similar wavefront approach. From each part of the lines and curves, we construct expanding waves. When these waves intersect with waves from a different entity, they merge, yielding the Voronoi diagram between the pair of entities. Other examples of the Voronoi diagram between entities is found in the grass burning algorithm (or the lawn-mower's problem), tool-path generation algorithms for contour milling [Kim 01] [Quinlan 94]. 4.5 Offset surfaces Offsets are defined as the locus of points at a signed distance along the normal of a surface. The topic of offset surfaces has received considerable attention in the past decade. 61 Pham [Pham 92] and Maekawa [Maekawa 99] carry a detailed survey of research in the past few decades on offset of curves and surfaces. For sake of brevity, this section presents the offset of algebraic surfaces to introduce the concept and discusses the computation of the offset of triangulated surface, a key idea employed in our algorithm. 4.5.1 Offset of an algebraic surface For an algebraic surface, i.e., a surface represented by algebraic functions, including parametric and implicit surfaces, the computation of the offset is a closed-form mathematical operation. For a parametric surface, the offset surface is defined by, r0 (t) = r(t)-dn(t) where ro(t) is the equation of the offset, r(t) is the equation of the progenitor surface, and n(t) is the normal vector to the progenitor surface. The offset surface is functionally more complex than the progenitor surface because of the square root computation involved in finding the normal vector n(t). Offset curve Progenitor curve Figure 27 Offset of a curve For an implicit surface, f(x,y,z) = 0, the normal is obtained by taking Vf and normalizing it. This approach also involves square root computation in the normalization step. Hence the offset surface is functionally more complex than the progenitor implicit surface. Figure 27 provides an example of an offset curve, illustrating the idea of a signed distance along the surface normal. 4.5.2 Offset of a triangulated surface Offset is well understood for continuous representations such as algebraic surfaces and parametric surfaces. However, offset of a tessellation has not received so much attention and detail. A tessellation is a linear interpolation of points on a surface and hence to a large extent, can be regarded as a discrete representation. We define the offset of a tessellation to be the locus of all points which are at a fixed signed distance away from the given tessellated surface. The notion of surface normal is not well defined for a discrete set of points. For a tessellation, we encounter two approaches to evaluating surface normals. For each of the triangle on the surface, there is a surface normal associated with the plane of 62 the triangle. There is also the school of thought which tries to attribute an average surface normal value to each vertex on the surface. The offset of a tessellation could be computed based on either of these sets of normal values. 4.5.2.1 Averaged surface normal approach Lemma: A given vertex on the surface of a solid will have atleast three incident triangles if it does not have tears or holes. From the first principles, a surface normal will be normal to the tangent plane. The tangent plane is equiangular to each of the planes of the triangles sharing a given point. We like to compute the surface normal at a point as such a vector that is equiangular to each of the surface normals of the planes of the triangles sharing the point. There has not been any algorithm reported for computing such a vector, given an arbitrary set of vectors. 4.5.2.2 Localized paraboloid normal This approach to compute an averaged surface normal value for each vertex on a tessellation involves computing a localized quadratic surface approximation. The adjacency information for each vertex is first computed. For each vertex on the surface, we determine the list of all vertices which share a common edge with the given vertex. The given vertex is assumed to be at the vertex of a paraboloid which passes through the vertices in its adjacency list [Figure 28]. By least squares approximation, we are able to find the algebraic equation for the paraboloid and thence, we estimate the surface normal . Figure 28 Localized paraboloid around a vertex in a tessellation. The normal for the vertex is found from the normal to the paraboloid. It has been shown that the error in such a computation is of second order [Marciniak 01] . The localized paraboloid normal computation is a robust approach for approximating the surface normal at a vertex. The offset of the initial tessellation is then computed as a signed offset along each of these surface normals at the individual vertices. 4.5.2.3 Offset of planes approach A tessellation consists of vertices, edges and triangular faces. Each vertex can be regarded as an algebraic solution of the planes which share it. Exception to the above statement occur when the faces sharing a vertex are co-planar. Since surface normal for a plane is well-defined, the offset of the vertices can be indirectly computed by offsetting the planes and then computing their intersection. From an indexed mesh, for each vertex, 63 we have to find all triangles which share it. This is computed indirectly in the following fashion: for each triangle, we find the indices of its three vertices. Then for each of the vertex indices, we add the triangle's index in a list. Thus, by sweeping through the list of triangles, we are able to identify all triangles which share a particular vertex. We then offset the planes corresponding to these triangles by a fixed distance and re-compute their intersection. By identifying degenerate cases, we are able to robustly compute the offset surface. When the offset does not result in self-intersections, it is easily observed that the edges on the tessellation will be moving along the entity Voronoi diagram in the interior of the tessellation. When the original surface has self-intersection, some of the Voronoi planes merge together and form new planes. 4.6 Bounding volumes with depth information In our research, we decided to adopt discrete orientation polytopes as the bounding volumes. Section 2.3.2.6 has a discussion on k-DOPs as bounding volumes. We found that their rapid overlap detection and their easy update between orientations, suit our requirements for a real-time collision avoidance system. We make no assumptions abou the object models and their geometry. The dynamic object is modelled as a cloud of points while the static terrain is modelled as a polygon soup. We model both these environments using bounding volume hierarchies of k-DOPs. This section presents a potential problem associated with discrete orientation bounding volumes and a solution for the same. 4.6.1 Where do the bounding volumes of surface representations fail? We analyzed the role of bounding volumes with specific application to a surface representation. Bounding volume hierarchies are dependent on the idea that at successive levels of the hierarchy, the bounding volume approximates the surface more accurately and thus, the intersection detection query becomes refined. From an abstract perspective, one uses bounding volumes for encasing solid objects. These bounding volumes are three dimensional convex objects which are used to enclose the whole or parts of a given object's surface. At a very localized level, with the exception of sharp corners, the surface of an object would most likely match a planar surface. In such a situation, the bounding volume would turn out to be too thin and also lose a dimension - its thickess along a direction normal to the bounded surface. The dimension lost thus is referred as depth with specific reference to the depth of penetration from the surface of the solid. Ho has reported this problem as common among all triangle-set methods [Ho 99] . Other researchers have observed this case when the bounding volume thickness goes to zero, but they have presented it as a case when the algorithm actually speeds up because of the lesser number of directions to check for overlap [Held 98] [Gottschalk 96] . In our collision detection approach, one of the objects is modelled as a point cloud. At every stage of the algorithm, we like to ensure that there is no collision between the objects if the bounding volume overlap tests return a negative. Near the leaf-level in the bounding volume hierarchy, we could possibly encounter a case where two bounding volumes could not be overlapping, but one of the bounding volumes could be completely 64 inside the other object and hence it will be a case offalse-negative result of the algorithm. Figure 29 shows an example situation when the objects are colliding while their bounding volumes indicate no overlap. Bounding box with points inside Thin Bounding Box Figure 29 Objects are overlapping even though bounding boxes don't The Bounding Box here is axis aligned. One of the sides is nearly parallel to the coordinate axis and it causes the bounding box to be extremely thin. 4.6.2 Add depth to bounding volumes using offset The problem, as cited above in the case of bounding volumes is removed if we are artificially able to add the depth information in them. We create the offset surface of a given object's surface at a specified depth and add the same depth information into the bounding volumes. The reason is that, even in the earlier worst case of a facet being parallel to a coordinate axis, the offset of the same facet would be adding the depth in a direction perpendicular to the plane of the facet. Hence, we can very easily observe the bounding volume having the depth information. Figure 30 indicates the adding of offset surface to provide bounding volumes with depth information. 65 Progenitor surface Offset surface Figure 30 When combined with offset surface, bounding volume carries depth information 4.7 Implicit Voronoi Verification - Our Conjecture The triangle on the surface as well as the triangle in the offset location, together define a volume for which the given surface triangle is the closest among all other facets. When this region is bounded by a k-DOP with a large set of directions, the inaccuracy between the bounding volume and the enclosed volume is less. Some of the bounding planes approximate the Voronoi planes between the triangles. This is the basic philosophy which binds Offset of a triangulation and the entity Voronoi diagram. We conjecture that our bounding volume overlap tests are themselves an approximate Voronoi plane checks for the nearest neighbor. The k-DOP overlap tests mimic the proximity queries against the Voronoi planes and add to the efficiency of our approach. Section 4.5.2.3 explains how an entity Voronoi diagram comes in play when two planes are offset. Figure 31 shows a 2-D equivalent of this situation. If a point is wrongly reported as inside a bounding volume of a region while it is actually not so, we find that such a point has to be inside the region common to two adjacent bounding boxes. In Figure 31, the shaded region indicates the common region between the adjacent bounding boxes. Any point which could wrongly get attributed to the other adjacent bounding box has to belong to this shaded region. We also find that such a region should include the Voronoi plane between the two surface facets. As a result of this, the given point will be close to the Voronoi plane and hence, the distance of this point from the two adjacent planes will be nearly equal. Thus, even in the absence of an explicit and accurate proximity check, if we use only the bounding volume overlap tests to determine the closest feature, we will not be adding too much error in the computation of the penetration distance. 66 The discussion so far indicates that there could be cases offalse positives. For an accurate collision avoidance algorithm, there is the need to have explicit and accurate proximity checks so that the measure of penetration could be computed accurately. In the following section, we explain how we also compute and maintain a data structure of the actual Voronoi diagram between the various triangles. By computing the Voronoi diagrams, we achieve complete accuracy in our algorithm. This enhances the implicit Voronoi verification already achieved during the bounding volume overlap tests. Point on surface Image Point Voronoi Plane Figure 31 Bounding box encloses the original triangle and its "image". It also implicitly bounds the Voronoi planes the extremes. 4.8 Explicit Voronoi Verification - A Robust Approach In the following discussion, facet refers to a triangle of a tessellation. Computation of the offset of a tessellation assumes that the connectivity information amongst vertices still remains unaltered. For each facet of the tessellation, there exists a corresponding facet on the offset surface. The offset surface and the original surface facets combine to provide an implicit representation of the Voronoi diagram in the shallow region beneath the surface. Accurate penetration detection and avoidance makes it necessary that we verify explicitly against the equations of the Voronoi planes surrounding each facet. For a pair of planes which intersect along a line, the voronoi plane between them is the angle bisector plane [Figure 32]. Thus, for a tessellation, we can associate each Voronoi plane uniquely with an edge of the tessellation. The fact that the voronoi plane is the angle bisector plane between two facets on the surface enables its easy computation. We use the fact that the longer diagonal of a rhombus is the angle bisector between the non-parallel sides. If n, and n 2 define the surface normals of two planes, we find that n, - n 2 defines the surface normal for the bisector plane. This approach, however does not yield the correct answer when the two planes are co-planar. The above method will yield a zero vector [Figure 33]. We use the direction of the edge between the two facets to robustly compute the surface normal of the Voronoi plane associated with that edge. 67 \ x Normal Nororaa 2 Voronoi plane's normal Figure 32 Very close to the surface, the Voronoi planes can be associated with a distinct edge on the tessellation. n, + n2 / n,-n n2 2 \ \ /2n n, Figure 33 The diagonals of the rhombus drawn with the two normal vectors as adjacent sides are directly related to the Voronoi plane between the planes whose normals are n1 and n 2 68 Chapter 5 Penetration detection and avoidance 5.1 Outline Penetration detection amounts to quantifying the extent to which two objects intersect, while keeping in mind that suitable correction measures should be developed so that the objects move out of intersection. The problem of an optimal measure of correction to two penetrating objects is still open. We adopt a translational correction measure at the heart of our algorithm. From the background presented in Section 2.4, there has mostly been an emphasis on collision detection. Our research attempts to detect a measure of penetration and also propose an avoidance scheme. Chapter 4 presents the various theoretical ideas developed as part of this thesis. The data structures have been built keeping in mind the potential pitfalls associated with floating point arithmetic. As in common practice, we employ a bounding volume hierarchy to expedite the detection of collisions. k-DOPs are the bounding volumes used and as explained in Section 4.6, they are modified to carry depth information. Voronoi diagram between the surface triangles in a tessellation is computed for verification of the closest pair of features. Alongwith the pre-processing stage, most collision detection algorithms that use bounding volumes can be considered as having two phases, called the broadphase and narrowphase. The broad phase and narrow phases have distinct characteristics, and often have been treated as independent problems for research. Even in this research, we attempt to specifically optimize the computations in the broad phase and narrow phase separately. 5.2 Sizes of data structures The input to the pre-processing stage are two solid model files in STL format. The data structures built are thus: a linear array storing the indices of the vertices, an array for storing the indices of the edges and an array for storing indices to the triangles are built com- 69 monly for both objects. Though the dynamic object is treated as a point cloud; but it does carry its polygon soup information which could be used, should the need be. Let V be the number of vertices, E be the number of edges and F,the number of triangles in our solid model. Assuming we have no abnormalities such as holes and tears, we find that E = 1.5F There are three edges for each triangle and each edge gets counted twice when we count all edges of all triangles. By Euler's equation, -E+V+F = 2 As a result, F = 2V-4 and E = 3V-6 The total number of Voronoi planes between the triangles equals the total number of edges and hence, it is linear in relation to the number of the vertices. The Voronoi planes are also stored as a linear array, with each plane uniquely being represented by its surface normal and the projection distance from the origin. Additional information in the form of the two triangles sharing each voronoi plane are also stored for ease of computation during run-time of the algorithm. 5.2.1 Broad phase In the broad phase, collisions between the bounding volumes are detected rather than the underlying geometric primitives. Across various collision algorithms, the broad phase is nearly similar. They might differ only in the choice of the bounding volume type. In the broad phase, we find all pairs of intersecting bounding boxes. In our algorithm, the broad phase is recursive. The pseudo-code for the broad phase is given below. Pseudo-code for broad phase algorithm Input: object 1, object 2 output: Pairs of bounding volume leaves, one each of object 1 and object 2, which are reported to be under overlap. Algorithm: 01 collision-detect( object 1 Bounding volume, object 2 Bounding volume){ 02 if ( bounding volumes of object 1 and of object 2 overlap) 03 then if object 1 is not a leaf 04 collision detect( object 1's left child, object 2); 05 collision detect( object l's right child, object 2); 06 else if object 2 is not a leaf 07 collision detect(object 1, object 2's left child); 08 collision detect(object 1, object 2's right child); 09 else 10 report collision between bounding volume leaves; 11 12 1 70 . M The above bounding volume hierarchy is binary in nature. Similar implementations are possible for broader tree versions, with each node having more than two children. 5.2.2 Narrow phase For each intersecting pair of bounding volume leaves as reported by line 11 of the broad phase, we perform a detailed intersection test on the corresponding objects. In the narrow phase, the spatial interactions amongst the geometric primitives are explicitly detected for computing penetration values. The performance of a narrow phase algorithm does not depend on the total number of vertices in the object, but on the complexity of each object. If the geometric primitives enclosed by the leaf-level bounding volumes in the hierarchy are complex for computing the penetration, it would reflect in the narrow phase algorithm taking up too much computation time. In our algorithm, we have a set of points as part of one of the bounding volume's primitives and a triangle as the other object's primitive. Thus, for each point in the first bounding volume, we first check if the triangle in the other bounding volume is indeed the closest feature. This query is performed by checking the point against the three Voronoi planes associated with each of the three edges of the triangle. Once the Voronoi planes indicate the triangle to be the closest feature, then we compute depth of the point by evaluating the distance from the point to the plane of the triangle. Broad phase D I.' Narrow phase I...' Li*J Figure 34 Broad phase and narrow phase of our collision detection algorithm Pseudo-code for narrow phase algorithm Input: Bounding volume leaf from object 1 and from Object 2 output: 71 Penetration depth of each point reported under intersection and the direction along which this depth is computed. Algorithm: 01 Narrow phase { 02 for each geometric primitive in object l's bounding volume leaf 03 closest, 04 { if the primitive in object 2's bounding volume leaf is the compute the exact extent of penetration; } 05 compute an over-all correction measure based on all these individual correction measure values; } 5.2.3 Adaptive approach in updating bounding volumes and object models Section 5.2.1 and 5.2.2 discuss the collision detection algorithm and its implementation. Collision detection algorithms run in a real-time scenario, where computational time is sparingly available. A direct approach to the collision algorithm would be to transform the entire object to the new position and orientation, and then build the bounding volume hierarchy. Such a difficulty is encountered if we use OBB or AABB as the bounding volumes. In essence, the bounding volume depend on the underlying object's position and orientation. When using k-DOPs as the bounding volumes, the object is bounded once and all further transformations are applied to the initially created bounding volume hierarchy [Figure 14]. When the new position and orientation of the moving object's coordinate frame are known, the bounding volume hierarchy is updated first. For the narrow phase of the algorithm, the object's coordinates are transformed only when it is reported that the bounding volume leaves are under overlap. Only those portions of the object that are most likely to be under collision are selectively transformed. Proper book-keeping also ensures that the coordinates of the object are not transformed over and over again. As an improvement, an adaptive approach is used for updating the bounding volume hierarchy as well. As we traverse the tree in a top-down fashion from the root, we update the children of a node only when that node is reported under overlap. The algorithm thus updates only those bounding volumes which could possibly be under overlap. 5.3 Collision Avoidance Most collision detection algorithms till date have stopped with reporting collisions. Keerthi [Keerthi 89] provided the first work on the concept of negative distances between two convex polyhedra in intersection. Ong [Ong 93] tries to quantify penetration and provides a measure of penetration between convex polyhedra. These measures, called Growth distances are very useful in the case of convex polyhedra to quantify both separation as well as interpenetration. These provide insight into quantifying the extent of collisions, leaving the idea of collision avoidance still open. 72 We have invented a method of accurately computing the penetration depths of all points under intersection. The direction along which these penetrations are minimum are also found. Taking all these values into account, we propose an overall correction scheme. We have a weighted approach, with each correction vector being additionally weighted by the depth of penetration. The overall translation correction vector e is given by, d 2ini * Id i where n is the direction alongwhich a particular point has to be moved to bring it out of penetration, and d; is the penetration depth of that particular point. The scheme shown above is an averaged collision avoidance scheme. It is iterative in nature. For an example, we present a test case of a circle vs. a pair of intersecting lines. At each stage, the correction vector is applied to the circle object and finally the intersection is eliminated after 7 iterations. 1.6 Figure 35 Iterative nature of our collision avoidance scheme We implemented this scheme to a few test cases and found the number of iterations to remove penetration to be between 4 and 8. 5.4 Measures of complexity of collision detection algorithms A complete understanding of any algorithm necessitates the analysis of its computa- tional complexity. Collision detection and avoidance algorithms fall under a special category of algorithms which are output sensitive, i.e., the computational effort involved in the algorithm depends not only on the size of the input, but also on the size of the output. Consider the case of two polyhedra which are separated in space. The collision detection algo- 73 rithm will stop once non-overlap is reported from the tests in the bounding volume hierarchy. Consider another instance when the two polyhedra are under overlap. The bounding volume hierarchy will report the overlap and then appropriate penetration computation and avoidance measures are adopted. Clearly the latter case involves more computations than the former. The difference between these two cases illustrates the output sensitive nature of the time complexity of the algorithm. At the very basic level, the complexity of our collision detection algorithm can be represented as a sum of the time taken for the broad phase algorithm, the time taken for the narrow phase algorithm and the time taken for computing an overall correction measure. T = Nb xb+Nnx tn+D(Nn) where T is the total time taken by the algorithm, Nb is the number of bounding volume pairs intersecting in the algorithm, tb is the time taken for an overlap test between a bounding volume pair, Nn is the number of primitives under overlap at the leaf level of the hierarchy, t b is the time taken to compute a measure of penetration from an overlap at the leaf level, 1D(n) is the time taken to compute an overall correction from the individual penetration measures. Such a time computation is more, qualitative in nature and is useful to understand the true behavior of the collision detection algorithm. To better understand the time of computation involved while using bounding volume hierarchies, we can rewrite the equation for the time complexity of the algorithm as T= = ( =In) ' (Nb -ij)) XIb+ Nn xrn + D(N where Nb-ij is the number of bounding volume pairs intersecting in the broad phase such that one of the bounding volume is that of the static object's hierarchy at a depth i and the other bounding volume belongs to the dynamic object's hierarchy at a depth j, J. is the height of the static object's bounding volume hierarchy, X is the height of the dynamic object's bounding volume hierarchy. This approach helps us understand the trade-offs involved in using a particular bounding volume as compared to another. When we use a bounding volume which encloses a large number of primitives and whose overlap test is easy, for e.g., an AABB, Nb is very small, but at the same time, it increases N, and Tn also. Suri et al, have proposed a model to analyze the time involved in a collision detection algorithm with a bounding volume hierarchy [Suri 99] . They compare the total number of object pairs that are tested for collision against the total number of object primitives under 74 collision. The total number of object pairs that are tested for collision, Kb is the computational effort taken by the algorithm. The total number of object primitives under collision, K, is the minimum effort necessary to be taken for the specific instance of the input. Suri et al, have proposed bounds for the ratio between the two values Kb and K0 , based on the bounding volume's aspect ratio and the scalefactor in a bounding volume hierarchy. 75 76 Chapter 6 Results The objective of our research has been to detect measures of penetration between two generic three dimensional solids and to provide correction measures to disengage two objects under intersection. We have proposed an algorithm to this effect and Chapter 4 carries the description of the algorithm. In Chapter 5, we provide the pseudo-code and address some of the important issues in programming this algorithm. While understanding the efficiency of our algorithm, we also reiterate that the implementation of the algorithm through programming is another equally challenging problem. In this chapter, we present the results from implementing our algorithm. Alongside the programming implementation, we have also discovered two important ideas which will improve the performance of bounding volume hierarchies using k-DOPs. Section 6.1.1 provides details of these ideas. Section 6.1.3 is a recap of "shallow penetration", which has been the backbone of our algorithm. In Section 6.1.4, we discuss some of the findings from our research which helped in optimizing the computational effort. We conclude this chapter with a section on applications of our algorithm and suggested future work arising from our work. 6.1 Implementation of our algorithm We implemented our collision detection algorithm on a SGI Octane with two 250MHz R10000 CPUs. The dual processor environment was useful particularly to expedite the computations and the graphics rendering at the same time. Our test cases involved static objects having around 2400-2500 triangles and the moving object composed of 500-600 points. For the bounding volume hierarchy, we employed a 26-DOP and at the leaf level of the static object's hierarchy, a single triangle was enclosed while the leaf level of the dynamic object's hierarchy enclosed not more than 20 points. 77 Relative position of objects Number of points of dynamic object under overlap Time (ms) Large overlap 90-130 10-14 Grazing contact 15-30 6~9 No overlap 0 3~4 Table 6.a Timing of our penetration detection and avoidance algorithm on an SGI Octane dual 250 MHz R10000 processors The timings shown in Table 6.a vary a little depending on the input solid models and also on the input motions of the objects. It is also important to note here that the time taken by the algorithm is also dependent on the clock-speed of the processor. With 1.5 GHz processors available currently, we can get faster implementations of our algorithm. 6.1.1 Philosophy of bounding volumes In this research, we found an important characteristic of bounding volumes. Bounding volume hierarchies should be created bearing in mind that at no stage should the bounding volume become computationally more intensive than the object or part thereof, that is enclosed. Should due consideration not be given to the above condition, one would find that the algorithm performs unnecessary computations. It is for this reason that we refer bounding volumes as "Computationally efficient object representations". The depth of the bounding volume hierarchy should be decided based on the comparison between the complexity of the leaf level bounding volumes and the geometric primitives enclosed at the leaf-level. Held reports the use of a threshold value of 1 triangle for the environment hierarchy and 40 triangles for the flying hierarchy [Held 98]. While it is said that these values work well on a large variety of data sets, there is no mathematical argument to support this empirical choice. While implementing our collision detection algorithm on a SGI Octane with two 250MHz R10000 CPUs, we tested the times for transforming a k-DOP from one orientation to another. We ran the simulation updating the k-DOP bounding volume hierarchy in a dynamic environment and specifically computing the times of update when the bounding volume is a 6-DOP, 14-DOP, 18-DOP and 26-DOP. Table 6.b shows these timing results. These values are not constant and fall within a range.. 78 k time (Rs) 6 55-70 14 110~130 18 135-165 26 200-220 Table 6.b Time required for transforming various k-DOPs between two orientations The difference in timing is mainly because of the number of corner vertices present in each of the k-DOPs. A 6-DOP has 8 vertices, a 14-DOP has 24 vertices, an 18-DOP has 32 vertices and a 26-DOP has 48 vertices. Transformation of the k-DOP bounding volume hierarchy amounts to transforming the corner vertices of the initial k-DOPs [Figure 14]. This gives a metric for the minimum number of vertices needed in the leaf-level geometric primitives so that using a k-DOP is efficient. For example, if we are using a 14-DOP, then there must be atleast 24 vertices enclosed in the leaf-level geometric primitives. Otherwise, the leaf-level k-DOP transformation and subsequent transformation of the underlying primitives amounts to unnecessary computations. The size of the dynamic object (i.e. the flying hierarchy) is limited by the processor speed. We should not naively compute the transformation of the entire object. Instead, we focus only on those portions of the object which are most likely to be under collision. The object's size is indirectly reflected in the size and the depth of the bounding volume hierarchy. In our algorithm, we have employed a 26-DOP. We notice that a 26-DOP could contain a maximum of 48 extremal vertices. Figure 13 presents an example of each type of kDOP and shows the number of corner vertices thereof. Section 5.2.3 presents the adaptive approach, where the children of a bounding box are transformed only when the parent reports an overlap. While using such an approach, we analyzed the typical number of bounding volume corner vertices that are transformed when collision detection query is performed on a moving object. Relative object position Total number of corner vertices transformed to answer overlap query Depth of hierarchy needed to answer overlap query Overlap -860 29-32 Grazing contact -700 25-28 No overlap -400 12-15 Table 6.c Number of bounding volume vertices transformed to answer an overlap detection query 79 Table 6.c presents data for an overlap query involving a static object involving 2400 triangles and a moving object with 600 points. At the leaf level, the static object bounding box had one triangle while the moving object had less than 20 points. The bounding volume tree is not a balanced tree and it is clearly seen in the depth of the bounding volume hierarchy needed to answer the overlap detection query. The number of bounding volume corner vertices that are transformed is a substantial portion of the actual number of vertices in the moving object itself. This number will increase when the size and complexity of the moving object increases. All these vertices need to be transformed for each run-time query. The more the number of bounding volume vertices, the more the computational time required. Thus the size of the dynamic object is limited by the availability of computational power, i.e., the processor speed. 6.1.2 On the choice of directions of a k-DOP Having employed the aforesaid k-DOPs as part of our algorithm, we come up with the following conclusion. The choice of directions in a k-DOP, though obvious for human perception (slicing the vertices or edges or both from a cube) has no mathematical reason or metric supporting it. A k-DOP is a k-Discrete Orientation Polytope. Any set of k directions could be used to create our bounding volume. The only requirement for creating a kDOP is a set of k different normal vector directions and k projection values which define the locations of the planes in space. For the sake of application as a bounding volume, these k directions should be such that the number of corner vertices formed during the intersection of the planes is a minimum. Minimizing the number of the corner vertices improves the time taken to transform the bounding volume hierarchy and hence, enhances the speed of our algorithm. Our conjecture is that these k directions be chosen such that they span the unit sphere of directions in a uniform manner. An example of such a set of directions which span space uniformly are found in Platonicsolids. Platonic solids are polytopes, whose polygonal faces are all regular polygons of the same kind. There are 5 platonic solids - tetrahedron, cube, octahedron, icosahedron and dodecahedron. The platonic solids could be used to define a 4-DOP, 6-DOP, 8-DOP, 12-DOP and a 20-DOP. Given the number k, we can choose the optimal set of directions by equally spacing them on a unit sphere. One could look at the problem as akin to that of placing k equally charged point charges on a unit sphere such that their configuration minimizes the Coulombian potential [Edmundson 92]. Obviously, the relative configuration of all these charges on the unit sphere is not altered by the rotations of the sphere. The basic set of k directions should be chosen such that the bounding volume hierarchy around the objects and their subsets thereof is the tightest. 6.1.3 Shallow penetration Our research objective is to detect and correct shallow penetration between non-convex polyhedra. Collision detection in its broader sense is applicable for penetration to any degree or extent. But then, these involve applications with real world solids. Apart from recognizing that shallow penetration is the scope for most collision detection and avoidance systems, we have identified a potential lacuna in using bounding volume hierarchies 80 to enclose surface elements. We present an example situation where a bounding volume has an almost-zero thickness along a particular direction. Such a bounding volume would yield a false-negative: a case where the algorithm would indicate a potential collision case as though there were no collision. Held reported this case of zero thickness as one that involves lesser overlap tests [Held 98]. They have not presented the possibility of a collision going unnoticed. Ho has reported the above situation as a potential problem with triangulated methods, and hence presents a method involving implicit surfaces [Ho 99]. We have invented a methodology for including a depth information in the bounding volumes. As a suggested topic for future investigation, one could explore metrics for relating the depth to some geometric property of the surface. 6.1.4 Efficient coordinate transformation Real-time collision detection necessitates very efficient and specifically, sparing use of computational power in terms of processor speed and computer memory. A dynamic environment needs update of its orientation map at each instant for the collision detection query. We identify that the dynamic environment needs to be computed only at those locations in space where there is maximum probability of collision. Further, one needs to employ optimization methods for computing the transformation of the object representations. In our case, the dynamic object is represented as a connected set of points, for which the coordinate information needs to be updated at each instant. A coordinate transformation typically consists of a rotation and transformation. Transformation of a vector typically is computed by a homogenous matrix transformation or by means of Rodrigues transformation involving an axis of rotation. In this section, we present some of our results in optimizing the computations involved in transforming the objects. 6.1.4.1 Transformation of the dynamic object We had written our programs in C++ and object oriented programming paradigms were used to handle vector algebra and matrix operations. We find that the overhead encountered because of using the matrix class and the vector class results in the transformation due to matrix multiplication to be not too efficient as one would otherwise expect. In Rodrigues transformation, one evaluates the sine and cosine trigonometric functions. In computers, evaluation of trigonometric functions is carried out using a Taylor series expansion. The sine and cosine functions typically cost about one hundred multiplication operations. As a result, for repeated transformations of several vectors given the same axis angle values, we optimize on the computations by pre-computing sine and cosine values and then passing these values as parameters to the function call. 6.1.4.2 Transformation of the bounding volumes The use of k-DOP is justified by the ease of update between orientations. Unlike OBBs [Ponamgi 97], one does not bound the object in their new position to compute the bounding volumes. Instead, the bounding volume hierarchy is computed around the object in its initial orientation. At every later instant, depending on the transformation undergone by the coordinate frame attached to the dynamic object, we update the bounding volume hierarchy alone. This has been referred as tumbling by Held [Held 98]. Tumbling typically 81 results in a bounding volume whose volume is greater than or equal to the original volume [Appendix B]. This could reduce the accuracy of the bounding volume. This amounts to a trade-off between accuracy and computational time available for the collision detection query. The k-DOP, an intersection of a discrete set of half-spaces defined by planes, is a convex object. Any mathematical operation on the boundary of a convex set can be obtained by the same operation on its extremal points [Grunbaum 67]. So, the transformation of a k-DOP in effect is carried out by the transformation of its extremal vertices. However, the k-DOP is represented by its interval projections along the discrete set of k directions. Rotation of a k-DOP necessitates the computing of the rotations of all its extremal vertices, and then the computation of the projections. Translation of a k-DOP can be computed easily, if one identifies that a translation of a k-DOP only results in the increase/decrease of the interval endpoints by the same amount, along the various directions. Thus for translation of the k-DOP we need not translate each of the individual corner vertices again. This result provides us with a small saving in computations. We find that when the translation of all corner vertices are computed and then, when the projections alone are changed for the case of translation, we end up with a savings of about 10% in the latter case. This improvement, though small, is significant in real-time applications. 6.1.4.3 Broad decision trees The choice of the bounding volume hierarchy is a design choice based on the type of application and the choice of the geometric model. In our algorithm, the dynamic hierarchy is computed as a set of points. While we use k-DOPs as bounding volumes, care is taken to ensure that we don't perform an excessive number of coordinate transformations involving the corner vertices of the k-DOPs. This reason leads us to the requirement that we rapidly traverse down the bounding volume hierarchy to the level of leaves, so that as few number of bounding volume corner vertices are transformed. This is achieved by using a broad tree. We employed a binary tree initially. A 4-tree and an 8-tree were subsequently employed. Table 6.c presents a comparison of the total number of extreme vertices computed in various decision tree models for a typical object. A broader tree ensures that not many bounding boxes are tested for each collision query. It might be possible that a broad tree results in a large number of collision queries than necessary. This is a trade-off that could be investigated for future work. 6.2 Applications Collision detection algorithms usually find applications in robotic path planning, force feedback systems and in dynamic simulations. We present some of the applications possible by employing our algorithm with force feedback systems, or haptic systems. With the possibility of integrating our collision detection algorithm with a force feedback device, i.e., a haptic device, we find a range of applications possible. The first of these is in simulating a virtual factory environment. Consider a production line where people work on a specific set of tasks such as tightening a set of bolts on a car chassis, assembling a set of IC chips on a mother board, moving a particular piece between various machines in a Cellular Manufacturing System etc. Our collision detection 82 algorithm could be used to create such a virtual factory, using head-mounted sensors, gloves and force feedback devices. Being able to handle any non-convex polyhedral model, our algorithm is not limited to a particular set of objects and can suit a variety of applications. Collision algorithms integrated into haptic systems can be used to perform tele-virtual surgery. Several expert surgeons could bring together their expertise in operating a patient through tele-virtual surgery. A remotely located surgeon could operate on a virtual patient and can instruct the surgeon performing the operation about specific tasks to be done. The force feedback system enhances the touch and feel experienced by the remote surgeon and his instructions are more accurate than being guess-work. Force feedback devices find an important use in training dentists. Dentists, in the current times, start their training by observing a senior dentist perform the various operations. After a certain period of learning, the apprentices start hands-on training with dental operations of low or moderate complexity. This method is resorted to in order to avoid the mistakes made during the learning period of the apprentices. Using force feedback devices, dentists could be trained to do complicated operations quickly. By using a virtual set of dentures, there is no fear for mistakes and the apprentice can have a hands-on experience in dental operations of varying complications. Video gaming industry is extremely popular among all ages. Their main advantage has been the fast graphics card to enable very rapid graphics rendering. Combining a generic collision detection algorithm such as ours to video games could greatly enhance their marketing potential. 6.3 Scope for future work Specific to our algorithm, there have been a few new problems that surfaced during our research. We present them here as a suggestion for future research and investigation. Our algorithm relies mainly on the offset approach for a triangulation. We expect the maximum offset depth to be dependent on some of the geometric properties underlying the triangulation, such as local curvature, minimum edge length, average area etc. Understanding this dependency and proposing a useful metric for the same is a suggested area for further research. As noted in our finding about the choice of directions for a k-DOP, we leave open the problem of choosing the particular rotated configuration of the k-different directions which form the tightest fitting bounding volume hierarchy around the given object. 83 84 References [Adachi 95] Y Adachi, T. Kumano and K. Ogino, Intermediate representationfor stiff virtual objects, IEEE Transactions on Robotics and Automation, 1994. [Aggarwal 89] A. Aggarwal, L. Guibas, J. Saxe, P. Shor, A linear time algorithmfor computing the Voronoi diagram of a convex polygon, Discrete and Computational Geometry, 4, 1989, pp. 491-504 [Aurenhammer 91] F. Aurenhammer, Voronoi diagrams:A survey of a fundamental geometric data structure, ACM Computing Surveys, Vol. 25 (3), 1991, pp. 345-405. [Balasubramaniam 99] M. Balasubramaniam, Tool selection and path planning for 3-Axis rough machining, S. M. thesis, Massachusetts Institute of Technology, 1999. [Balasubramaniam 00] M. Balasubramaniam, S. Ho, S. E. Sarma and Y. Adachi, Generatingcollisionfree 5axis toolpaths through a haptic interface, communicated to Computer Aided Design. [Baraff 89] D. Baraff, Analytical methods for dynamic simulation of non-penetratingrigid bodies, Computer Graphics (SIGGRAPH '89 Proceedings), Vol 23, July 1989, pp. 223-232. [Baraff 94] D. Baraff, Fast Contact force computation for non-penetrating rigid bodies, ACM Trans. on Computer Graphics, Vol. 28, 1994, pp. 23-34. [Barber 96] B. Barber, D. Dobkin and H. Huhdanpaa, The Quickhull algorithmfor convex hulls, ACM Trans. on Mathematical Software, Vol. 22, No. 4, Dec. 1996, pp. 469-483. [Beckmann 90] N. Beckmann, H-P. Kriegel, R. Schneider and B. Seeger, The R*-tree: an efficient and robust access methodfor points and rectangles, In Proc. ACM SIGMOD International Conference on Management of Data, 1990, pp. 322-331. [Cameron 86] S. A. Cameron and R. K. Culley, Determining the minimum translation distance between two convex polyhedra, Proc. IEEE International Conference on Robotics and Automation, 1986, pp. 591-596. [Cameron 91] S. A. Cameron, Approximation hierarchies and S-bounds, Proc. of Symposium on solid modelling foundations and CAD/CAM applications, 1991, pp. 129-137. [Cameron 96] 85 S. A. Cameron, A comparison of two fast algorithms for computing the distance between convex polyhedra, IEEE Transactions on Robotics & Automation, July 1996. [Cameron 97] S. A. Cameron, Enhancing GJK: Computing minimum and penetration distances between convex polyhedra, Proc. Int. Conf. on Robotics & Automation, April 1997. [Canny 86] J. F. Canny, Collision detection for moving polyhedra, IEEE Trans. on Pattern Analysis & Machine Intelligence, 8(2), Mar. 1986, pp. 200-209. [Canny 87] J. F. Canny, The complexity of robot motion planning, MIT Press, 1987. [Chazelle 80] B. Chazelle, Computational Geometry and Convexity, Ph.D. thesis, Yale University, 1980. [Chazelle 84] B. Chazelle, Convex partitions of polyhedra: a lower bound and worst-case optimal algorithm, SIAM J. Comput., 13, 1984, pp. 488-507. [Chazelle 95] B. Chazelle, D. Dobkin, N. Shouraboura, A. Tal, Strategies for polyhedral surface decomposition: An experimental study, Symposium on Computational Geometry, 1995. [Chazelle 97] B. Chazelle, L. Palios, Decomposing the boundary of a non-convex polyhedron, Algo- rithmica, 17, 1997, pp. 245-265. [Crosnier 99] A. Crosnier, J. R. Rossignac, Tribox bounds for three dimensional objects, Computers & Graphics, 23, 1999, pp. 429-437. [de Berg 97] M. de Berg, M. van Kreveld, M. Overmars, 0. Schwarzkopf, Computational Geometry: Algorithms and Applications, Springer Verlag, 1997. [Dobkin 80] D. Dobkin and B. Chazelle, Detection is easier than computation, Proc. 12th ACM SIGACT Symposium, Los Angeles, May 1980, pp. 146-153. [Dobkin 85] D. Dobkin and D. Kirkpatrick, A linear algorithmfor determining the separation of convex polyhedra, J. of Algorithms, 6, 1985, pp. 381-392. [Dobkin 90] D. Dobkin, J. Hershberger, D. Kirkpatrick and S. Suri, Computing the Intersectiondepth of polyhedra, Manuscript 1990. [Dworkin 94] 86 P. J. Dworkin, Efficient Collision Detection for real-time simulated environments, S. M. thesis, Massachusetts Institute of Technology, 1994. [Edelsbrunner 85] H. Edelsbrunner, Computing the extreme distances between two convex polyhedra, J. of Algorithms, 6, 1985, pp. 213-224. [Edmundson 92] J. R. Edmundson, The distribution of point charges on the surface of a sphere, Acta Crystallographica A48, 1992, pp. 60-69. [Foley 96] J. D. Foley, A. Dam, S. K. Feiner, J. F. Hughes, Computer Graphics - principles and practice, Addison-Wesley Pub. Co., 1996. [Gibson 00] S. F.Gibson, R. N. Perry, A. P. Rockwood, T. R. Jones, Adaptively Sampled Distance Fields: A General Representation of shape for Computer Graphics, Mitsubishi Electric Research Laboratories Technical Report TR2000-15, 2000. [GJK 88] E. G. Gilbert, D. W. Johnson and S. S. Keerthi, A fast procedurefor computing the distance between objects in three-dimensionalspace, IEEE J. Robotics and Automation, vol RA-4, 1988, pp. 193-203. [Goldberg 91] D. Goldberg, What every computer scientist should know about floating point arithmetic, ACM Computing Surveys, 23(1), 1991, pp. 5-48. [Gottschalk 96] S. Gottschalk, M. C. Lin, D. Manocha, OBB Tree: A hierarchicalstructurefor rapid interference detection, Proc. of ACM SIGGRAPH, 1996. [Grunbaum 67] B. Grunbaum, Convex polytopes, John Wiley and Sons Ltd. 1967 [Held 98] J. T. Klosowki, M. Held, J. S. B. Mitchell, H. Sowizral, K. Zikan, Efficient collision detection using bounding volume hierarchiesof k-DOPs, IEEE Trans. on Visualization and Computer Graphics, 4 (1), Jan 1998, pp. 21-36. [Ho 99] S. Ho, Real time detection of geometric interference: Application to full-body haptics, S. M. thesis, Massachusetts Institute of Technology, 1999. [Hubbard 95] P. M. Hubbard, Collision detection for interactive graphics applications,IEEE Trans. on Visualization and Computer Graphics, 1(3), Sept 1995, pp. 218-230. [Indyk 00] 87 P. Indyk, Higher dimensional ComputationalGeometry, Ph.D. thesis, Stanford Univer- sity, 2000. [Jimenez 00] P. Jimenez, F. Thomas, C. Torras, 3D Collision Detection: a survey, Computers & Graphics, 25, 2000, pp. 269-285. [Keerthi 89] S. S. Keerthi and K. Sridharan, Efficient algorithmsfor computing two measures of depth of collision between convex polygons, Technical Report, Department of Com- puter Science and Automation, IISc, Bangalore, India, 1989. [Kim 98] D. J. Kim, L. Guibas and S. Y. Shin, Fast collision detection among multiple moving spheres, IEEE Trans. on Visualization and Computer Graphics, 4(3), 1998, pp. 230242. [Kim 01] T. Kim, Machine optimal tool pathsfor 5-Axis machining, Ph.D. thesis, Massachusetts Institute of Technology, 2001. [Kimmel 98] R. Kimmel, N. Kiryati and A. M. Bruckstein, Multivalued distance maps for motion planning on surfaces with moving objects, IEEE Trans. on Robotics and Automation, Vol. 14, 3, June 1998, pp. 427-436. [Krishnan 97] S. Krishnan and D. Manocha, An efficient surface intersection algorithm based on lower dimensionalformulation, ACM Trans. on Computer Graphics, Vol. 16(1), 1997, pp. 74-106. [Krishnamurthy 98] V. Krishnamurthy, Fitting smooth surfaces to dense polygonal meshes, Ph.D. thesis, Stanford University, 1998. [Lin 91] M. C. Lin and J. F Canny, A fast algorithm for incremental distance computation, Proc. of IEEE Conf. on Robotics and Automation, 1991, pp. 1008-1014. [Lin 93] M. C. Lin, Efficient collision detection for Animation and Robotics, Ph.D. thesis, Uni- versity of California, Berkeley, 1993. [Lin 98] M. C. Lin, S. Gottschalk, Collision detection between geometric models: a survey, Pro c. of IMA Conference on Mathematics of surfaces, 1998. [Maekawa 99] T. Maekawa, An overview of offset curves and surfaces, Computer Aided Design, 31(3), 1999, pp. 165-173. 88 [Marciniak 01] K. Marciniak, Personal communication, April 2001. [Megiddo 83] N. Megiddo, Linear-time algorithmsfor linear programming in R3 and relatedproblems, SIAM J. of Computing, 12, 1983, pp. 759-776. [Mehlhorn 84] K. Mehlhorn, Data Structures and Algorithms, Volume 1: Sorting and Searching, Springer-Verlag, Berlin, 1984. [Mehlhorn 84] K. Mehlhorn, Data Structures and Algorithms, Volume 3: Multi-DimensionalSearching and ComputationalGeometry, Springer-Verlag, Berlin, 1984. [Mirtich 96] B. Mirtich, Impulse based dynamic simulation of rigid body systems, Ph. D. thesis, University of California, Berkeley, Dec 1996. [Mirtich 98] B. Mirtich, V-Clip: Fast and robust polyhedral collision detection, ACM Trans. on Graphics, Vol. 17(3), July 1998, pp. 177-208. [Ong 93] C. J. Ong, Penetrationdistances and their applicationto Robotic path planning, Ph.D. thesis, Univ. of Michigan, Ann Arbor, 1993. [Patrikalakis] N. Patrikalakis and T. Maekawa, Course notes for 2.158 - Computational Geometry, Massachusetts Institute of Technology. [Pham 92] B. Pham, Offset curves and surfaces: a brief survey, Computer-Aided Design, 24(4), 1992, pp. 223-229. [Pobil 96] A. Pobil, M. Perez, B. Martinez, A practicalapproach to collision detection between general objects, Proc. of IEEE Conf. on Robotics and Automation, April 1996. [Ponamgi 97] M. Ponamgi, M. C. Lin, D. Manocha, Incremental algorithmsfor collision detection between polygonal models,IEEE Trans. on Visualization and Computer Graphics, Vol. 3(1), 1997, pp. 51-67. [Pentland 89] A. Pentland and J. Williams, Good vibrations:Modal dynamics for graphicsand animation. Computer Graphics (SIGGRAPH '89 Proceedings), Vol 23, July 1989, pp. 215-222. [Quinlan 94] 89 S. Quinlan, Efficient distance computation between non-convex objects, Proc. IEEE Conf. on Robotics and Automation, 1994. [Sarma 99] S. Sarma, The Crossing function and its application to zig-zag toolpath generation, Computer Aided Design, 31, Dec 1999, pp. 881-890. [Shamos 75] M. I. Shamos, Geometric complexity, Proc. 7th ACM Symposium on the Theory of Computing, May 1975, pp. 224-233. [Shamos 85] F. P. Preparata and M. I. Shamos, Computational Geometry - an Introduction, Springer-Verlag, New York, 1985. [Suri 99] S. Suri, P. M. Hubbard and J. F. Hughes, Analyzing bounding boxesfor object intersec- tion, ACM Trans. on Graphics, Vol. 18(3), 1999, pp. 257-277. [Teller 99] S. Teller and M. Teichmann, Polygonal approximationsof Voronoi diagramsof a set of triangles in three dimensions, Technical report 766, Lab for Computer Science, MIT, 1997. [Vaidya 89] P. M. Vaidya, An O(n log n) algorithm for the all-nearest-neighbours-problem,Dis- crete & Computational Geometry, 4, 1989, pp. 101-115. [Weiler 85] K. Weiler, Edge-based data structuresfor solid modeling in curved-surface environ- ments, IEEE Computer Graphics and Applications, 5(1), January 1985, pp. 21-40. [Woo 85] T. Woo, A Combinatorialanalysis of boundary data structure schemata, IEEE Com- puter Graphics and Applications, 5(3), March 1985, pp. 19-27. 90 Appendix A : Terminology affinely independent set A set of points T c R d is affinely independent if no point x e T is an affine combination of T - x. AABB Axis-Aligned Bounding box. A bounding volume whose six boundary planes are normal to the three coordinate axes. B-Rep Boundary Representation. A solid model representation where the geometric primitives on the boundary is used to represent the solid. BSP Binary Space Partition. A scheme of dividing n-dimensional space in a binary fashion using primitives in n-i dimensions. d-ball An open d-ball in Rd with radius p and center a is the set of points with Euclidean distance less than p from a. For example an open 2-ball in R 2 is an open disk. convex set A set X in Rd is convex if, for any two points a and b in X, the line segment ab is completely contained in X. convex hull The convex hull of a point set S in Rd is the smallest convex set in Rd containing S. The convex hull of a set S is sometimes written as conv S. connectivity Connectivity of a set S is defined by the set of all geometric primitives sharing a common element with the set S. For eg., connectivity of a triangle T includes the set of all triangles which share an edge or a vertex with T. CSG 91 Constructive Solid Geometry. A solid model representation where a set of Boolean operations performed on a set of common solids and shapes defines the solid. Delaunay Triangulation The Delaunay triangulationis a triangulation of a point set S in Rd where each simplex s has the open ball property, i.e. there exists an open d-ball with the points defining s on its boundary which contains no points in S. dimension The dimension of a k-simplex is k. The dimension of a simplicial complex K is equal to the maximum dimension of any simplex in K. face The face of a simplex s is a simplex defined by a subset of the points defining s. For example a triangle has 3 vertex and 3 edge faces, as well as itself. general position In the description of geometric algorithms, it is common to explicitly assume that certain degenerate cases do not occur in the input, this is known as assuming general position. The particular assumptions depend upon the algorithm under consideration, for example when computing Delaunay triangulations of points in the plane one typically assumes that no 3 points are colinear and no 4 points are cocircular. interval tree The interval tree is a data structure designed to handle intervals on the real line whose extremes belong to a fixed set of N abscissae. polyhedron A polyhedron is a three dimensional solid whose boundary features are polygonal and also contain the edges and the vertices in the boundary. Rd Rd denotes d-dimensional Euclidean space. regular triangulation A regulartriangulationis a generalization of the Delaunay triangulation where there is a real weight associated with each site in the input. The dual to a regular triangulation is the power diagram. 92 shape The shape of a simplicial complex is defined by the union of its simplices. k-simplex A k-simplex is the convex hull of k+1 affinely independent points. A 0-simplex is a point, a 1-simplex is an edge, a 2-simplex is a triangle, and a 3-simplex is a tetrahedron. k-DOP k-Discrete Orientation Polytope. A bounding volume whose boundary planes are normal to set of a k-discrete directions respectively. OBB Oriented Bounding Box. A bounding volume with six boundary planes which are oriented normal to the three principal axes of inertia of the enclosed set of points. The Oriented Bounding Box follows the shape of the underlying object to the maximum extent possible. Sphere trees Sphere trees are a bounding volume hierarchy in three dimensions where each bounding volume is a sphere. The tree is usually built in a bottom-up fashion, with each parent node being the smallest enclosing sphere of its two children. The popularity of sphere trees arise from their ease of distance computation and overlap detection. Voronol diagram The Voronoi diagram of a finite point set S C Rd subdivides Rd into regions such that for each point a in S, there is a Voronoi cell V such that every point in V is at least as close to a as any other point in S. 93 94 Appendix B : Inaccuracy in the update of k-DOPs Update of the bounding volume hierarchy of k-DOPs is different from conventional methods of update. In a conventional update method, an object is transformed first and the bounding volume hierarchy is computed based on the new position and orientation of the object. For a k-DOP, the update is based on the initial bounding volume hierarchy and not the object that it encloses. Figure 14 shows how this update is carried out on an 8-DOP. Here, we give a proof that such an update results in a slight decrease in accuracy. We first prove that k-DOP is a convex object. k-DOP is defined by the intersection of a finite number of half-spaces in R3 . Half-spaces are convex sets and therefore their intersection is a convex set. The boundary of the k-DOP will then coincide with its convex hull, by property of convex sets [Grunbaum 67]. During update, when we bound the initial k-DOP Q with a set of k-hyperplanes, we get a new convex object Q' for which K is a subset. Of all objects Q', the tightest fitting one is the convex hull, which in this case is Q itself. Thus, Q' can at best be as tight fitting as Q. Hence, in most cases, the newly updated k-DOP Q' will be less tight compared to the initial k-DOP f. This completes the proof why the k-DOP update method adds a small amount of inaccuracy to the bounding volumes. 95 96 Appendix C : Tangency of Voronoi parabola in a tapered tool For the cross section of the tapered tool, we discuss the voronoi diagram here. Our discussion is limited to the tapered portion ABCDEA. The cross section of the tapered portion alone resembles a trapezium. The Voronoi diagram among the various entities is as shown in Figure 36. The limits of the Voronoi diagram is given by the polygon ACDE. Region 1 is the locus for all points which are closer to the point B compared to the line CD, and hence is bounded by parabola. Region 2 is the locus of all points which are closer to the line BC compared to the line CD. Region 2 is bounded by the angle bisector line between BC and CD. Region 2 is also bounded by the line BO which demarcates points which are closer to the line BC than the point B. Point 0 will be equidistant from BC, CD and the point B and hence will be at the intersection of the two lines and the parabola. In order for this diagram to represent the voronoi diagram, we observe that the line OC has to be tangent to the parabola OF at 0. Only then will the correct proximity information will be carried in the vicinity of point 0. This can be proved from the converse of the following result in coordinate geometry. D Region 2 Region 1 Region 3 C BA A F E Figure 36 Voronoi diagram for the tapered portion of a cutting tool Let a tangent be drawn to a parabolaat a point X. Extend this tangent till it meets the directrix at point Y If F is the focal point of the parabola, the line segment XY subtends and angle 90 degrees at F By definition for region 1, CD is the directrix for the parabola OF and B is the focal point. OB and BC are perpendicular and hence it is proven that OC is tangent to the parabola OF at the point 0. 97 98