hypar-io / Elements

The smallest useful BIM.
https://www.hypar.io
MIT License
347 stars 74 forks source link

Inconsistencies between Contains/Covers functions #1048

Open DmytroMuravskyi opened 10 months ago

DmytroMuravskyi commented 10 months ago

Describe the bug When working with issue https://github.com/hypar-io/Elements/issues/767 I found that it's hard categorize Contains/Covers functions or understand what it does from signature. All Covers function say that they return true when "is within this Polygon or coincident with an edge" while Contains - "without coincidence with an edge or vertex". But Contains3D (and a function calling it) says "is within this Polygon or coincident with an edge." and returns accordingly breaking understanding of difference between the two.

It's hard to understand if function expects 3d or 2d geometry. Many functions say "when compared on a shared plane." but some of them, work on XY plane, like bool Contains(Polygon polygon) where Clipper with 2d IntPoint is used or bool Covers(Polygon polygon) where Intersects2d is called. This fails if Polygon is on YZ plane, for example.

Also some functions use Clipper lib: bool Contains(Polygon polygon) and bool Covers(Vector3 vector) while other use custom implementation. Ideally all functions should rely on same implementation since they are similar.

Expected behavior