pub fn flatten2(
curve: &Curve2,
domain: Interval,
chord_tolerance: f64,
max_depth: u32,
) -> Result<Vec<DVec2>, GeomError>Expand description
Flatten a 2D curve over domain so the chord never deviates from the true
curve by more than chord_tolerance.
For the families crate::bound::certifies_flattening2 names this is a
guarantee: every span is also accepted on a certified chord bound, and a
B-spline is cut at its corner knots first (#232). Other families are
accepted on their midpoint sagitta alone.
ยงWhy bisection rather than a closed-form segment count
A count derived from radius and tolerance only works for circles. Bisecting on measured sagitta works for every family, including rational splines whose curvature varies along the span, and it degrades gracefully on the degenerate inputs imported data actually contains.
The returned polyline includes both endpoints and is ordered along
increasing parameter. max_depth bounds the work: a caller gets a
deterministic result rather than an unbounded subdivision on a pathological
curve.