Skip to contents

Calculate the distance from the centroid to each point.

Usage

get_centroid_distance(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

  • If x is a single matrix: returns a numeric vector (one distance per point)

  • If x is a list: returns a list of numeric vectors

  • If x is a tibble: returns a list of numeric vectors extracted from coo column

Details

Returns the Euclidean distance from the centroid to each point on the outline. This is a vector, not a scalar, so cannot be used with measure().

Examples

get_centroid_distance(shapes$cat)
#>   [1]  34.31990  39.00328  40.00320  43.99495  50.69720  53.90924  52.55907
#>   [8]  52.52957  52.20015  52.55812  52.61612  54.31349  56.59908  59.40501
#>  [15]  62.66144  65.53286  69.76034  74.26140  77.33955  79.00731  78.11181
#>  [22]  77.72230  76.88079  76.51507  75.63766  74.23042  73.30249  72.87219
#>  [29]  73.71639  77.78210  80.40619  81.58098  83.22112  84.30098  85.79951
#>  [36]  86.71249  88.02588  88.77306  89.92639  90.13438  90.28569  89.28609
#>  [43]  86.91723  84.40353  80.15956  76.15219  70.82553  64.85450  60.74912
#>  [50]  57.89694  56.83578  55.95673  54.74263  55.16888  55.25582  55.98933
#>  [57]  56.38400  58.35028  59.07500  59.62974  60.92254  62.88128  64.73527
#>  [64]  66.78327  69.22504  69.74529  69.92929  71.66872  75.97306  81.80010
#>  [71]  87.84706  92.84452  98.87596 104.96454 111.15487 116.75147 121.60512
#>  [78] 128.04552 134.71546 140.69472 136.86126 131.37791 126.59840 123.41902
#>  [85] 122.69864 121.01366 118.76471 117.75570 112.12518 104.91642  97.51900
#>  [92]  91.68809  86.58583  82.99913  78.79090  74.17820  69.77683  65.62930
#>  [99]  60.21715  53.38076  46.65732  40.97628  36.57808  33.78765  32.99402
#> [106]  33.03037  34.13804  36.21886  39.11784  43.44371  48.20639  54.06622
#> [113]  58.83584  61.61620  60.89052  58.08533  53.35359  45.74337  38.61419
#> [120]  32.32887
get_centroid_distance(shapes)
#> $cat
#>   [1]  34.31990  39.00328  40.00320  43.99495  50.69720  53.90924  52.55907
#>   [8]  52.52957  52.20015  52.55812  52.61612  54.31349  56.59908  59.40501
#>  [15]  62.66144  65.53286  69.76034  74.26140  77.33955  79.00731  78.11181
#>  [22]  77.72230  76.88079  76.51507  75.63766  74.23042  73.30249  72.87219
#>  [29]  73.71639  77.78210  80.40619  81.58098  83.22112  84.30098  85.79951
#>  [36]  86.71249  88.02588  88.77306  89.92639  90.13438  90.28569  89.28609
#>  [43]  86.91723  84.40353  80.15956  76.15219  70.82553  64.85450  60.74912
#>  [50]  57.89694  56.83578  55.95673  54.74263  55.16888  55.25582  55.98933
#>  [57]  56.38400  58.35028  59.07500  59.62974  60.92254  62.88128  64.73527
#>  [64]  66.78327  69.22504  69.74529  69.92929  71.66872  75.97306  81.80010
#>  [71]  87.84706  92.84452  98.87596 104.96454 111.15487 116.75147 121.60512
#>  [78] 128.04552 134.71546 140.69472 136.86126 131.37791 126.59840 123.41902
#>  [85] 122.69864 121.01366 118.76471 117.75570 112.12518 104.91642  97.51900
#>  [92]  91.68809  86.58583  82.99913  78.79090  74.17820  69.77683  65.62930
#>  [99]  60.21715  53.38076  46.65732  40.97628  36.57808  33.78765  32.99402
#> [106]  33.03037  34.13804  36.21886  39.11784  43.44371  48.20639  54.06622
#> [113]  58.83584  61.61620  60.89052  58.08533  53.35359  45.74337  38.61419
#> [120]  32.32887
#> 
#> $dog
#>   [1]  22.21506  25.62016  29.04925  33.45981  38.61380  43.39980  49.25876
#>   [8]  57.72702  64.16626  73.81221  81.02269  88.78228  97.68457 103.63506
#>  [15] 108.89089 110.43418 112.47989 118.87280 123.28196 124.50887 121.05010
#>  [22] 117.62664 113.90234 110.96235 105.56843  96.26920  89.33034  85.07482
#>  [29]  89.54603  97.32056 105.71594 112.41490 106.98587 100.25032  97.52987
#>  [36]  93.93558  92.90206  91.25099  91.97505  91.16666  90.89624  89.00660
#>  [43]  86.63299  82.40353  78.19906  72.99367  68.43385  63.52553  58.71677
#>  [50]  54.36873  49.73237  46.23428  43.28867  39.75478  38.37633  38.92183
#>  [57]  39.53744  42.93183  47.35109  53.64413  60.47335  69.05065  76.25675
#>  [64]  84.31494  90.48762  97.18055 104.24910 112.44143 118.66287 122.00482
#>  [71] 125.54472 126.09815 125.11232 128.77426 133.26331 137.86736 135.17319
#>  [78] 131.71519 127.06741 120.71292 114.55861 108.69372 102.61770  97.06995
#>  [85]  91.39215  86.74979  81.01024  76.88731  73.07981  71.39287  68.48315
#>  [92]  67.03115  66.22104  63.99356  62.69218  63.75233  66.71313  69.71185
#>  [99]  73.08107  78.18040  82.15398  87.77590  94.83482 100.50228  98.80330
#> [106]  95.89044  88.90337  83.49646  78.18893  71.58998  65.15271  59.49517
#> [113]  52.57606  46.47572  38.67526  33.38102  29.15463  25.15238  21.93534
#> [120]  21.11419
#> 
#> $heart
#>   [1] 105.36279 103.41414 100.45729  95.74080  92.08882  87.93900  84.17948
#>   [8]  81.48937  79.49298  78.41663  77.29026  77.49904  77.51216  78.52675
#>  [15]  79.95478  81.63639  83.73063  85.32790  87.56408  90.20025  92.27360
#>  [22]  95.27505  97.01229  98.76100  99.82886 101.27965 101.83983 102.66856
#>  [29] 102.67587 102.92635 103.30070 103.98334 104.69830 104.82820 104.24915
#>  [36] 104.55047 104.45925 103.74191 102.87242 102.75886 101.58470  99.92614
#>  [43]  97.99346  96.39598  94.29405  92.35006  89.93007  86.92526  84.65735
#>  [50]  81.14894  78.29251  74.21389  70.31134  66.02765  60.58906  56.57739
#>  [57]  50.77763  45.14127  40.81280  35.68778  32.65197  36.72580  41.99326
#>  [64]  46.40888  52.13589  58.29438  63.35851  67.96899  71.42304  75.44822
#>  [71]  79.63427  81.73423  85.36608  87.73958  90.86703  93.41895  95.46553
#>  [78]  97.03273  98.77053 100.88261 102.19777 103.58596 104.82088 104.97453
#>  [85] 104.96468 105.23078 105.06205 104.83440 104.85451 105.24725 103.71966
#>  [92] 103.46288 103.35893 103.49670 101.78867 101.37908 100.05541  98.17553
#>  [99]  95.65599  93.15579  90.43184  88.13711  85.72262  83.72923  81.71363
#> [106]  79.80999  78.99283  77.83562  77.10318  77.33779  78.30294  79.77197
#> [113]  82.04572  84.36657  87.30207  91.33218  95.80815  99.55326 104.40403
#> [120] 108.35851
#> 
#> $leaf2
#>   [1]  63.81421  70.79797  76.73332  83.66483  89.65184  96.66050 103.79187
#>   [8] 106.26595 102.96846  96.45363  89.04944  81.90240  75.84427  68.79246
#>  [15]  62.74355  55.75530  58.41535  61.87005  65.01656  67.41108  69.89208
#>  [22]  73.19838  75.93651  79.25089  82.31162  85.93750  82.25511  73.42141
#>  [29]  63.82518  59.70304  64.53064  68.99350  74.68302  80.69946  79.44214
#>  [36]  72.43758  68.50696  74.15088  80.11119  85.66857  91.59914  93.75822
#>  [43]  87.34789  81.49143  74.78103  71.73913  74.04629  72.39063  65.84985
#>  [50]  57.27786  48.71656  40.24926  40.17279  45.82306  52.39612  59.13504
#>  [57]  64.59879  70.49045  74.74893  70.87138  66.87491  63.02304  69.85559
#>  [64]  75.55232  82.14836  87.85700  94.50584 100.35165  95.57643  88.98063
#>  [71]  83.30458  76.74668  69.88672  64.26588  66.92311  70.92956  74.81813
#>  [78]  71.09151  66.07422  59.83104  54.54726  48.03335  41.02259  39.71716
#>  [85]  49.58229  57.39166  65.96479  72.50761  75.55894  72.74203  74.46108
#>  [92]  81.62661  87.48430  93.89650  91.74068  88.01053  81.44448  76.42253
#>  [99]  70.70893  73.58738  79.57765  80.84895  76.62639  71.06584  65.60871
#> [106]  61.63443  64.82633  73.02844  81.83003  87.68354  83.95387  80.07374
#> [113]  77.35311  74.46511  71.03628  68.37692  65.43969  62.47522  58.80054
#> [120]  56.92366
#>