| interparc | R Documentation |
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.
interparc(t, ..., n.samples = 5000, k = 20, gamma = 1)
t |
Either:
|
... |
Two or more equal-length coordinate vectors (e.g., |
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
|
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.
A matrix with one column per coordinate dimension (V1, V2, ...),
containing interpolated points that are equally spaced by arc length.
x <- cos(seq(0, 2*pi, length.out = 20) * 1.5 - pi/2)
y <- sin(seq(0, 2*pi, length.out = 20))
plot(x, y, type = "b")
lines(interparc(1000, x, y), col = 2)
points(interparc(10, x, y), col = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.