polygon2.of
A polygon from its corners in order, checked for count and finiteness.
Usage
Polygon2.of(points: readonly Point2[]): Result<Polygon2>Parameters
pointsreadonly Point2[]The corners in order, either orientation; a last point equal to the first is dropped. Required. In model.
Returns
Ok with a frozen polygon whose ring is copied from the points; its orientation is kept as given.
Errors
Guarantees
- cornerCount ≥ 3 and every coordinate of xy is finite
- points() equals the input, without a closing repeat
- The same result on every machine.
Use instead
polygon2.fromFlat: the corners are already a flat [x0, y0, …] array
Example
const r = Polygon2.of([Point2.of(0, 0), Point2.of(2, 0), Point2.of(0, 2)])
r.value.area() // → 2