interparc: Interpolate Equally Spaced Points Along a Closed Curve
Description
Fits periodic cubic smoothing splines to the supplied coordinates and
returns points that are equally spaced by arc length along the fitted curve.
The curve is parameterized by cumulative chord length, smoothed using
cyclic cubic splines (mgcv), and then reparameterized by arc length to
obtain equally spaced samples.
A matrix with one column per coordinate dimension (V1, V2, ...),
containing interpolated points that are equally spaced by arc length.
Arguments
t
Either:
A single integer specifying the number of equally spaced output
points, or
A numeric vector of normalized arc-length positions between 0 and
1 at which to evaluate the curve.
...
Two or more equal-length coordinate vectors (e.g., x, y, or
x, y, z) describing the input curve.
n.samples
Number of points used to approximate the arc-length
parameterization of the fitted spline. Larger values improve accuracy but
increase computation time.
k
Basis dimension for the cyclic cubic spline. Larger values allow
more flexible fits.
gamma
Smoothing penalty multiplier passed to
mgcv::gam(). Values greater than 1 produce smoother curves.
Details
The function first parameterizes the input points by cumulative chord
length, fits a cyclic cubic spline to each coordinate using
Restricted Maximum Likelihood (REML), estimates arc length from the fitted
curve, and then evaluates the splines at parameter values corresponding to
equally spaced arc-length positions.