abandoned integer aliases for projection directions

This commit is contained in:
Philip Eisenlohr 2021-02-27 18:46:20 -05:00 committed by Sharan Roongta
parent 175d724ded
commit 464c62e7e7
1 changed files with 3 additions and 3 deletions

View File

@ -201,8 +201,8 @@ def project_stereographic(vector,direction='z',normalize=True,keepdims=False):
---------- ----------
vector : numpy.ndarray of shape (...,3) vector : numpy.ndarray of shape (...,3)
Vector coordinates to be projected. Vector coordinates to be projected.
direction : str or int direction : str
Projection direction 'x' | 0, 'y' | 1, or 'z' | 2. Projection direction 'x', 'y', or 'z'.
Defaults to 'z'. Defaults to 'z'.
normalize : bool normalize : bool
Ensure unit length of input vector. Defaults to True. Ensure unit length of input vector. Defaults to True.
@ -227,7 +227,7 @@ def project_stereographic(vector,direction='z',normalize=True,keepdims=False):
[0.41421356, 0] [0.41421356, 0]
""" """
shift = 2-('xyzXYZ'.index(direction)%3 if isinstance(direction,str) else int(direction)) shift = 'zyx'.index(direction)
v_ = np.roll(vector/np.linalg.norm(vector,axis=-1,keepdims=True) if normalize else vector, v_ = np.roll(vector/np.linalg.norm(vector,axis=-1,keepdims=True) if normalize else vector,
shift,axis=-1) shift,axis=-1)
return np.roll(np.block([v_[...,:2]/(1+np.abs(v_[...,2:3])),np.zeros_like(v_[...,2:3])]), return np.roll(np.block([v_[...,:2]/(1+np.abs(v_[...,2:3])),np.zeros_like(v_[...,2:3])]),