Skip to main content

brepkit_geometry/sampling/
mod.rs

1//! Adaptive and uniform curve/surface sampling.
2//!
3//! # Uniform sampling
4//!
5//! [`sample_uniform`] and [`sample_uniform_with_params`] divide a parameter
6//! range into equal-size steps and evaluate the curve at each step. This is
7//! fast but may under-sample highly curved regions.
8//!
9//! # Deflection-based (adaptive) sampling
10//!
11//! [`sample_deflection`] uses recursive midpoint subdivision: it measures the
12//! perpendicular distance from the true curve point at each interval midpoint
13//! to the straight chord between the interval endpoints. If that distance
14//! (the "sag") exceeds `max_deflection`, the interval is split in two. This
15//! guarantees that every chord's midpoint deviation is within the requested
16//! tolerance.
17//!
18//! # Arc-length parameterized sampling
19//!
20//! [`sample_arc_length`] places `n` points at approximately equal arc-length
21//! spacing. It builds a fine chord-length table (256 segments) and bisects to
22//! find the parameter at each target fraction.
23//!
24//! # Curvature-adaptive sampling
25//!
26//! [`sample_curvature`] splits a NURBS curve's range at its knots and
27//! subdivides intervals whose turning, read from their curvature and arc
28//! length and from the turn of their tangents, exceeds a tolerance.
29//! Produces denser samples where the curve bends.
30//!
31//! # Surface grid sampling
32//!
33//! [`surface_grid`] evaluates a regular N×M grid of points over a parametric
34//! surface domain.
35//!
36pub mod arc_length;
37pub mod curvature;
38pub mod deflection;
39pub mod surface;
40pub mod uniform;
41
42pub use arc_length::sample_arc_length;
43pub use curvature::sample_curvature;
44pub use deflection::sample_deflection;
45pub use surface::surface_grid;
46pub use uniform::{sample_uniform, sample_uniform_with_params};