The Gilbert-Johnson-Keerthi (GJK) algorithm is an iterative method that computes the Euclidean distance between two convex shapes by operating on their Minkowski difference. It relies on the geometric property that two convex sets intersect if and only if their Minkowski difference contains the origin. GJK efficiently searches for the point in this difference set closest to the origin using support mapping functions, which return the most extreme point of a shape in a given direction, avoiding the need to explicitly construct the complex Minkowski difference volume.
Glossary
Gilbert-Johnson-Keerthi (GJK) Algorithm

What is Gilbert-Johnson-Keerthi (GJK) Algorithm?
The Gilbert-Johnson-Keerthi algorithm is a foundational computational geometry method for efficiently determining the minimum distance and intersection status between two convex sets.
In industrial robotics path planning, GJK serves as the primary narrow-phase collision detection routine, executed millions of times per second to verify that robotic manipulators and automated guided vehicles (AGVs) do not penetrate obstacles. Its computational efficiency makes it ideal for real-time trajectory optimization and model predictive control (MPC) loops. The algorithm is often paired with broad-phase culling methods like bounding volume hierarchies and is a core component of physics engines and motion planning libraries such as Bullet and Open Motion Planning Library (OMPL).
Key Characteristics of the GJK Algorithm
The Gilbert-Johnson-Keerthi algorithm is the workhorse of modern physics engines and robotic path planning. It efficiently determines the minimum distance and separation vector between any two convex shapes by iteratively refining a simplex in Minkowski configuration space.
Minkowski Difference Core
The algorithm's mathematical foundation is the Minkowski difference (B - A). GJK does not operate on the original shapes directly. Instead, it searches for the point in this difference set closest to the origin. If the origin lies inside the Minkowski difference, the original shapes intersect. This elegant transformation reduces the complex problem of checking two arbitrary convex sets to the simpler problem of checking if a single convex set contains the origin.
Iterative Simplex Refinement
GJK is an iterative algorithm that builds and refines a simplex—a generalized triangle (point, line, triangle, or tetrahedron) in 2D or 3D—inside the Minkowski difference. Each iteration uses a support function to map a search direction to the furthest point in the Minkowski difference. The algorithm then uses this new vertex to evolve the simplex closer to the origin, terminating when the simplex either contains the origin (collision) or proves the origin is unreachable (separation).
Support Function Mapping
The support function S(d) is the only geometry-specific operation GJK requires, making it extremely general. For a convex shape, S(d) returns the vertex furthest in a given direction d. For compound shapes, the support function of the Minkowski difference is simply S_A(d) - S_B(-d). This abstraction allows GJK to handle any convex primitive—spheres, boxes, capsules, convex hulls—without modification, as long as a support function is defined.
Distance Sub-Algorithm (Johnson)
When shapes are separated, GJK transitions to the Johnson distance sub-algorithm to compute the exact minimum distance. Once the main loop determines the origin is outside the Minkowski difference, it identifies the closest feature (vertex, edge, or face) of the current simplex to the origin. This yields not only the separation distance but also the witness points on each original shape, which are critical for computing collision normals and penetration depth in physics simulations.
Expanding Polytope Algorithm (EPA) Companion
GJK alone only provides a boolean intersection test and separation distance. To compute penetration depth—how far two objects are interpenetrating—the Expanding Polytope Algorithm (EPA) is invoked after GJK detects a collision. EPA starts with the simplex that contains the origin and iteratively expands it by adding support points until it approximates the Minkowski difference surface, returning the minimum translation vector required to separate the objects.
Numerical Robustness Challenges
In floating-point implementations, GJK is notoriously sensitive to numerical precision. Degenerate cases like nearly co-planar faces or very thin simplexes can cause the algorithm to cycle or return incorrect results. Production-grade implementations employ safeguards:
- Tolerance thresholds for zero-distance checks
- Backup exact arithmetic for critical steps
- Simplex degeneration detection to reset the search
- Maximum iteration limits to prevent infinite loops
Frequently Asked Questions
Clear, technically precise answers to the most common questions about the Gilbert-Johnson-Keerthi algorithm, the foundational narrow-phase collision detection routine in modern robotics and physics simulation.
The Gilbert-Johnson-Keerthi (GJK) algorithm is an iterative method that efficiently computes the minimum Euclidean distance between two convex sets. It works by operating on the Minkowski difference of the two shapes—a single convex set that contains the origin if and only if the original shapes intersect. GJK iteratively builds a simplex (a point, line segment, triangle, or tetrahedron) inside the Minkowski difference, using support mapping functions to sample the boundary in promising directions. At each iteration, the algorithm checks whether the current simplex contains the origin; if it does, the shapes intersect. If not, GJK refines the simplex to get closer to the origin, converging to the exact minimum distance within a small number of iterations. This geometric approach avoids the computational expense of explicitly computing the Minkowski difference or performing exhaustive vertex-vertex checks, making it the dominant narrow-phase collision detection routine in robotics, video games, and physics engines like Bullet and Box2D.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
The GJK algorithm is a foundational narrow-phase routine. These related concepts complete the collision detection pipeline and represent alternative or complementary geometric representations.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us