Module polyline_length

Source
Expand description

Exact distance-to-parameter conversion for polylines.

A polyline is the one refused family whose arc length is a finite sum rather than an integral: locating a distance is a running sum until the interval is found, then one linear interpolation. The only transcendental is the sqrt in each segment length, which Line already relies on and reports as ArcLength3d, so refusing the sequence while accepting each element was not defensible on exactness grounds (kernel#107).

Three edges have a plausible-looking wrong answer, so each is pinned deliberately rather than left to fall out of the code:

  • A SEAM is two-valued. At an interior vertex the tangent jumps, so this returns the parameter of the OUTGOING segment: a distance that lands exactly on a vertex reads the heading the curve is about to take, not the one it arrived with.
  • A ZERO-LENGTH segment (repeated identical points) has no direction. Skipping it would silently change the parameterisation, so it is refused instead.
  • A CLOSED polyline’s wrap segment is real length and is included, but distance still may not exceed the total: it is clamped by refusal, never wrapped around.

Functions§

polyline_length
Total 3D length of polyline, or an error if any segment is degenerate or non-finite.
polyline_parameter
Convert a distance along polyline to its native parameter.