INNER CODE UNIT · Python

nstr_fixed

TheOpenSpaceProgram/osp-magnum · scripts/icosahedron_tables.py:28

def nstr_fixed(value, sigfigs):
    value = mpmathify(value);
    if value == 0.0:
        # mpmath would intentionally output 0.0e+0 otherwise for some reason
        return " 0.000000000000000e+0"
    return (" " if value > 0 else "") + nstr(mpmathify(value), sigfigs, min_fixed=1, max_fixed=0, show_zero_exponent=True, strip_zeros=False);

def nstr_double(value):
    return nstr_fixed(value, 16)

def nstr_float(value):
    return nstr_fixed(value, 9) + "f"

def mid(a, b):
    return (0.5*(a[0]+b[0]), 0.5*(a[1]+b[1]), 0.5*(a[2]+b[2]))

def mag(a):
    return sqrt(a[0]*a[0] + a[1]*a[1] + a[2]*a[2])

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…