skip to content

How does conservative advancement find the time of impact of two rotating convex bodies, and when does it converge slowly?

level: seniorimportance: should knowfreq 35%

answer

  1. never step past contact
  2. gap divided by an approach-speed bound
  3. angular speed times farthest radius
  4. spinning bodies near a surface crawl
  5. cap iterations, stop at a target gap

basics

~20 s

Conservative advancement repeatedly divides the bodies' closest distance by an upper bound on their approach speed and advances time by that safe amount, never passing contact. It crawls when the bound is loose, as with fast spin near a surface.

solid answer

~50 s

Each iteration poses both bodies at the current time `t` in the step, runs a closest-distance query for the gap `d` and the unit direction `n` from A toward B, and bounds how fast that gap can shrink. A common bound is `dot(vA - vB, n) + |wA|*rA + |wB|*rB`, where `v` and `w` are linear and angular velocity and `r` is each body's farthest surface point from its centre of mass. Advancing by `d / bound` cannot overshoot, because no pair of points can close the gap faster than the bound. It stops when `d` drops to a small target separation, reports no hit if `t` passes the step's end, and needs an iteration cap. Head-on translation converges in a few iterations; a long body spinning fast near a surface converges slowly, because the angular term assumes every point heads straight at the other body. Root-finding along a separating axis usually needs fewer iterations there.

code

pseudocode · 18 lines
pseudocode
// Time t runs from 0 to dt within one step. Each body moves with constant linear
// velocity v and angular velocity w; maxRadius is its farthest surface point
// from its centre of mass.
function conservativeAdvancement(A, B, dt, target, tolerance, maxIters):
    t = 0
    for iter in 1..maxIters:
        poseA = poseAt(A, t)
        poseB = poseAt(B, t)
        (gap, n) = closestDistance(A, poseA, B, poseB)   // n: unit vector from A toward B
        if gap <= target + tolerance:
            return HIT(t)
        bound = dot(A.v - B.v, n) + length(A.w) * A.maxRadius + length(B.w) * B.maxRadius
        if bound <= 0:
            return NO_HIT                 // the gap cannot shrink during this step
        t = t + (gap - target) / bound    // safe: cannot pass the target separation
        if t > dt:
            return NO_HIT                 // the safe advance reaches past the step
    return HIT(t)                         // iteration cap: treat as contact at the last safe time

go deeper

for a junior

Recall that conservative advancement steps time forward in safe amounts until two moving shapes are nearly touching, and that it handles rotation.

for a middle

Walk through the loop: closest distance, approach-speed bound, safe advance, and the stopping and no-hit conditions.

for a senior

Justify why the bound never overshoots, predict when the loop crawls, and explain how a target separation, iteration cap and separating-axis root finding fix that.

for a principal

Weigh iterative time-of-impact solving against speculative contacts or substeps for a game's mix of fast spinning and fast translating bodies.

## Why rotation needs an iterative method For two spheres moving in straight lines, the time of impact (TOI) falls out of a quadratic. Real bodies are boxes, capsules and convex hulls that **rotate** during a step. A common motion model holds each body's linear velocity `v` and angular velocity `w` constant across the step, so its pose at time `t` is its centre moved by `v*t` and rotated by `w*t`. Under that model the distance between the bodies is no longer a polynomial in `t`: rotation brings sines and cosines in, and no closed-form root exists for general shapes. **Conservative advancement** (CA) answers the question by stepping time forward in amounts that are provably safe. ## The loop 1. Pose both bodies at the current time `t`, starting at the beginning of the step. 2. Run a **closest-distance query** between the two convex shapes. It returns the gap `d` and a unit direction `n` pointing from A toward B; how that query works belongs with narrow-phase collision, and CA only consumes its result. 3. If `d` is at or below a small **target separation**, report a hit at `t`. 4. Compute an upper bound on how fast the gap can shrink, the **approach-speed bound**. 5. If the bound is zero or negative, the bodies cannot approach during the rest of the step: report no hit. 6. Advance `t` by `(d - target) / bound`. If `t` passes the end of the step, report no hit; otherwise return to step 1. ## Why it never overshoots The direction `n` found at time `t` defines a fixed axis. The **separation along that fixed axis**, the gap between the two bodies' extreme points measured along `n`, is never more than the true distance as long as it stays positive, so it is a safe lower bound for the future distance. How fast can that separation shrink? - The centres of mass close along `n` at exactly `dot(vA - vB, n)`. - Rotation moves any surface point of A at most `|wA| * rA`, where `rA` is the farthest distance from A's centre of mass to its surface; likewise for B. - So the separation along `n` shrinks no faster than `dot(vA - vB, n) + |wA|*rA + |wB|*rB`, for the whole step, because `n` is held fixed. Advancing by the gap divided by this bound therefore cannot bring the bodies into contact: at worst they arrive exactly at the target separation. Each iteration is safe on its own, so the only question is how many are needed. ## Where it converges slowly The bound treats every unit of rotational speed as if it pointed straight at the other body. When that is far from true, each step is much shorter than it needs to be. - **Fast spin on a long body**: a plank spinning fast has a large `|w| * r` term even while its tips move parallel to the other body's surface, so the bound overstates its approach and the advances are short. - **Bodies that stay close all step**: a fast-spinning disc skimming just above the floor keeps `d` small while its angular term stays large, so every advance is tiny too, and the loop can exhaust its cap without reaching the end of the step. - **A target separation that is too small**: the last few iterations shave only fractions off the remaining gap, so a needlessly tight tolerance pays for many extra queries. Head-on translation is the opposite case: the bound equals the true closing speed, and the loop lands on the target in a few iterations. ## Root finding along a separating axis A sharper alternative uses the **actual** separation instead of a worst-case bound: 1. At the current time, take the closest features and the separating axis they define, fixed in one body's frame or in world space. 2. Write the separation along that axis as a function `sep(t)`, evaluated by posing both bodies at `t` and taking their support points along the axis. 3. If `sep` at the end of the step is still above the target, many implementations treat the pair as separated for this step. With fast rotation this is an approximation, because the separation along a fixed axis can dip and recover inside the step. 4. Otherwise find the `t` where `sep(t)` equals the target with a **bracketed root finder**, such as bisection mixed with the secant or false-position method, which stays inside the bracket while converging quickly. 5. Re-run the closest-feature query at that time. If the gap is within tolerance, that is the TOI; if new features now face each other, repeat with their axis. | Method | Uses | Strength | Weakness | |---|---|---|---| | Swept sphere | a closed-form quadratic | exact, cheap | spheres and straight motion only | | Conservative advancement | distance and a speed bound | simple, never overshoots | slow when the bound is loose | | Separating-axis root finding | the real separation function | few iterations near contact | more involved; must handle feature changes | ## Practical guards - **Iteration cap**: a hard limit on loop count, with a decision about what to report when it is hit; many implementations treat it as contact at the last safe time. - **Target separation above zero**: stopping slightly short of touching leaves room for ordinary contact generation, which handles small gaps and overlaps far more robustly than an exact touch. - **Reuse of closest features**: starting each distance query from the previous iteration's features makes the repeated queries cheap. - **Motion model consistency**: the poses used for TOI must follow the same motion the integrator will produce, or the reported time of impact describes a path the body never takes.

  • Why project the linear velocity onto n but use the full angular speed?
    Along the fixed axis `n`, the centres of mass close at exactly `dot(vA - vB, n)`, so projecting is precise for the linear part. For rotation, an exact rate would need every surface point's velocity, so the bound assumes the fastest possible surface point, at `|w| * r`, moves straight along `n`. Some implementations use the full relative linear speed too, which is looser but simpler to reason about.
  • Why stop at a small positive target separation instead of exact contact?
    Reaching exactly zero distance takes the slowest final iterations, and a distance query is least reliable when the shapes touch or overlap. Stopping slightly apart lets ordinary contact generation, which handles small gaps and shallow overlaps well, produce the contact at the time of impact.

  • Conservative advancement can overshoot contact when bodies rotate quickly.
  • Advancing by the gap divided by the current closing speed is always safe.
  • Conservative advancement needs no iteration cap because it always converges quickly.
  • Conservative advancement only works for spheres moving in straight lines.
  • The angular term can be dropped when the centre of mass is moving fast.