Walks along a path and emits a point every step units of arc length.
The result has (nearly) uniform point spacing regardless of how the input was
parameterized, which is what makes a swept tube look even:
generate_tube places exactly one cross-section per path point,
so uneven spacing means a tube that is finely subdivided in one place and
faceted in another. Typical use is to even out the output of
spline_path, whose samples are evenly spaced in the curve
parameter rather than along the curve.
Value
An Nx3 numeric matrix of resampled path points. A path without length (or with fewer than two points) is returned as it is.
Details
The spacing that is uniform is the *arc length* along the path; the straight-line distances between consecutive samples are slightly shorter wherever the path curves. An open path always keeps its final point (with a possibly shorter last step); a closed path ends on a copy of its first point and is covered in a whole number of steps, so its effective step can differ from the requested one by a fraction of a percent.
Examples
waypoints <- matrix(c(0, 0, 0, 1, 1, 0, 2, 0, 0), ncol = 3, byrow = TRUE)
smooth <- spline_path(waypoints, samples_per_segment = 32)
even <- resample_path(smooth, step = 0.1)
nrow(even)
#> [1] 30