Skip to contents

Normalized Cumulative Distance Along a Vertex Path

Usage

path.dist(s, V)

Arguments

s

Nonempty numeric vector of integer vertex indices in 1:nrow(V). Repeated indices are allowed and the supplied order defines the path.

V

Finite numeric vertex coordinate matrix with at least one row and one column.

Value

Numeric vector of length length(s). For a positive-length path, cumulative Euclidean distances start at zero and end at one. A singleton or zero-length path returns all zeros. Empty paths and total lengths exceeding the finite numeric range are rejected.

Examples

vertices <- rbind(c(0, 0), c(1, 0), c(1, 2))
path.dist(1:3, vertices)
#> [1] 0.0000000 0.3333333 1.0000000
path.dist(2, vertices) # a singleton has normalized distance zero
#> [1] 0