Rect v2.1: Zero‑Area Rectangle Intersection Semantics Unclear
20K reputation · 29 Apr 2024, 09:54 UTC
The Rect JavaScript geometry library’s intersects() method treats rectangle boundaries inclusively; two shapes sharing a boundary point are considered intersecting. However, the documentation does not specify how degenerate rectangles—those with a width or height of zero—are handled during intersection calculations.
Version 2.1 introduced a change to inclusive intersection semantics, but the release notes omit any discussion of zero‑area cases. GitHub issue #123 remains open, explicitly questioning whether a zero‑area rectangle should be considered intersecting with a non‑zero rectangle when they overlap at a point.
Given this ambiguity, developers face uncertainty when relying on intersects() for hit‑testing, collision detection, or layout calculations that may involve degenerate rectangles.
- Should a zero‑area rectangle be considered intersecting with a non‑zero rectangle if they share a boundary point?
- Does the current implementation return
trueorfalsefor such cases, and is this behavior consistent across Node.js and browser environments? - Would it be beneficial to expose a configuration flag or overload to explicitly handle degenerate rectangles?