Currently, our primitives use a closed interval semantics, i.e., both min and max are included.
To avoid confusion about floating point rounding to integer domain we do not offer floating-point variants of methods on integer primitives, e.g., we don't offer contains(float) and similar methods with floating points on Rectanglei.
As I like the idea of testing based on properties and invariants here's what I got from the review of #23, plus a few additional things (as discussed on Discord with @pollend and @4Denthusiast):
Let A, B, C be rectangles, and let p be a point. Let ∅ denote an invalid rectangle without size.
-
isValid
-
lenght/area
- Rectanglei: number of discrete integer points
- count(rect.iterable) == rect.area == rect.sizeX * rect.sizeY
⚠️ Rectanglei is not iterable, and we cannot get the contained discrtete points...
-
contains/intersection
- iff p ∈ A && p ∈ B ⇒ p ∈ A ∩ B
- ∀ p ∈ A ∩ B ⇒ p ∈ A && p ∈ B
- B ⊆ A, p ∈ B ⇒ p ∈ A
- B ⊆ A, C ⊆ B ⇒ C ⊆ A
- maxₐ ∈ A, minₐ ∈ A (closed interval)
-
intersection
- A ∩ A == A
- A.intersects(B) == (A ∩ B ≠ ∅), where A.intersects(B) is the test for intersection
-
union
- A ⊆ (A ∪ B)
- B ⊆ (A ∪ B)
- A ∪ A == A
-
Rectangled/f
- bounds are inclusive
- we cannot count the points inside a rectangle, so the same test as above does not work
Currently, our primitives use a closed interval semantics, i.e., both min and max are included.
To avoid confusion about floating point rounding to integer domain we do not offer floating-point variants of methods on integer primitives, e.g., we don't offer
contains(float)and similar methods with floating points onRectanglei.As I like the idea of testing based on properties and invariants here's what I got from the review of #23, plus a few additional things (as discussed on Discord with @pollend and @4Denthusiast):
Let A, B, C be rectangles, and let p be a point. Let ∅ denote an invalid rectangle without size.
isValid
lenght/area
contains/intersection
intersection
union
Rectangled/f