There are different algorithms to check if two polygons intersect, but one common and efficient way to accomplish this in Matlab is to use the polybool
function. This function can operate on two closed polygons and determine if their intersection is not empty, and if so, return the resulting polygon(s).
Here is an example code showing how to use polybool
to check the intersection of two polygons defined by their vertices:
main.m622 chars22 lines
Note that polybool
can also be used to compute the union, difference, or xor of the two polygons.
gistlibby LogSnag