Narrowphase is the detailed collision detection stage that follows the broadphase. It takes the list of potentially intersecting object pairs and performs exact geometric tests to determine if a collision has actually occurred. For convex shapes, algorithms like the Gilbert–Johnson–Keerthi (GJK) algorithm and the Expanding Polytope Algorithm (EPA) are used to compute the penetration depth and contact manifold. This stage outputs precise contact points, surface normals, and penetration data, which are critical inputs for the subsequent constraint solver that resolves the collision forces.
Glossary
Narrowphase

What is Narrowphase?
Narrowphase is the second, precise stage in the collision detection pipeline where potentially colliding pairs identified by the broadphase are tested in detail to compute exact contact points, normals, and penetration depth.
The computational cost of narrowphase is high, as it involves solving complex geometric queries. Its efficiency is paramount for real-time simulations in robotics and gaming. The output—a set of contact constraints—defines how bodies interact, directly influencing the physical realism of rigid body dynamics. In the context of sim-to-real transfer learning, accurate narrowphase collision resolution in a physics engine is essential for training robust robotic policies that can handle precise manipulation and complex environmental interactions before physical deployment.
Core Functions of the Narrowphase
The narrowphase is the precision stage of collision detection. It takes the potentially colliding pairs identified by the broadphase and performs detailed geometric tests to compute exact contact information required for the constraint solver.
Exact Contact Point Calculation
The primary function of the narrowphase is to compute the exact points of intersection between two colliding shapes. This is far more precise than the bounding volume approximations used in the broadphase. For convex shapes, algorithms like GJK (Gilbert–Johnson–Keerthi) and EPA (Expanding Polytope Algorithm) are used to find the closest points or penetration depth. The output is a set of one or more contact points in world space, which are passed to the constraint solver to generate appropriate collision responses.
Contact Normal and Penetration Depth
Beyond just finding contact points, the narrowphase must calculate the contact normal (a unit vector pointing from one body to the other, defining the direction of separation) and the penetration depth (the scalar distance the shapes overlap). This data is critical for the physics engine's constraint solver (e.g., solving a Linear Complementarity Problem) to apply correct impulses that resolve the collision, prevent interpenetration, and simulate realistic bouncing or sliding with friction.
Shape-Specific Geometric Tests
The narrowphase implements specialized, efficient algorithms for different primitive shape pairs. Common tests include:
- Sphere vs. Sphere: Simple distance check between centers.
- Box vs. Box: Separating Axis Theorem (SAT) is commonly used.
- Capsule vs. Mesh: Often involves line segment to triangle tests.
- Convex vs. Convex: GJK/EPA is the standard.
- Concave vs. Anything: Typically requires decomposition into convex parts or use of Signed Distance Fields (SDFs). The choice of algorithm directly impacts simulation accuracy and performance.
Continuous Collision Detection (CCD)
For fast-moving objects, discrete collision detection (testing at single time steps) can fail, causing tunneling (where an object passes through another). A key advanced function of the narrowphase is Continuous Collision Detection (CCD), which tests the swept volume of an object's path between time steps. This involves more complex continuous geometric queries (e.g., conservative advancement) to compute the time of impact (TOI) and generate speculative contacts, ensuring robust simulation of bullets, thin walls, or rapidly moving robotic parts.
Contact Persistence and Caching
To improve stability and performance, the narrowphase often implements contact caching or warm starting. If a contact pair was colliding in the previous simulation step, its contact manifold (set of points) is stored and reused as a starting point for the next step. This persistence reduces jitter, allows the constraint solver to converge faster, and is essential for stable stacking and resting contacts. Managing this cache—adding new contacts, merging, and pruning old ones—is a core narrowphase responsibility.
Integration with the Physics Pipeline
The narrowphase does not operate in isolation. It is a critical link between the broadphase and the constraint solver. Its performance dictates the solver's workload. Efficient narrowphase implementations are often parallelized, processing multiple collision pairs simultaneously. The computed contact data (point, normal, depth) is formatted into a contact manifold and passed to the solver (like a Projected Gauss-Seidel solver) which calculates the final forces and torques to apply, completing the collision resolution loop.
How Narrowphase Detection Works
Narrowphase is the second, precise stage in the collision detection pipeline where potentially colliding pairs identified by the broadphase are tested in detail to compute exact contact points, normals, and penetration depth.
Narrowphase detection is the computational stage where pairs of objects flagged by the broadphase undergo exact geometric intersection tests. For convex shapes, algorithms like the Gilbert–Johnson–Keerthi (GJK) algorithm and the Expanding Polytope Algorithm (EPA) are used to determine collision status and compute penetration depth and contact normal. This stage outputs a precise contact manifold—a set of contact points and associated data—which is passed to the constraint solver to resolve physical interactions.
The narrowphase operates on fundamental shape primitives like spheres, boxes, capsules, and convex hulls. For complex concave shapes, they are often decomposed into convex parts. The generated contact constraints—including position, normal, and friction parameters—are critical for the solver to apply correct impulses, preventing interpenetration and simulating realistic rigid body dynamics. Efficient narrowphase algorithms are essential for the stability and physical accuracy of the overall physics simulation.
Common Narrowphase Algorithms
Comparison of core algorithms used in the narrowphase stage to compute exact contact information between convex shapes.
| Algorithm | Shape Support | Primary Output | Computational Complexity | Typical Use Case |
|---|---|---|---|---|
Gilbert–Johnson–Keerthi (GJK) | Convex Polyhedra | Distance / Collision Boolean | O(n) | General convex collision, distance queries |
Expanding Polytope Algorithm (EPA) | Convex Polyhedra | Penetration Depth & Contact Normal | O(n²) worst-case | Computing contact info for penetrating shapes |
Separating Axis Theorem (SAT) | Convex Polyhedra (Boxes, Polygons) | Collision Boolean & Minimum Translation Vector | O(n) for boxes | Axis-aligned and oriented bounding boxes (AABBs/OBBs) |
Minkowski Portal Refinement (MPR) | Convex Polyhedra | Penetration Depth & Contact Normal | O(n) | Alternative to GJK/EPA, often used in game physics |
Sphere-Capsule, Capsule-Capsule | Sphere, Capsule | Exact Contact Points | O(1) | Character controllers, simple swept volumes |
V-Clip (Voronoï Clip) | Convex Polyhedra | Distance & Closest Points | O(n) | Maintaining closest features between moving objects |
Quickhull-based Intersection | Convex Hulls | Intersection Polyhedron | O(n log n) | Exact intersection volume for complex queries |
Why Narrowphase Accuracy Matters for Sim-to-Real
The narrowphase stage is the critical bottleneck for simulation fidelity. Inaccurate contact modeling here creates a 'reality gap' that policies trained in simulation cannot cross, leading to catastrophic failure on real hardware.
Contact Point & Normal Precision
The narrowphase calculates the exact point of contact and the surface normal at that point. In robotics, this determines the direction of contact forces. An error of a few millimeters or degrees in simulation leads to incorrect force application in the real world, causing a robot to slip, drop an object, or apply unsafe pressure. For example, a gripper's success in picking up a delicate object is entirely dependent on the precise normal vector computed during contact.
Penetration Depth Calculation
This is the measure of how much two shapes overlap. Accurate penetration depth is non-negotiable for the constraint solver, which uses it to calculate the impulse needed to push the objects apart in a single time step.
- Too shallow: Objects appear to float or make unstable contact.
- Too deep: The solver applies massive, unrealistic corrective forces, causing 'jitter' or explosive behavior. This inaccuracy directly corrupts the force/torque data a reinforcement learning policy uses to learn stable manipulation.
Algorithm Choice Defines Fidelity
Different narrowphase algorithms trade speed for accuracy, directly impacting sim-to-real transfer.
- GJK/EPA (Gilbert–Johnson–Keerthi/Expanding Polytope Algorithm): The gold standard for convex shapes. Provides exact contact features but is computationally intensive.
- SAT (Separating Axis Theorem): Efficient for axis-aligned geometries but limited in general cases.
- Mesh-vs-Mesh: Extremely expensive. Often approximated with primitive decomposition (breaking meshes into spheres, capsules, convex hulls) for real-time performance, introducing fidelity loss. The choice here dictates what contact phenomena can be learned in simulation.
The Reality Gap in Friction & Restitution
Narrowphase outputs (contact point, normal, depth) are the primary inputs for friction and restitution (bounciness) models. An error in the contact normal will miscalculate the tangential (friction) force direction. Inaccurate penetration depth affects the normal force magnitude, which in turn scales the friction force (via the Coulomb model). A policy that learns to slide a box in simulation will fail if the simulated friction is 20% off from real-world values due to underlying narrowphase inaccuracies.
Impact on Policy Observation Space
In reinforcement learning for robotics, the observation space often includes proprioceptive data (joint torques) and sometimes estimated external contact forces. These signals are derived from the physics engine's resolution of contacts. Noisy or biased narrowphase computations inject erroneous observations into the policy during training. The policy then learns to rely on these simulation artifacts, which vanish on real hardware, causing immediate distributional shift and failure.
Benchmark: The Cantilever Snap Test
A canonical test for narrowphase and solver fidelity is simulating a compliant cantilever beam (e.g., a ruler) pressed against a peg until it snaps past. This test stresses:
- Continuous Collision Detection (CCD): To prevent the beam tip from tunneling through the peg.
- Accurate contact generation during sliding.
- Stable constraint resolution under high stress. A physics engine that fails this simple benchmark cannot be trusted to train policies for real-world contact-rich tasks like assembly or cable manipulation.
Frequently Asked Questions
Essential questions about the Narrowphase, the precise computational stage in physics engines responsible for detailed collision analysis.
Narrowphase is the second, precise stage in the collision detection pipeline where potentially colliding pairs, identified by the broadphase, are tested in detail to compute exact contact points, surface normals, and penetration depth. It operates on the reduced set of object pairs that passed the initial broadphase culling, applying exact geometric tests to shapes like convex hulls, spheres, and capsules. The output is a manifold—a data structure containing the precise geometric information of the contact—which is then passed to the constraint solver to calculate appropriate collision responses and forces, ensuring objects do not interpenetrate while obeying physical laws like friction and restitution.
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
Narrowphase is a critical component within the broader physics simulation pipeline. These related terms define the computational stages and algorithms that work in concert to model realistic physical interactions.
Broadphase
The broadphase is the first, coarse stage in the collision detection pipeline. Its primary function is culling: it uses spatial data structures like a Bounding Volume Hierarchy (BVH) or spatial hash to quickly identify pairs of objects that are potentially colliding, while efficiently discarding pairs that are obviously far apart. This drastically reduces the number of expensive pairwise checks passed to the narrowphase.
- Purpose: Performance optimization via early rejection.
- Output: A list of candidate colliding pairs.
- Common Algorithms: Sweep and prune, grid-based methods, dynamic BVH.
Collision Detection
Collision detection is the overarching computational process of determining when two or more simulated objects intersect or come into contact. It is typically implemented as a two-stage pipeline:
- Broadphase: Fast, approximate culling of non-interacting objects.
- Narrowphase: Precise geometric tests on remaining pairs.
This process is fundamental to simulating physical interactions like contact, stacking, and grasping in robotics. The narrowphase provides the exact geometric data required for the subsequent constraint solver to compute realistic collision responses.
Contact Generation
Contact generation is the core computational task performed within the narrowphase stage. Once a collision is detected, this sub-process calculates the precise geometric details of the intersection, which are essential for a physically accurate response.
- Contact Point: The exact location(s) where shapes intersect.
- Contact Normal: A unit vector perpendicular to the collision surface, defining the direction of separation.
- Penetration Depth: The distance the objects have overlapped.
These contact manifolds are the primary output of the narrowphase and serve as direct input to the physics engine's solver to resolve interpenetration and apply friction.
Constraint Solver
A constraint solver is the algorithmic component that resolves the forces and impulses necessary to satisfy all physical constraints in a simulation time step. It consumes the contact data (points, normals, depth) generated by the narrowphase.
- Primary Function: To compute collision responses that prevent interpenetration and model friction.
- Mathematical Framework: Often formulated as a Linear Complementarity Problem (LCP) or solved via iterative methods like Projected Gauss-Seidel (PGS).
- Constraints Handled: Contact non-penetration, joint limits, ragdoll joints, and rope constraints.
Gilbert–Johnson–Keerthi (GJK) Algorithm
The GJK algorithm is a highly efficient iterative method central to modern narrowphase collision detection for convex shapes. Instead of testing all geometric features, it uses support functions to find the closest points between two shapes' Minkowski difference.
- Output: Minimum distance between shapes and a collision boolean.
- Efficiency: Its iterative nature provides sub-linear time complexity in typical cases.
- Companion Algorithm: Often paired with the Expanding Polytope Algorithm (EPA) to generate contact manifolds (normals and penetration depth) when a collision is detected.
Continuous Collision Detection (CCD)
Continuous Collision Detection (CCD) is an advanced narrowphase technique that prevents tunneling—where fast-moving or small objects pass through thin geometry between discrete simulation time steps. Instead of testing static shapes, CCD tests the continuous swept volume along an object's trajectory.
- Use Case: Critical for simulating bullets, fast-moving robots, or cloth with small gaps.
- Method: Computes the time of impact (TOI) along the motion path.
- Trade-off: Significantly more computationally expensive than discrete collision detection, so it is often applied selectively to high-velocity objects.

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