Function Bounds2.tryFromMinMax

Constructs a non-empty bounds from minimum and maximum corners.

static bool tryFromMinMax(
  Point2!T minimum,
  Point2!T maximum,
  out Bounds2 result
) pure nothrow @nogc @safe;

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);