d3 / d3-geo-polygon

Clipping and geometric operations for spherical polygons.
https://observablehq.com/collection/@d3/d3-geo-polygon
Other
107 stars 22 forks source link

planar polygon clipping #25

Closed Fil closed 2 months ago

Fil commented 5 years ago

The Imago projection needs to use polygon clipping; but it seems a bit absurd that we are doing spherical clipping (with 200 control points computed as the inverse of 200 planar points) just to do what is in the end a simple rectangular clipping. The thing is tricky because, so close to the limit, the spherical interpolation between control points might jump from one side to the other.

Fil commented 4 years ago

See https://github.com/d3/d3-polygon/issues/4

Fil commented 2 months ago

The best library (as of today and as far as I know) is https://github.com/mfogel/polygon-clipping; see https://observablehq.com/@fil/hello-polygon-clipping.