Open HarryStevens opened 4 years ago
It will likely also be necessary to implement a utility method called, say, polygonWind, polygonSort, or polygonOrder because the Martinez et al clipping algorithms require a polygon's vertices to be in counter-clockwise order.
Here's an implementation: https://observablehq.com/d/eaf3a3c863d34aee
See also: http://sean.cm/a/polygon-clipping-pt1
On simple polygons, see: https://en.wikipedia.org/wiki/Simple_polygon
Fil's done it: https://observablehq.com/@d3/polygonclip
Would love to see this added to the library!
The current relationship methods return only booleans, i.e. if the relationship exists. Better would be to return where the relationship exists, or false if it does not exist.
The polygon relationship methods will likely be somewhat time consuming to implement. The most modern algorithms for performing boolean operations on polygons can be found here: http://www.cs.ucr.edu/~vbz/cs230papers/martinez_boolean.pdf
These will likely not be compatible with current methods, so it may be necessary to bump major versions.