Check if two polygons overlap: Difference between revisions
Content added Content deleted
(→{{header|jq}}: any) |
|||
Line 283: | Line 283: | ||
end; |
end; |
||
# If there's an axis for which the projections do not overlap, then false; else true |
|||
def polygonsOverlap($poly1; $poly2): |
def polygonsOverlap($poly1; $poly2): |
||
any( $poly1, $poly2 | getAxes[]; |
|||
. as $axis |
|||
⚫ | |||
| ($poly1 | projectOntoAxis($axis)) as $proj1 |
|||
⚫ | |||
| projectionsOverlap($proj1; $proj2) | not) |
|||
// 1 |
|||
| |
| not; |
||
def poly1: [[0, 0], [0, 2], [1, 4], [2, 2], [2, 0]]; |
def poly1: [[0, 0], [0, 2], [1, 4], [2, 2], [2, 0]]; |