expression

Check circle contact after a broad-phase candidate

Two circles with nonnegative radii touch or overlap when their center distance is no greater than the sum of radii. Comparing squared distances avoids a square root. This small integer model uses bounded coordinates; large inputs require overflow checks. It is not a contact manifold or a solver. Expected result (NOT RUN): contact: true contact: false Common mistake: Comparing a squared distance with an unsquared radius or ignoring integer overflow. Static Rust example; not a verified ByteMind executable assessment.

Formal Syntax & Structure

rust syntaxrust
dx*dx + dy*dy <= (r1+r2)*(r1+r2)

Working Example

Example Snippetrust
fn touches(a: [i64; 2], b: [i64; 2], r: i64, s: i64) -> bool {    let dx = a[0] - b[0]; let dy = a[1] - b[1];    dx * dx + dy * dy <= (r + s) * (r + s)}fn main() {    println!("contact: {}", touches([0, 0], [3, 4], 2, 3));    println!("contact: {}", touches([0, 0], [4, 4], 2, 3));}
Rust Reference