Gilbert–Johnson–Keerthi distance algorithm: Difference between revisions

Content deleted Content added
Replaced content with 'Bonjour je m'appelle Jean-pierre-paul-jack-alex-françois et mon prénom est trop bien ma gueule !'
Tag: possible vandalism
Line 1:
Bonjour je m'appelle Jean-pierre-paul-jack-alex-françois et mon prénom est trop bien ma gueule !
The '''Gilbert–Johnson–Keerthi distance [[algorithm]]''' is a method of determining the minimum distance between two [[convex set]]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 (mathematics)|support function]] to iteratively generate closer [[simplex|simplices]] to the correct answer using the [[Minkowski sum]] (CSO) of two convex shapes.
 
"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 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]], especially in [[physics engine]]s for [[video games]].
 
== Overview ==
 
GJK relies on two functions:
 
* <math>Support(shape, \vec{d})</math>, which returns the point on <math>shape</math> which has the highest dot product with <math>\vec{d}</math>.
* <math>NearestSimplex(s)</math>, which takes a simplex <math>s</math> and returns the simplex on <math>s</math> closest to the origin, and a direction toward the origin normal to the new simplex. If <math>s</math> itself contains the origin, <math>NearestSimplex</math> accepts <math>s</math> and the two shapes are determined to intersect.
 
The simplices handled by <math>NearestSimplex</math> may each be any simplex sub-space of {{math|'''R'''<sup>''n''</sup>}}. For example in 3D, they may be a point, a line segment, a triangle, or a tetrahedron; each defined by 1, 2, 3, or 4 points respectively.
 
=== Pseudocode ===
 
<code>
function GJK_intersection(shape p, shape q, vector initial_axis):
vector A = Support(p, initial_axis) - Support(q, -initial_axis)
simplex s = {A}
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
</code>
 
== Illustration==
 
[[File:Two types of collisions and corresponding CSO faces.svg|550px|thumb|center|The two types of collision and corresponding CSO face: face-vertex (top) and edge-edge (bottom).]]
 
==External links==
*[http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?&arnumber=2083 "A fast procedure for computing the distance between complex objects in three-dimensional space", Gilbert, Johnson and Keerthi] - the initial publication
*[http://web.comlab.ox.ac.uk/oucl/work/stephen.cameron/distances "Computing the Distance between Objects", Oxford professor Stephen Cameron's implementation of GJK]
*[http://code.google.com/p/gjkd/ A 2D implementation of the Gilbert–Johnson–Keerthi (GJK) algorithm, written in the D programming language]
*[https://mollyrocket.com/849 A 52 minute video lecture on implementing Gilber-Johnson-Keerthi]
 
{{DEFAULTSORT:Gilbert-Johnson-Keerthi distance algorithm}}
[[Category:Geometric algorithms]]
[[Category:Convex geometry]]
 
 
{{Mathapplied-stub}}