Categories &

Functions List

Function Reference: geom.arclength

drafting: L = geom.arclength (P)
drafting: L = geom.arclength (P, CLOSED)
drafting: [L, S] = geom.arclength (…)

Length along a sampled curve.

L = geom.arclength (P) returns the total length of the polyline whose points are the rows of the N-by-2 matrix P, in the units of P.

L = geom.arclength (P, CLOSED) adds the closing segment from the last point back to the first when CLOSED is true. CLOSED defaults to false.

[L, S] = geom.arclength (…) also returns the cumulative length at each point, starting at zero, which is what a caller needs to place something a given distance along the curve.

The length is that of the polyline, not of any smooth curve it may have been sampled from, and a polyline is always the shorter of the two. How much shorter is governed by the sampling: at the chordal tolerance geom.curvesample works to, the shortfall is of the same order.

See also: geom.resample, geom.simplify, geom.curvesample

Source Code: geom.arclength

The length along a curve, and the cumulative distance at each point -- which is what places something a given distance along it.

 P = [0, 0; 30, 0; 30, 40];
 [L, S] = geom.arclength (P)
L = 70
S =

    0
   30
   70

Closing the ring adds the segment back to the start

 geom.arclength (P, true)
ans = 120

The length is that of the polyline, not of the smooth curve it was sampled from, and a polyline is always the shorter of the two.

 for n = [8, 60, 400]
   t = linspace (0, 2*pi, n + 1)(1:n)';
   printf ('%3d-sided polygon: %8.4f  (circle is %8.4f)\n', n, ...
           geom.arclength (10 * [cos(t), sin(t)], true), 2 * pi * 10);
 endfor
  8-sided polygon:  61.2293  (circle is  62.8319)
 60-sided polygon:  62.8031  (circle is  62.8319)
400-sided polygon:  62.8312  (circle is  62.8319)