Skip to main content

Module chord

Module chord 

Source
Expand description

Chord deviation computation for circular arc discretization.

Given a circle of radius r, the chord deviation (sag) at the midpoint of an arc subtending angle θ is r*(1 - cos(θ/2)). This module provides the inverse: given a maximum deflection, compute the number of segments needed to discretize an arc.

Two independent tolerances drive density: the linear sag deflection and an angular cap angular_tol (max tangent turn per segment). The linear criterion alone lets a small-radius arc take a near-π turn per segment, under-tessellating sharp rounded features; the angular cap floors the segment count independently of radius.

Constants§

DEFAULT_ANGULAR_TOL
Default angular deflection cap (radians) when a caller has no preference.

Functions§

segments_for_chord_deviation
Compute the number of segments needed to discretize a circular arc so that the chord-height deviation stays below deflection.
segments_for_chord_deviation_with_angle
Compute the number of segments to discretize a circular arc so that both the chord-height deviation stays below deflection and the per-segment tangent turn stays below angular_tol.