import numpy as np

def spherical_coords(theta, phi):
    """
    given theta and phi, returns the corresponding Cartesian vector """
    theta *= 2*np.pi/360
    phi *= 2*np.pi/360
    r=1
    x=r*np.sin(theta)*np.cos(phi)
    y=r*np.sin(theta)*np.sin(phi)
    z=r*np.cos(theta)
    r = np.array([x,y,z])
    return r

def find_orthog(u1, u2):
    """
    Given two Cartesian vectors, find the vector that is orthogonal to both
    Arguments:
        u1: vector 1 [x,y,z]
        u2: vector 2 [x,y,z]
    Returns:
        theta, phi (oxford magnet basis)"""
    u3 = np.cross(u1, u2)
    theta = np.arccos(u3[2])/np.linalg.norm(u3)
    phi = np.arctan(u3[1]/u3[0])
    return theta, phi
    
