Subdivide a Path into Arc-Length Spaced Points
Value
Numeric matrix with n.subdivision.pts rows and ncol(path) columns,
preserving coordinate column names. The first and last rows are the path
endpoints. A singleton or zero-length path repeats its location in every
output row. Empty paths are rejected.
Details
Points are interpolated at equally spaced cumulative Euclidean distances along the input polyline. Zero-length segments are skipped. Equal spacing along the polyline does not imply equal straight-line distances between output points that straddle a corner, and an interior vertex need not appear in the output. Distances are evaluated in floating-point arithmetic; paths whose total length exceeds the finite numeric range are rejected.
Examples
path <- rbind(c(0, 0), c(1, 0), c(1, 2))
subdivide.path(path, n.subdivision.pts = 5)
#> [,1] [,2]
#> [1,] 0.00 0.00
#> [2,] 0.75 0.00
#> [3,] 1.00 0.50
#> [4,] 1.00 1.25
#> [5,] 1.00 2.00
# Arc distances 0, 0.75, 1.5, 2.25, 3 give:
# (0, 0), (0.75, 0), (1, 0.5), (1, 1.25), (1, 2).
subdivide.path(matrix(c(1, 2), nrow = 1), n.subdivision.pts = 3)
#> [,1] [,2]
#> [1,] 1 2
#> [2,] 1 2
#> [3,] 1 2