Skip to contents

While it is sometimes necessary to get the actual intersection geometry, it may other times only be necessary to query whether an intersection exists. This is in general much faster than checking if intersection() returns NULL. Further, it is not bounded by the same constraint that an exact intersection must be constructable so a wider range of geometries are supported for the predicate. If the query is not possible it will return NA rather than an error

Usage

has_intersection(x, y, ...)

x %is_intersecting% y

Arguments

x, y

Geometry vectors or bounding boxes

...

Arguments passed on to methods

Value

a logical vector

See also

Examples

# Example of the predicate
t <- triangle(point(0, 0), point(1, 1), point(0, 1))
l <- line(1, -1, c(0, 1, 2))
has_intersection(t, l)
#> [1]  TRUE  TRUE FALSE

# Use binary operator instead
t %is_intersecting% l
#> [1]  TRUE  TRUE FALSE

# 2 dimensional circles are better supported
l %is_intersecting% circle(point(7, 4), 9)
#> [1]  TRUE  TRUE FALSE