Function Bounds2.tryFromMinMax
Constructs a non-empty bounds from minimum and maximum corners.
Returns false when:
- either corner contains NaN; or - min is greater than max on any axis.
Infinities are permitted when the ordering invariant holds.
On failure, result is Bounds2.init.
Example
Example constructing bounds and rejecting reversed corners.
import geo;
alias P = Point2!double;
alias B = Bounds2!double;
B bounds;
assert(
B .tryFromMinMax(
P(1.0, 2.0),
P(4.0, 6.0),
bounds
)
);
assert(bounds .min == P(1.0, 2.0));
assert(bounds .max == P(4.0, 6.0));
assert(
!B .tryFromMinMax(
P(5.0, 2.0),
P(4.0, 6.0),
bounds
)
);
assert(bounds == B .init);