Contact generation is the narrowphase process that computes the exact contact manifold—including intersection points, surface normals, and penetration depths—between two colliding shapes. It follows the broadphase culling stage and precedes the constraint solver, which uses this geometric data to calculate collision response forces. This stage is critical for simulating realistic physical interactions, such as stacking, friction, and restitution, within a physics engine.
Glossary
Contact Generation

What is Contact Generation?
Contact generation is the precise computational core of collision detection in physics engines, responsible for calculating the exact geometric interactions between colliding objects.
Algorithms like the Gilbert–Johnson–Keerthi (GJK) algorithm for distance computation and the Expanding Polytope Algorithm (EPA) for penetration depth are foundational to modern contact generation. The output is formatted as a Linear Complementarity Problem (LCP) or fed directly to solvers like Projected Gauss-Seidel (PGS) to enforce non-penetration constraints. Accurate contact generation is essential for sim-to-real transfer, as errors here directly degrade the fidelity of robotic manipulation and locomotion policies trained in simulation.
Key Outputs of Contact Generation
Contact generation is the narrowphase process that computes the precise geometric data required to resolve collisions between simulated objects. Its outputs are the fundamental inputs for the constraint solver.
Contact Point
The contact point is the exact 3D coordinate in world space where two shapes intersect or are closest. For penetrating shapes, this is typically computed as a point on the contact manifold—the overlapping surface region. Multiple contact points may be generated for a single collision pair to ensure stable stacking and resting contact resolution. For example, a box resting on a plane typically generates four contact points, one at each corner.
Contact Normal
The contact normal is a unit vector perpendicular to the contact surface, defining the direction in which the colliding bodies should be separated. It points from the reference shape (Shape B) toward the incident shape (Shape A). This vector is critical for calculating impulse and penetration resolution. For convex shapes, algorithms like GJK/EPA (Expanding Polytope Algorithm) compute this normal from the Minkowski difference.
Penetration Depth
Penetration depth is a scalar distance measuring how much two shapes overlap. A positive value indicates inter-penetration, while zero or negative indicates separation or touching contact. This value, combined with the contact normal, defines the separation vector needed to resolve the collision. Deep penetrations can cause instability in solvers, which is why simulation steps use continuous collision detection (CCD) for fast-moving objects.
Contact Manifold
A contact manifold is the set of all contact points between two shapes for a given collision. It represents the region of contact, not just a single point. For polyhedral shapes, this is often a polygon (e.g., a line segment for edge-edge contact, or a face polygon). Maintaining a persistent manifold across simulation steps reduces jitter and improves solver efficiency for resting contacts. The manifold is typically capped at 4 points for performance.
Reference & Incident Features
These are identifiers for the specific geometric primitives (e.g., face, edge, vertex) involved in the collision. The reference feature is from one shape (often the one with the supporting plane), and the incident feature is from the other. Caching these features aids in warm-starting the constraint solver in subsequent time steps, accelerating convergence. This is a key optimization in engines like Bullet and PhysX.
Restitution & Friction Coefficients
While material properties are inputs, contact generation associates the computed contact point with combined restitution (bounciness) and friction coefficients. These are derived from the surface materials of the two colliding bodies. The combined restitution is typically the minimum of the two values, while combined friction uses models like the Coulomb friction model or a geometric mean. These coefficients directly parameterize the contact constraint solved in the next pipeline stage.
How Contact Generation Works in the Physics Pipeline
Contact generation is the precise computational stage within a physics engine that determines how simulated objects physically interact upon collision.
Contact generation is the core process of the narrowphase collision detection stage. It takes potentially colliding object pairs identified by the broadphase and computes the exact geometric data of their intersection. This output, known as a contact manifold, includes the points of contact, surface normals, and penetration depths required for the subsequent constraint solver to calculate realistic collision responses and forces.
The process employs specialized algorithms like the Gilbert–Johnson–Keerthi (GJK) algorithm for distance and collision tests between convex shapes, often paired with the Expanding Polytope Algorithm (EPA) to extract penetration details. For complex or concave shapes, decomposition into convex parts or use of Signed Distance Fields (SDFs) is common. The accuracy and efficiency of this stage are critical for simulation stability, preventing objects from interpenetrating and ensuring physically plausible rigid body dynamics.
Common Contact Generation Algorithms
A comparison of core algorithms used to compute exact contact points, normals, and penetration depths between intersecting convex shapes in the narrowphase stage of a physics pipeline.
| Algorithm / Feature | Gilbert–Johnson–Keerthi (GJK) | Expanding Polytope Algorithm (EPA) | Separating Axis Theorem (SAT) | Voronoi Clip (V-Clip) |
|---|---|---|---|---|
Primary Purpose | Distance calculation & collision detection for convex shapes | Penetration depth and contact manifold generation from GJK overlap | Collision detection for convex polytopes (e.g., boxes, polygons) | Fast collision detection and contact generation for convex polyhedra |
Shape Support | Convex shapes via support function | Convex shapes (requires simplex from GJK) | Convex polytopes (discrete vertices/faces) | Convex polyhedra |
Output Type | Boolean collision, minimum distance, witness points | Penetration vector, contact normal, contact points | Boolean collision, separating axis, overlap depth | Boolean collision, closest features, separation vector |
Computational Complexity | Iterative, typically O(1) per iteration, converges quickly | Iterative, builds polytope from simplex, can be less stable | O(n+m) for axes tests (n & m are face/edge counts) | O(1) average case using adjacency info, robust |
Penetration Depth | ||||
Contact Manifold Generation | ||||
Robustness to Deep Penetration | Can fail with numerical instability | |||
Common Use Case | General convex collision/query, often paired with EPA | Extracting contact info after GJK detects overlap | Axis-aligned bounding boxes (AABB), oriented bounding boxes (OBB) | Robotics simulation, convex polyhedra with precise feature tracking |
Applications in Robotics and Simulation
Contact generation is the critical narrowphase process that computes the exact geometric details of a collision, such as contact points, surface normals, and penetration depth. Its accuracy directly determines the physical realism of interactions in robotic training and simulation.
Robotic Grasping and Manipulation
Accurate contact generation is foundational for simulating robotic manipulation. It enables the physics engine to compute the wrench (force and torque) a gripper exerts on an object, which is essential for training grasp stability policies. Without precise contact points and normals, a simulated robot cannot learn to apply correct forces to lift, push, or assemble objects, creating a reality gap that hinders sim-to-real transfer.
Legged Locomotion and Terrain Interaction
For legged robots like quadrupeds or humanoids, contact generation determines foot-ground interaction. The engine must compute:
- Contact points on the sole of the foot.
- Surface normal to determine the direction of the ground reaction force.
- Friction cone for calculating slip conditions. Incorrect contact modeling leads to policies that fail on real terrain due to unrealistic friction or foot placement, making it a core challenge in reinforcement learning for locomotion.
Articulated Mechanism and Joint Limits
In multi-body systems like robotic arms, contact generation is not just for external collisions. It is used to enforce joint limits by treating the limit stops as contact constraints. When a revolute joint reaches its maximum angle, the solver generates a contact impulse to prevent further rotation, simulating the physical hard stop. This prevents self-intersection and teaches policies to operate within the robot's mechanical design envelope.
Cluttered Environment Navigation
Autonomous mobile robots (AMRs) operating in warehouses or homes must navigate dense, cluttered spaces. Contact generation allows the simulation of bump-and-nudge interactions with obstacles. By modeling these low-velocity contacts accurately, navigation policies can be trained for contact-rich navigation, where the robot uses gentle pushes to rearrange objects or squeeze through tight spaces—a behavior impossible to learn with simple binary collision detection.
Haptic Feedback and Teleoperation
In digital twin simulations used for operator training or remote teleoperation, contact generation data feeds haptic feedback devices. The computed contact forces are translated into vibrations and resistance on the operator's controls. High-fidelity contact modeling is therefore critical for creating an immersive and physically accurate training environment, allowing operators to 'feel' virtual objects and develop appropriate muscle memory for real-world tasks.
Failure Mode and Safety Testing
Simulation is a safe sandbox for testing catastrophic failures. Contact generation enables the simulation of collision scenarios—like a robot arm crashing into its own body or a drone hitting a wall. By accurately modeling the high-energy impacts and resulting fragment collisions, engineers can stress-test hardware designs and safety controllers (e.g., emergency stop routines) virtually, identifying failure modes before building physical prototypes.
Frequently Asked Questions
Contact generation is the precise computational core of collision detection. These questions address its mechanisms, role in the physics pipeline, and its critical importance for training robust robotic policies in simulation.
Contact generation is the computational process within the narrowphase collision detection stage that calculates the exact geometric details of an intersection between two simulated shapes. When the broadphase identifies a potentially colliding pair, the contact generator's job is to determine if they are truly intersecting and, if so, produce a contact manifold—a set of data points describing the collision. This manifold includes the contact points (the precise locations where the shapes touch or penetrate), the contact normal (a unit vector pointing from one body to the other, defining the direction of separation), and the penetration depth (the distance the shapes overlap). This data is the essential input for the subsequent constraint solver, which computes the appropriate impulses and forces to resolve the collision, enforcing non-penetration and applying friction.
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
Contact generation is a critical component within the physics simulation pipeline. These related terms define the algorithms, data structures, and mathematical frameworks that enable precise modeling of physical interactions.
Collision Detection
Collision detection is the overarching computational process of identifying when two or more simulated objects intersect or come into contact. It is typically structured as a two-stage pipeline:
- Broadphase: Efficiently culls obviously non-colliding pairs using spatial data structures like a Bounding Volume Hierarchy (BVH).
- Narrowphase: Precisely tests the remaining potential pairs to compute exact geometric intersections, which is where contact generation occurs.
Narrowphase
Narrowphase is the second, precise stage in the collision detection pipeline. It takes the list of potentially colliding object pairs from the broadphase and performs detailed geometric tests. The core output of the narrowphase is the contact manifold, which includes:
- Exact points of intersection.
- Surface normals at each contact.
- Penetration depth. Algorithms like GJK and EPA are fundamental to this stage.
Gilbert–Johnson–Keerthi (GJK) Algorithm
The Gilbert–Johnson–Keerthi (GJK) algorithm is an iterative method for computing the distance between two convex shapes. It is the foundation for modern collision detection and contact generation:
- Operates by iteratively refining a simplex (point, line, triangle, or tetrahedron) within the Minkowski difference of the two shapes.
- Extremely efficient due to its support function-based approach.
- Primarily outputs a boolean collision result and the separation distance. For full contact data, it is often paired with the Expanding Polytope Algorithm (EPA).
Linear Complementarity Problem (LCP)
A Linear Complementarity Problem (LCP) is the mathematical framework used to model and resolve contact forces and friction after contact generation. It ensures physical constraints are satisfied:
- Non-penetration: Contact forces must be non-negative (pushing objects apart).
- Complementarity: Either objects are separated (zero force) or in contact (positive force).
- Friction: Modeled using additional constraints within the LCP. Solvers like Projected Gauss-Seidel (PGS) are used to compute the final forces applied to bodies.
Continuous Collision Detection (CCD)
Continuous Collision Detection (CCD) is a technique that prevents tunneling, where fast-moving objects pass through thin geometry between discrete simulation time steps. It is essential for robust contact generation in high-speed simulations.
- Instead of testing static shapes, CCD tests the swept volume along an object's trajectory.
- Critical for simulating bullets, fast-moving robots, or particles.
- Computationally more expensive than discrete collision detection but necessary for accuracy.
Constraint Solver
A constraint solver is the algorithmic component of a physics engine that resolves the forces and impulses needed to satisfy all physical constraints in a system. After contact generation provides the geometric data, the solver's job is to compute the dynamic response.
- Constraints include contact non-penetration, friction, and joints (hinges, sliders).
- Iterative solvers like Projected Gauss-Seidel (PGS) are common for real-time applications.
- The solver ensures the final simulated motion is physically plausible and stable.

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