-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Already implemented and tested in python
def find_alpha_and_phi(dpx, dpy):
absphi = np.sqrt(dpx ** 2 + dpy ** 2) / 2.0
if absphi < 1e-20:
phi = absphi
alpha = 0.0
else:
if dpy>=0.:
if dpx>=0:
# First quadrant
if np.abs(dpx) >= np.abs(dpy):
# First octant
phi = absphi
alpha = np.arctan(dpy/dpx)
else:
# Second octant
phi = absphi
alpha = 0.5*np.pi - np.arctan(dpx/dpy)
else: #dpx<0
# Second quadrant
if np.abs(dpx) < np.abs(dpy):
# Third octant
phi = absphi
alpha = 0.5*np.pi - np.arctan(dpx/dpy)
else:
# Forth octant
phi = -absphi
alpha = np.arctan(dpy/dpx)
else: #dpy<0
if dpx<=0:
# Third quadrant
if np.abs(dpx) >= np.abs(dpy):
# Fifth octant
phi = -absphi
alpha = np.arctan(dpy/dpx)
else:
# Sixth octant
phi = -absphi
alpha = 0.5*np.pi - np.arctan(dpx/dpy)
else: #dpx>0
# Forth quadrant
if np.abs(dpx) <= np.abs(dpy):
# Seventh octant
phi = -absphi
alpha = 0.5*np.pi - np.arctan(dpx/dpy)
else:
# Eighth octant
phi = absphi
alpha = np.arctan(dpy/dpx)
return alpha, phi
Metadata
Metadata
Assignees
Labels
No labels