import math


def tthphi_to_gammanu(tth, phi):
    """Transfer ttheta-phi to gamma-nu."""
    gamma = math.atan2(math.cos(phi)*math.sin(tth), math.cos(tth))
    nu = math.asin(math.sin(tth)*math.sin(phi))
    return gamma, nu