Function Angle.tryFromDegrees

Make an angle from degrees without throwing.

static bool tryFromDegrees(
  const T degrees,
  out Angle result
) pure nothrow @nogc @safe;

Use this when the angle comes from input data that may be invalid. The result holds radians internally; read .degrees to get degrees.

Parameters

NameDescription
degrees Finite angle in degrees.
result Receives the constructed angle on success.

Returns

true on success; false for NaN, infinity, or when conversion to scalar T does not produce a finite radian value. On failure result is initialized to .init on entry and has no guaranteed value on failure.

Example

Example checking degree input without throwing.

import geodesy;
Angle!double angle;
assert(Angle!double.tryFromDegrees(90.0, angle));
assert(angle.degrees == 90.0);