Skip to main content

Module arc_parameter

Module arc_parameter 

Source
Expand description

Arc length along any evaluable curve and its inverse, and arc-length chains (#239), re-exported on the same footing as curve and surface. Arc length along any evaluable curve, and its inverse.

Most curves have no closed-form arc length: a cubic parabola y = A x^3 needs int sqrt(1 + 9 A^2 x^4) dx, an elliptic integral, and a B-spline or an ellipse is no better. Yet some data names a position by distance along such a curve: an arc-length trim selector, or a chain piece read by arc length. This module discharges both with quadrature of the speed |c'(t)| and a safeguarded Newton root find, the same bargain crate::arc_length makes for intrinsic curves: the stored value stays exact, only reading it needs numerical work.

§Accuracy contract

  • arc_length2 and arc_length3 integrate the speed by adaptive 8-point Gauss-Legendre, panels split at every knot and polyline vertex (the speed is only piecewise smooth there) and bisected until a panel and its two halves agree to the panel’s share of ARC_LENGTH_TOLERANCE * max(1, length). That agreement is an error ESTIMATE, as QUADPACK’s is, not a proof; on a smooth speed the halves are far more accurate than the estimate says.
  • parameter_at_arc_length2 and parameter_at_arc_length3 return a parameter whose arc length from from matches the request to the same tolerance, or a parameter bracket collapsed to rounding.
  • Lines, intrinsic curves and chains are exact: their parameter is a multiple of arc length, so no quadrature is run.

A request past the end of a bounded curve, a start parameter outside its domain, a curve whose speed does not evaluate, and a quadrature that needs more than MAX_PANELS panels are refused by name.

Constants§

ARC_LENGTH_TOLERANCE
Relative tolerance of every arc length and arc-length inverse this module returns: the absolute tolerance for a length l is ARC_LENGTH_TOLERANCE * max(1, |l|), in the curve’s length unit.
MAX_PANELS
Most quadrature panels one arc length may use before it refuses.

Functions§

arc_length2
Signed arc length of a 2D curve from parameter from to to: negative when to < from. See the module documentation for the tolerance.
arc_length3
Signed arc length of a 3D curve from parameter from to to; see arc_length2.
parameter_at_arc_length2
The parameter at signed arc length length from parameter from along a 2D curve: in increasing parameter for a positive length, decreasing for a negative one.
parameter_at_arc_length3
parameter_at_arc_length2 for a 3D curve.