import logging
import math


def cosine_law(a,b,c):
    """
    law of cosine

    :param a: distance1
    :param b: distance2
    :param c: distance3
    :return: angle in C-A-B
    """
    if not (a>1E-5 and b>1E-5):
        logging.warn("Found very small distance: a: %6.3f b: %6.3f"%(a,b))
    acosy = min(max(-1.0,(a**2+b**2-c**2)/(2*a*b)),1.0)
    acosy = math.acos(acosy)
    return(acosy)