Skip to main content

geop_core_geometry/
search.rs

1//! The default effort of the subdivision searches and the Newton
2//! refinement after them. These bound how hard a search tries, never what
3//! an answer means (see `AGENTS.md`): an operation that needs another
4//! value says so where it uses it, with its reason.
5
6use geop_core_math::scalars::Scalar;
7
8/// Node budget for a subdivision search (`contains`, `intersection`).
9pub const MAX_NODES: usize = 20_000;
10
11/// Where a subdivision search hands over to Newton (see `AGENTS.md`'s
12/// "Subdivide to isolate, then Newton to refine").
13pub const MIN_SUBDIVISION_SIZE: f64 = 1e-7;
14
15/// Where a nearest-point search hands over to Newton, as a fraction of the
16/// size of what it searches (`NurbCurve::closest_point`,
17/// `NurbSurface::closest_point`). Bounds effort only: every piece left at
18/// the handoff that could hold a nearer point is refined, so a coarser
19/// handoff only leaves Newton more pieces to start from.
20pub const NEAREST_HANDOFF: f64 = 1e-3;
21
22/// Newton steps projecting a point onto a surface.
23pub const PROJECT_ITERATIONS: usize = 20;
24
25/// [`MIN_SUBDIVISION_SIZE`] as a scalar.
26pub fn min_subdivision_size() -> Scalar {
27    Scalar::from_f64(MIN_SUBDIVISION_SIZE)
28}