Position around a polygon

pos_by_polygon(
  x,
  y,
  where = c("left", "right", "top", "bottom", "topleft", "topright", "bottomleft",
    "bottomright")
)

Arguments

x

x-coordinate of a polygon.

y

y-coordinate of a polygon.

where

Which side of the polygon? It should take value in c("left", "right", "top", "bottom", "topleft", "topright", "bottomleft", "bottomright").

Value

A numeric scalar of length two, which is the xy-coordinate of the point.

Examples

x = c(235, 235, 237, 241, 246, 248, 250, 250, 250, 253,
      256, 260, 264, 263, 261, 257, 252, 247, 241, 237, 235)
y = c(418, 409, 402, 397, 394, 395, 396, 404, 411, 416, 417, 
      416, 415, 422, 429, 434, 437, 436, 432, 426, 418)
pos_by_polygon(x, y, "left")
#> [1] 235.0000 415.4286
pos_by_polygon(x, y, "bottomleft")
#> [1] 235 394