Gilbert–Johnson–Keerthi Distance Algorithm
   HOME

TheInfoList



OR:

The Gilbert–Johnson–Keerthi distance
algorithm In mathematics and computer science, an algorithm () is a finite sequence of rigorous instructions, typically used to solve a class of specific Computational problem, problems or to perform a computation. Algorithms are used as specificat ...
is a method of determining the minimum distance between two
convex set In geometry, a subset of a Euclidean space, or more generally an affine space over the reals, is convex if, given any two points in the subset, the subset contains the whole line segment that joins them. Equivalently, a convex set or a convex r ...
s. Unlike many other distance algorithms, it does not require that the geometry data be stored in any specific format, but instead relies solely on a
support function In mathematics, the support function ''h'A'' of a non-empty closed convex set ''A'' in \mathbb^n describes the (signed) distances of supporting hyperplanes of ''A'' from the origin. The support function is a convex function on \mathbb^n. Any n ...
to iteratively generate closer
simplices In geometry, a simplex (plural: simplexes or simplices) is a generalization of the notion of a triangle or tetrahedron to arbitrary dimensions. The simplex is so-named because it represents the simplest possible polytope in any given dimension. ...
to the correct answer using the ''configuration space obstacle'' (CSO) of two convex shapes, more commonly known as the
Minkowski difference In geometry, the Minkowski sum (also known as dilation) of two sets of position vectors ''A'' and ''B'' in Euclidean space is formed by adding each vector in ''A'' to each vector in ''B'', i.e., the set : A + B = \. Analogously, the Minkowski ...
. "Enhanced GJK" algorithms use edge information to speed up the algorithm by following edges when looking for the next simplex. This improves performance substantially for polytopes with large numbers of vertices. GJK makes use of Johnson's distance sub algorithm, which computes in the general case the point of a tetrahedron closest to the origin, but is known to suffer from numerical robustness problems. In 2017 Montanari, Petrinic, and Barbieri proposed a new sub algorithm based on signed volumes which avoid the multiplication of potentially small quantities and achieved a speedup of 15% to 30%. GJK algorithms are often used incrementally in simulation systems and video games. In this mode, the final simplex from a previous solution is used as the initial guess in the next iteration, or "frame". If the positions in the new frame are close to those in the old frame, the algorithm will converge in one or two iterations. This yields collision detection systems which operate in near-constant time. The algorithm's stability, speed, and small storage footprint make it popular for Realtime
collision detection Collision detection is the computational problem of detecting the intersection (Euclidean geometry), intersection of two or more objects. Collision detection is a classic issue of computational geometry and has applications in various computing ...
, especially in
physics engine A physics engine is computer software that provides an approximate simulation of certain physical systems, such as rigid body dynamics (including collision detection), soft body dynamics, and fluid dynamics, of use in the domains of computer gr ...
s for
video games Video games, also known as computer games, are electronic games that involves interaction with a user interface or input device such as a joystick, game controller, controller, computer keyboard, keyboard, or motion sensing device to gener ...
.


Overview

GJK relies on two functions: * \mathrm(\mathrm, \vec), which returns the point on which has the highest dot product with \vec. * \mathrm(s), which takes a simplex and returns the simplex on closest to the origin, and a direction toward the origin normal to the new simplex. If itself contains the origin, accepts and the two shapes are determined to intersect. The simplices handled by may each be any simplex sub-space of . For example in 3D, they may be a point, a line segment, a triangle, or a
tetrahedron In geometry, a tetrahedron (plural: tetrahedra or tetrahedrons), also known as a triangular pyramid, is a polyhedron composed of four triangular faces, six straight edges, and four vertex corners. The tetrahedron is the simplest of all the o ...
; each defined by 1, 2, 3, or 4 points respectively.


Pseudocode

function GJK_intersection(shape p, shape q, vector initial_axis): vector A = Support(p, initial_axis) − Support(q, −initial_axis) simplex s = vector D = −A loop: A = Support(p, D) − Support(q, −D) if dot(A, D) < 0: reject s = s ∪ A s, D, contains_origin := NearestSimplex(s) if contains_origin: accept


Illustration


See also

*
Minkowski Portal Refinement The Minkowski Portal Refinement collision detection algorithm is a technique for determining whether two convex shapes overlap. The algorithm was created by Gary Snethen in 2006 and was first published in Game Programming Gems 7. The algorithm ...


External links


"A fast procedure for computing the distance between complex objects in three-dimensional space", Gilbert, Johnson and Keerthi
- the initial publication
"Computing the Distance between Objects", Oxford professor Stephen Cameron's implementation of GJK"A Strange But Elegant Approach to a Surprisingly Hard Problem (GJK Algorithm)"A 52 minute video lecture on implementing Gilbert-Johnson-Keerthi"Improving the GJK algorithm for faster and more reliable distance queries between convex objects"
Montanari, Petrinic and Barbieri.
"Collision Detection Accelerated: An Optimization Perspective"
Montaut, Le Lidec, Petrik, Sivic and Carpentier. This research article notably shows how the original GJK algorithm can be accelerated by exploiting Nesterov-type acceleration strategies, contributing to lowering the overall computational complexity of GJK. Geometric algorithms Convex geometry Applied mathematics {{Mathapplied-stub