Calculates the perimeter of a 2D shape.

perimeter(data, keep_data = FALSE)

Arguments

data

A data frame with the first two columns ordered x and y coordinates.

keep_data

Logical. Keep lengths of all segments of the perimeter? Defaults to FALSE.

Value

The perimeter.

Examples

mcap_2d <- mesh_to_2d(mcap)
plot(mcap_2d)


perimeter(mcap_2d)
#> [1] 1.678564

r <- 1 # radius
circ <- sim_circle(r=r) # simulate xy coordinates for a circle of radius 1
plot(circ, asp=1)

perimeter(circ)
#> [1] 6.282131

2 * pi * r # Note xy resolution affects output
#> [1] 6.283185