2
\$\begingroup\$

I want to make a function like areColliding which takes two polygons as args. I also want to cover cases like

case 1

and the dreaded

case 2

because I am trying to create a framework and I think that it should be as accurate as possible.

var polygon1 = [ [1, 1], [2, 5], [5, 3], ]; var polygon2 = [ [1, 1], [2, 5], [3, 5], [7, 4], [1, 3], [2, 1], [1, 0], ]; areColliding(polygon1, polygon2) //=> true areColliding([[1, 4]], [[1, 2], [3, 4], [5, 6]]) //=> Error areColliding({}, [[1, 2], [3, 4], [5, 6]]) //=> Error areColliding([[1,1],[2,2],[3,0]], [[7,7],[5,7],[6,8]]) //=> false 
\$\endgroup\$
1
  • 2
    \$\begingroup\$ So, presumably you did a search for standard algorithms for this and found options like Separating Axis Theorem, GJK, etc? What have you tried based on your research thus far? \$\endgroup\$ Commented Apr 5, 2021 at 11:49

0

You must log in to answer this question.