This algorithm checks whether a point lies within an arbitrary polygon by checking the even-odd-rule, which says that for any point (x,y) that lies within a polygon, the number of times it cross the boundaries of this polygon when x goes to infinity should be uneven/odd.
Value
Logical vector denoting whether each point in x lies within
(TRUE) or outside (FALSE) of the object.
Details
While this may not seem like the most efficient algorithm, it is quite fast for the typical objects used in predped.
Examples
# Create a set of points that come from a rectangle
my_rectangle <- rectangle(center = c(0, 0), size = c(2, 2))
points <- my_rectangle@points
# Create a set of points that fall inside of or outside of the rectangle
coords <- rbind(c(0, 0),
c(2, 0))
# Check where they lie with the raycasting algorithm
raycasting(points, coords)
#> [1] TRUE FALSE