zmath.aux

Some auxiliar math funtions

  • Declaration

    enum real M_1_180;

    Inverse of 180

  • Declaration

    pure nothrow @nogc @safe T clamp(T = float)(in T x) if (__traits(isFloating, T));

    Clamps a float point between -1.0 and +1.0

    Parameters

    T x

    Float point number to clamp Returns A flot point number clamped between -1.0 and 1.0

  • Declaration

    pure nothrow @nogc @safe T toRadians(T = float)(in T x) if (__traits(isFloating, T));

    Converts angles in degrees to radians

    Parameters

    T x

    Angle in grades Returns angle in radians

  • Declaration

    pure nothrow @nogc @safe T toDegrees(T = float)(in T x) if (__traits(isFloating, T));

    Converts angles in radians to degrees

    Parameters

    T x

    Angle in radians REturns angle in grades

  • Declaration

    int cmpFloat(T = float, U = float)(in T a, in U b, T maxRelDiff = 0.01, T maxAbsDiff = 1e-05);

    Compare two float point numbers with assuming that are equal if are in range of maxAbsDiff

    Parameters

    T a

    A float point number

    U b

    Other float point

    T maxRelDiff

    Max relative difference

    T maxAbsDiff

    Max absoulte difference Returns If a are aproximated equal that b, returns 0. Otherwise, if a > b, returns 1 and if a < b , returns -1;