expression
Test axis-aligned bounding boxes
An axis-aligned bounding box encloses a shape with minimum and maximum coordinates. A broad-phase overlap test can reject pairs before expensive geometry tests. This closed-interval 2D model counts touching edges as overlap; real shapes can still be disjoint even when their boxes overlap. Inputs are ordered, finite integer bounds. Expected result (NOT RUN): touch: true, separate: false Common mistake: Treating bounding-box overlap as proof of contact between arbitrary shapes. Static Rust example; not a verified ByteMind executable assessment.
Formal Syntax & Structure
rust syntaxrust
a.min_x <= b.max_x && b.min_x <= a.max_x && ...Working Example
Example Snippetrust
struct Rect { min: [i32; 2], max: [i32; 2] }fn overlaps(a: &Rect, b: &Rect) -> bool { (0..2).all(|i| a.min[i] <= b.max[i] && b.min[i] <= a.max[i])}fn main() { let a = Rect { min: [0, 0], max: [2, 2] }; let b = Rect { min: [2, 1], max: [4, 3] }; let c = Rect { min: [3, 0], max: [5, 2] }; println!("touch: {}, separate: {}", overlaps(&a, &b), overlaps(&a, &c));}