def TDL(AN, BN):
    """
    Helper function for MT2Plane.

    Adapted from MATLAB script
    `bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_
    written by Andy Michael and Oliver Boyd.
    """
    XN = AN[0]
    YN = AN[1]
    ZN = AN[2]
    XE = BN[0]
    YE = BN[1]
    ZE = BN[2]
    AAA = 1.0 / (1000000)
    CON = 57.2957795
    if np.fabs(ZN) < AAA:
        FD = 90.
        AXN = np.fabs(XN)
        if AXN > 1.0:
            AXN = 1.0
        FT = np.arcsin(AXN) * CON
        ST = -XN
        CT = YN
        if ST >= 0. and CT < 0:
            FT = 180. - FT
        if ST < 0. and CT <= 0:
            FT = 180. + FT
        if ST < 0. and CT > 0:
            FT = 360. - FT
        FL = np.arcsin(abs(ZE)) * CON
        SL = -ZE
        if np.fabs(XN) < AAA:
            CL = XE / YN
        else:
            CL = -YE / XN
        if SL >= 0. and CL < 0:
            FL = 180. - FL
        if SL < 0. and CL <= 0:
            FL = FL - 180.
        if SL < 0. and CL > 0:
            FL = -FL
    else:
        if - ZN > 1.0:
            ZN = -1.0
        FDH = np.arccos(-ZN)
        FD = FDH * CON
        SD = np.sin(FDH)
        if SD == 0:
            return
        ST = -XN / SD
        CT = YN / SD
        SX = np.fabs(ST)
        if SX > 1.0:
            SX = 1.0
        FT = np.arcsin(SX) * CON
        if ST >= 0. and CT < 0:
            FT = 180. - FT
        if ST < 0. and CT <= 0:
            FT = 180. + FT
        if ST < 0. and CT > 0:
            FT = 360. - FT
        SL = -ZE / SD
        SX = np.fabs(SL)
        if SX > 1.0:
            SX = 1.0
        FL = np.arcsin(SX) * CON
        if ST == 0:
            CL = XE / CT
        else:
            XXX = YN * ZN * ZE / SD / SD + YE
            CL = -SD * XXX / XN
            if CT == 0:
                CL = YE / ST
        if SL >= 0. and CL < 0:
            FL = 180. - FL
        if SL < 0. and CL <= 0:
            FL = FL - 180.
        if SL < 0. and CL > 0:
            FL = -FL
    return (FT, FD, FL)
def TDL ( AN , BN ) : XN = AN [ 0 ] YN = AN [ 1 ] ZN = AN [ 2 ] XE = BN [ 0 ] YE = BN [ 1 ] ZE = BN [ 2 ] AAA = 1.0 / ( 1000000 ) CON = 57.2957795 if np . fabs ( ZN ) < AAA : FD = 90. AXN = np . fabs ( XN ) if AXN > 1.0 : AXN = 1.0 FT = np . arcsin ( AXN ) * CON ST = - XN CT = YN if ST >= 0. and CT < 0 : FT = 180. - FT if ST < 0. and CT <= 0 : FT = 180. + FT if ST < 0. and CT > 0 : FT = 360. - FT FL = np . arcsin ( abs ( ZE ) ) * CON SL = - ZE if np . fabs ( XN ) < AAA : CL = XE / YN else : CL = - YE / XN if SL >= 0. and CL < 0 : FL = 180. - FL if SL < 0. and CL <= 0 : FL = FL - 180. if SL < 0. and CL > 0 : FL = - FL else : if - ZN > 1.0 : ZN = - 1.0 FDH = np . arccos ( - ZN ) FD = FDH * CON SD = np . sin ( FDH ) if SD == 0 : return ST = - XN / SD CT = YN / SD SX = np . fabs ( ST ) if SX > 1.0 : SX = 1.0 FT = np . arcsin ( SX ) * CON if ST >= 0. and CT < 0 : FT = 180. - FT if ST < 0. and CT <= 0 : FT = 180. + FT if ST < 0. and CT > 0 : FT = 360. - FT SL = - ZE / SD SX = np . fabs ( SL ) if SX > 1.0 : SX = 1.0 FL = np . arcsin ( SX ) * CON if ST == 0 : CL = XE / CT else : XXX = YN * ZN * ZE / SD / SD + YE CL = - SD * XXX / XN if CT == 0 : CL = YE / ST if SL >= 0. and CL < 0 : FL = 180. - FL if SL < 0. and CL <= 0 : FL = FL - 180. if SL < 0. and CL > 0 : FL = - FL return ( FT , FD , FL )
Helper function for MT2Plane.

    Adapted from MATLAB script
    `bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_
    written by Andy Michael and Oliver Boyd.