def v3is_within_tolerance(a, b, tolerance):
    if v3is_zero(a): # Should we test b is_zero as well?
        return True
    dot = v3dot(a, b)
    if dot < 0:
        return False
    if (dot * dot) < (v3lengthsq(a) * v3lengthsq(b) * tolerance):
        return False
    return True
The tolerance must be defined as the square of the cosine angle tolerated. Returns True is 'a' is zero.
dataset/ETHPy150Open turbulenz/turbulenz_tools/turbulenz_tools/tools/vmath.py/v3is_within_tolerance