HarryStevens / geometric

A JavaScript library for doing geometry.
https://www.npmjs.com/package/geometric
MIT License
980 stars 49 forks source link

polygonInPolygon -> Accept if PolygonA touches segment of PolygonB #8

Closed Mika83AC closed 5 years ago

Mika83AC commented 5 years ago

Currently I'm trying to use your library to detect if polygons are contained inside another polygon.

But for my case it's also fine if on segments (lines) of the "inside" polygon touches one or more of the "outer" polygon segments (point/line on line case). How can I handle this case with your library? Is there any possibility to do this without breaking the "inside" polygon into single lines and check if they are all inside or on the "outer" polygon segments?

Best regards, Michael

HarryStevens commented 5 years ago

Can you provide an example? It seems to return true for me: https://observablehq.com/d/a85af90aa1419dd5.

Depending on what you're trying to accomplish, you may also want polygonIntersectsPolygon.