overlaps

Tests whether two polyshapes share any area.

Category: Mathematics > Computational Geometry

Syntax

TF = overlaps(P1, P2)

true when P1 and P2 overlap.

Description

The test asks whether the intersection of the two shapes has a non-zero area. A shape lying entirely inside the other overlaps it; two shapes that are far apart do not. Because it avoids building the intersection result, it can be faster than computing intersect and checking its area.

Input arguments

P1, P2
polyshape objects.

Output arguments

TF
Logical scalar.

Example

Overlapping and separate shapes

A = polyshape([0 2 2 0], [0 0 2 2]);
B = polyshape([1 3 3 1], [1 1 3 3]);
C = polyshape([5 6 6 5], [5 5 6 6]);
overlaps(A, B)
overlaps(A, C)
Output
ans = logical
   1
ans = logical
   0

See also

intersect union subtract polyshape rectint