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 Rigour#Mathematics, mathematically rigorous instructions, typically used to solve a class of specific Computational problem, problems or to perform a computation. Algo ...
is a method of determining the minimum distance between two
convex set In geometry, a set of points is convex if it contains every line segment between two points in the set. For example, a solid cube (geometry), cube is a convex set, but anything that is hollow or has an indent, for example, a crescent shape, is n ...
s, first published by
Elmer G. Gilbert Elmer Grant Gilbert (March 29, 1930 – June 16, 2019) was an American aerospace engineer and a Professor Emeritus of Aerospace Engineering at the University of Michigan. He received his Ph.D. in Instrumentation Engineering from Michigan in 1957. ...
, Daniel W. Johnson, and S. Sathiya Keerthi in 1988. 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 ...
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 of two set (mathematics), sets of position vectors ''A'' and ''B'' in Euclidean space is formed by vector addition, adding each vector in ''A'' to each vector in ''B'': A + B = \ The Minkowski difference (also ''M ...
. "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 an intersection of two or more objects in virtual space. More precisely, it deals with the questions of ''if'', ''when'' and ''where'' two or more objects intersect. Collision detect ...
, especially in
physics engine A physics engine is computer software that provides an approximate simulation of certain physical systems, typically classical dynamics, including rigid body dynamics (including collision detection), soft body dynamics, and fluid dynamics. I ...
s for
video games A video game or computer game is an electronic game 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 generate visual fe ...
.


Overview

GJK relies on two functions: * \mathrm(\mathrm, \vec), which returns the point on which has the highest
dot product In mathematics, the dot product or scalar productThe term ''scalar product'' means literally "product with a Scalar (mathematics), scalar as a result". It is also used for other symmetric bilinear forms, for example in a pseudo-Euclidean space. N ...
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 (: tetrahedra or tetrahedrons), also known as a triangular pyramid, is a polyhedron composed of four triangular Face (geometry), faces, six straight Edge (geometry), edges, and four vertex (geometry), vertices. The tet ...
; 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 ∪ s, D, contains_origin := NearestSimplex(s) if contains_origin: accept


Illustration


See also

* Minkowski Portal Refinement *
Hyperplane separation theorem In geometry, the hyperplane separation theorem is a theorem about disjoint convex sets in ''n''-dimensional Euclidean space. There are several rather similar versions. In one version of the theorem, if both these sets are closed and at least on ...


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.
"the Gilbert–Johnson–Keerthi algorithm explained as simply as possible"
Geometric algorithms Convex geometry Applied mathematics {{Mathapplied-stub