Description Usage Arguments Details Value Author(s) Examples
View source: R/is_point_inside.R
Returns whether a point is inside or outside the convex polygon formed with the coordinates in a data frame or matrix
1 | is_point_inside(point, polyg)
|
point |
vector of two values for a point in the Cartesian plane |
polyg |
data frame or matrix with the coordinates forming the convex polygon |
The algorithm used here draws a ray from the point and counts the number of intersections made with the polygon. If the number of intersections is only one, then this means the point is inside the convex polygon.
This function returns TRUE
, if the point is inside and FALSE
, otherwise.
Rafael A. Moral <rafael.deandrademoral@mu.ie> and John Hinde
1 2 3 4 5 | my_polygon <- data.frame(c(1, 2, 3, 4, 3),
c(1, 0, .5, 3, 4))
points_to_test <- list(c(0, 0), c(2.5, 1), c(3.5, 4))
unlist(lapply(points_to_test, is_point_inside, my_polygon))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.