Tuesday, July 11, 2023

Point In Polygon node.js function

How to determine if a point coordinate lies within a 2D polygon defined by multiple coordinates.


Of several approaches to this problem I used Dan Sunday's Winding Number method.

1 comment:

  1. The order of the points in the polygon array matters. If you are uncertain of the point order you can add this point randomizer which calls the inPolygon check multiple times until it gets a true result.

    https://gist.github.com/cgrote714/5b36611d474d74ac09acaa791362283d

    ReplyDelete