w8r / GreinerHormann

Greiner-Hormann polygon clipping algorithm. Does AND, OR, XOR. Plays nicely with Leaflet. Handles non-convex polygons and multiple clipping areas. ~3kb footprint, no dependencies
http://w8r.github.io/GreinerHormann/
MIT License
238 stars 34 forks source link

Misleading documentation #23

Closed Aiosa closed 3 years ago

Aiosa commented 3 years ago

I am pretty stunned that in such project that involves a lot of math, the documentation calls difference as XOR. Both operations are totally different: XOR is a symmetric difference, resulting in areas not included in the intersection. From the documentation I went and wrote code that created intersection and performed xor on the initial polygon and the intersection to get the difference, and the behaviour was weird. Then I look closely on the example and find out that there is actually no XOR support whatsoever.

w8r commented 3 years ago

Hi @Aiosa! I agree. You can take a look at another project that makes the same type of operation and supports XOR: w8r/martinez

Aiosa commented 3 years ago

@w8r Actually, I needed only the difference, not XOR (thanks anyway), and spent over an hour by trying to figure out why the code does not work - and then I noticed that actually the documentation is wrong. So it would be nice to fix this 😄 (also on the dedicated webpage: https://milevski.co/GreinerHormann/)