Elsevier

Computer-Aided Design

Volume 90, September 2017, Pages 71-83
Computer-Aided Design

Detecting the intersection of two convex shapes by searching on the 2-sphere

https://doi.org/10.1016/j.cad.2017.05.009Get rights and content

Highlights

  • An algorithm similar in spirit to GJK for detecting when 2 shapes touch each other.

  • Numerically more robust and a little faster.

Abstract

We take a look at the problem of deciding whether two convex shapes intersect or not. We do so through the well known lens of Minkowski sums and with a bias towards applications in computer graphics and robotics. We describe a new technique that works explicitly on the unit sphere, interpreted as the sphere of directions. In extensive benchmarks against various well-known techniques, ours is found to be slightly more efficient, much more robust and comparatively easy to implement. In particular, our technique is compared favorably to the ubiquitous algorithm of Gilbert, Johnson and Keerthi (GJK), and its decision variant by Gilbert and Foo. We provide an in-depth geometrical understanding of the differences between GJK and our technique and conclude that our technique is probably a good drop-in replacement when one is not interested in the actual distance between two non-intersecting shapes.

Introduction

This paper is concerned with the problem of detecting the intersection of two convex objects. Given two convex objectsA and B in R3, we ask whetherA andB have a point in common or not. When that is the case we say that “they intersect” or “they touch each other”. The intersection detection problem is a component of collision detection for more general shapes, which plays a major role in robotics [1], computer animation [2] and mechanical simulation for example.

Intersection detection also plays a role in computer graphics in general as an ingredient in acceleration data structures, such as bounding volume hierarchies or Kd-trees. In the latter case, an object of interest (e.g. a ray, a view frustum, or another hierarchy) is tested for intersection against the geometric shapes that bound each node in the hierarchy. These bounding shapes are simple shapes (boxes, spheres) for which fast intersection detection techniques exist. For an in-depth exposition to intersection and collision detection, we refer the reader to the book of Ericson [3] and the survey of Jiménez et al. [4].

In robotics or computer graphics, we often limit ourselves to constant-size or small convex objects, and techniques that do not use pre-processing, but the intersection detection problem has several variants and has been studied by theoreticians as well. Computational geometers have recently developed an optimal solution for general convex polyhedra: Given any collection of convex polyhedra inR3, one can pre-process them in linear time, independently of each other, so that the intersection of any two polyhedraP andQ from the collection can be tested in optimal timeO(log|P|+log|Q|) (see [5] and the other references within). This essentially closes the (theoretical) problem for the case of convex polyhedra. It is not clear if their technique is amenable to an efficient implementation since the data-structures used are not simple and it requires knowledge of the connectivity between the polyhedron neighboring facets.

In this paper however, we only consider techniques that do not use excessive or complex pre-processing  1and are asymptotically slower, but very fast in practice.

Of particular interest is the beautiful algorithm developed by Gilbert, Johnson and Keerthi (GJK) for computing the distanced(A,B) between two convex polyhedraA and B [6]. It only needs access to the vertices of the polyhedra and typically uses just a few iterations over them to compute the distanced(A,B). It was later generalized and adapted to the decision version of the problem by Gilbert and Foo [1] to handle a broader class of convex objects. We describe these algorithms in Section 3.

In this paper we view the decision problem as that of finding an oriented plane that setsA on its negative andB on its positive side. WritingS for the set of normals to the planes achieving separation, we design, in Section 4, an algorithm to find a direction inS or decide thatS is empty (whenA andB do touch each other). Our algorithm iteratively prunes parts of the unit sphereS so that the remaining part, a convex spherical polygon, provides an increasingly tight superset ofS. We call it Decision Sphere Search, or DSS for short.

Section 5 gives a theoretical analysis of DSS and an extensive comparison of DSS with GJK. In particular, we show that DSS optimally aggregates the information gathered about the Minkowski differenceAB during the successive iterations.

In Section 6, we benchmark our implementations of a “naive”, quadratic algorithm, of DSS and of GJK. Each benchmark considers a specific type of objects and measures the performance of the algorithm with respect to the “collision density”, i.e. the ratio of the number of tested pairs of convex objects that actually intersect to the total number of tested pairs. Our DSS technique appears to be faster than GJK in general, numerically more robust and easier to implement. We have taken care to analyze a large variety of situations including very uneven ones, such as frustum-culling where one object (the frustum) is much larger than the other. In that case, we show that a hybrid technique combining DSS and GJK gives the overall best results and we explain why.

Section snippets

Preliminaries

It is simpler to work with an alternative view of the geometry of the intersection detection problem, thereby reducing it to deciding whether a closed convex set contains the origin or not. The rest of the present section describes this well known alternative view.

The Minkowski sum and Minkowski difference of two subsetsA andB ofR3 are (see Fig. 1): AB={a+baA,bB} andAB={abaA,bB}.Using this definition,A andB have non-empty intersection if and only ifAB contains the origino: ABoAB.

Related work

Research on practical intersection detection techniques for static convex shapes has not been very active in recent years, so we can refer the reader to the survey of Jiménez et al. [4] and the excellent book of Ericson [3]. We also refer the reader to our technical report [9], where we propose a review of previous work on intersection detection problem for small convex polyhedra with or without specific symmetries, through the unifying lens of Minkowski sums and the Gauss map, which both play

Our decision sphere search algorithm

Our algorithm is similar in spirit to the GJK/GF algorithm: We sequentially generate candidate directions along which the convexP and the origino are tested for separation using equations (11) and (8) until a final decision can be taken. Our algorithm differs from theirs in the way a new test direction is generated (they search a point closest to the origin on a simplex insideP, whereas we pick a point in a convex spherical polygon) and in that we do not seek the actual distance between the two

A characterization of the separating planes

This section derives a characterization of the planes separating two convex objects that we use in Section 5.2 to understand the differences between our algorithm and GJK. This characterization, embodied in definition (12) and Lemma 2 .

First, recall that testing thatA andB touch each other is equivalent to testing that the origino lies in the Minkowski differenceAB. In this section, in order to simplify the exposition, we therefore consider the geometrically (but not computationally)

Benchmarks

We have compared our implementations of DSS, GJK and other algorithms, over a few kinds of randomly generated data sets: random pairs of tetrahedra, oriented boxes and polytopes, and frustum culling of random spheres and axis-aligned boxes.

In the figures below, Generic is an implementation of a “naive” technique  4that we described

Concluding remarks

We have developed a new algorithm, DSS, to decide the disjointness of two convex shapes, by searching on the 2-sphere. Just as for GJK, DSS simply assumes that the extremal functionΣ (page 72) is computable on the shapes at hand. Compared to GJK, DSS is (i) easier to implement, (ii) numerically more robust, (iii) typically a little bit faster and never much slower.

We have however considered only the disjointness decision problem. But GJK can compute the actual distance between the two shapes.

Acknowledgment

This work was partially supported by ERC grant ShapeForge (StG-2012-307877).

References (23)

  • SabinM.

    Surfaces closed under five important geometric operations

  • This paper has been recommended for acceptance by Dr. Mario Botsch, Dr. Yongjie Jessica Zhang and Dr. Stefanie Hahmann.

    View full text