1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// SPDX-License-Identifier: MPL-2.0
//! Convex collision queries via the separating axis theorem.
//!
//! # What this answers, and what it deliberately does not
//!
//! Two convex shapes are disjoint if and only if some axis exists on which
//! their projections do not overlap. This crate finds such an axis, or proves
//! none exists.
//!
//! When the shapes are apart it also reports **how far** apart, because that
//! is the question a rule check asks: not "do these collide" but "is there
//! enough clearance". The `axiolid-inspect` crate's mesh clearance answers
//! the same
//! question for triangle soups; this answers it for convex shapes without
//! building an index.
//!
//! It does **not** report penetration depth. That is a deliberate refusal,
//! consistent with `axiolid-measure`: a contact area and an interpenetration
//! depth are different measurements, and collapsing them behind one number
//! is how a caller ends up using the wrong one. Callers needing penetration
//! depth for physics want EPA, which belongs in a physics engine rather than
//! a certified geometry kernel.
//!
//! # Why SAT rather than GJK
//!
//! For the shapes a model-checking rule actually has -- boxes, extruded
//! profiles, hulls with tens of vertices -- SAT is direct, has no iteration
//! count to tune, and its failure mode is a clean answer rather than a
//! tolerance-dependent one. GJK wins on high vertex counts and on a generic
//! support function; neither is the common case here, and published
//! commercial model-checking geometry APIs ship convex hull and SAT-style
//! tests without GJK/EPA at all.
//!
//! # Robustness
//!
//! Projections are compared with an explicit tolerance rather than exactly.
//! An axis derived from a cross product of two nearly parallel edges is
//! numerically meaningless, so such axes are skipped instead of being
//! allowed to report a spurious separation of ~1e-17.
use ;
pub use ;
pub use ConvexShape;
/// Shortest distance between two convex shapes, or zero if they overlap.
///
/// Convenience over [`separation`] for callers that only need the number.
/// Whether two convex shapes share any point.
/// Whether two oriented boxes overlap.
///
/// The case `Box3` could not answer before: it carried an orientation but had
/// no intersection test, so a caller had to fall back to an axis-aligned
/// bound and lose the tightness the orientation was for.
/// Whether a point lies inside or on a convex shape.
/// Axis-aligned extent of a shape along a direction.
pub