pub fn disjoint_box_box<A, B, T>(a: &A, b: &B) -> boolwhere
A: BoxTrait,
B: BoxTrait,
<A as Geometry>::Point: PointTrait<Scalar = T>,
<B as Geometry>::Point: PointTrait<Scalar = T>,
T: CoordinateScalar,Expand description
disjoint for two axis-aligned boxes — a direct separating-axis
test, skipping the general intersects machinery.
Two boxes are disjoint iff they are separated on either axis:
one’s maximum on an axis is below the other’s minimum. Mirrors the
box/box specialisation in
boost/geometry/strategies/cartesian/disjoint_box_box.hpp, which
short-circuits per axis rather than routing through intersects.
This is a CC5 fast path: disjoint(Box, Box) is one of the hottest
pair-combinations (envelope pruning, rtree node tests), and the
per-axis comparison is far cheaper than the generic areal intersects.
§Examples
use geometry_algorithm::disjoint_box_box;
use geometry_cs::Cartesian;
use geometry_model::{Box, Point2D};
type P = Point2D<f64, Cartesian>;
let a = Box::from_corners(P::new(0.0, 0.0), P::new(2.0, 2.0));
let far = Box::from_corners(P::new(5.0, 5.0), P::new(6.0, 6.0));
let overlapping = Box::from_corners(P::new(1.0, 1.0), P::new(3.0, 3.0));
assert!(disjoint_box_box(&a, &far));
assert!(!disjoint_box_box(&a, &overlapping));