Function Bounds2.tryExtend

Extends this bounds so that it contains p.

bool tryExtend(
  Point2!T p
) pure nothrow @nogc @safe;

Returns false when p contains NaN.

On failure, this bounds remains unchanged.

Example

Example extending bounds transactionally by a point.

import geo;

alias P = Point2!double;
alias B = Bounds2!double;

B bounds;

assert(bounds.tryExtend(P(5.0, 4.0)));
assert(bounds.tryExtend(P(1.0, 7.0)));

assert(bounds.min == P(1.0, 4.0));
assert(bounds.max == P(5.0, 7.0));

const before = bounds;

assert(
    !bounds.tryExtend(
        P(double.nan, 10.0)
    )
);

assert(bounds == before);