Function Ellipsoid.trySphere

Construct a sphere without throwing; radius must be finite and positive.

static bool trySphere(
  const T radius,
  out Ellipsoid result
) pure nothrow @nogc @safe;

Parameters

NameDescription
radius Finite positive radius in the caller-selected linear unit.
result Receives the constructed sphere on success.

Returns

true on success; false for a non-positive or non-finite radius. On failure result is initialized to .init on entry and has no guaranteed value on failure.

Example

Example checking spherical construction without throwing.

import geodesy;
Ellipsoid!double sphere;
assert(Ellipsoid!double.trySphere(6_371_000.0, sphere));
assert(sphere.flattening == 0.0);