Skip to contents

Calculate perimeter-related measurements of a shape.

Usage

get_perim(x, ..., .cols = NULL)

get_perim_along(x, ..., .cols = NULL)

get_perim_cum(x, ..., .cols = NULL)

Arguments

x

A matrix (nx2), list of matrices, or tibble with coo columns.

...

Additional arguments (reserved for future use).

.cols

Column name(s) to process when x is a tibble. If NULL, automatically detects columns containing coo objects.

Value

  • get_perim(): numeric scalar (matrix) or vector (list/tibble)

  • get_perim_along(): numeric vector (matrix) or list of vectors (list/tibble)

  • get_perim_cum(): numeric vector (matrix) or list of vectors (list/tibble)

Details

  • get_perim(): total perimeter

  • get_perim_along(): length of each segment

  • get_perim_cum(): cumulative perimeter from start

For tibbles, these functions extract values without modifying the tibble.

Examples

get_perim(shapes$cat)
#> [1] 750.7288
get_perim_along(shapes$cat)
#>   [1] 7.211103 4.000000 6.324555 6.708204 6.403124 5.000000 6.082763 6.000000
#>   [9] 6.000000 6.082763 6.000000 6.000000 6.000000 6.000000 6.082763 4.242641
#>  [17] 5.099020 6.708204 7.071068 6.324555 6.324555 6.082763 6.082763 6.000000
#>  [25] 6.082763 6.082763 6.082763 5.000000 5.830952 7.211103 6.324555 6.324555
#>  [33] 6.082763 6.082763 6.000000 6.000000 6.082763 6.082763 5.385165 6.708204
#>  [41] 7.810250 7.211103 6.708204 6.000000 6.000000 6.324555 6.708204 6.082763
#>  [49] 6.000000 5.099020 6.082763 6.000000 6.082763 6.000000 6.000000 6.082763
#>  [57] 6.000000 6.324555 6.708204 6.708204 5.385165 7.211103 7.810250 8.485281
#>  [65] 6.708204 6.324555 6.708204 7.810250 7.810250 6.708204 5.000000 6.082763
#>  [73] 6.324555 6.708204 7.810250 7.211103 6.708204 7.211103 7.071068 6.403124
#>  [81] 6.082763 5.000000 4.472136 6.708204 6.403124 7.071068 6.403124 6.082763
#>  [89] 7.211103 7.810250 5.830952 6.000000 5.099020 6.082763 6.000000 6.000000
#>  [97] 6.000000 6.324555 7.211103 7.211103 6.708204 6.324555 6.082763 5.000000
#> [105] 6.000000 6.000000 6.000000 6.000000 6.082763 5.385165 6.324555 5.385165
#> [113] 6.324555 7.211103 5.000000 6.324555 7.810250 7.211103 6.324555 3.605551
get_perim_cum(shapes$cat)
#>   [1]   7.211103  11.211103  17.535658  24.243862  30.646986  35.646986
#>   [7]  41.729749  47.729749  53.729749  59.812511  65.812511  71.812511
#>  [13]  77.812511  83.812511  89.895274  94.137914  99.236934 105.945138
#>  [19] 113.016206 119.340761 125.665316 131.748079 137.830841 143.830841
#>  [25] 149.913604 155.996366 162.079129 167.079129 172.910081 180.121183
#>  [31] 186.445739 192.770294 198.853056 204.935819 210.935819 216.935819
#>  [37] 223.018582 229.101344 234.486509 241.194713 249.004962 256.216065
#>  [43] 262.924269 268.924269 274.924269 281.248824 287.957028 294.039791
#>  [49] 300.039791 305.138810 311.221573 317.221573 323.304335 329.304335
#>  [55] 335.304335 341.387098 347.387098 353.711653 360.419857 367.128061
#>  [61] 372.513226 379.724328 387.534578 396.019859 402.728063 409.052619
#>  [67] 415.760823 423.571072 431.381322 438.089526 443.089526 449.172288
#>  [73] 455.496844 462.205048 470.015297 477.226400 483.934604 491.145706
#>  [79] 498.216774 504.619898 510.702661 515.702661 520.174797 526.883001
#>  [85] 533.286125 540.357193 546.760317 552.843080 560.054182 567.864432
#>  [91] 573.695384 579.695384 584.794403 590.877166 596.877166 602.877166
#>  [97] 608.877166 615.201721 622.412824 629.623926 636.332130 642.656686
#> [103] 648.739448 653.739448 659.739448 665.739448 671.739448 677.739448
#> [109] 683.822211 689.207375 695.531931 700.917096 707.241651 714.452753
#> [115] 719.452753 725.777309 733.587558 740.798661 747.123216 750.728768

# Extract from tibble
perims <- get_perim(bot)

# Add to tibble
bot$perim <- get_perim(bot)