Skip to main content

flatten2

Function flatten2 

Source
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.

ยง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.