similar style as for other conversions
This commit is contained in:
parent
04fbc38a4b
commit
3d10266fbc
|
@ -52,8 +52,6 @@ def cube_to_ball(cube):
|
|||
|
||||
"""
|
||||
cube_ = np.clip(cube,None,np.pi**(2./3.) * 0.5) if np.isclose(np.abs(np.max(cube)),np.pi**(2./3.) * 0.5,atol=1e-6) else cube
|
||||
if np.abs(np.max(cube_))>np.pi**(2./3.) * 0.5:
|
||||
raise ValueError('Coordinate outside of the cube: {} {} {}.'.format(*cube))
|
||||
|
||||
# transform to the sphere grid via the curved square, and intercept the zero point
|
||||
if np.allclose(cube_,0.0,rtol=0.0,atol=1.0e-16):
|
||||
|
@ -105,8 +103,6 @@ def ball_to_cube(ball):
|
|||
"""
|
||||
ball_ = ball/np.linalg.norm(ball)*R1 if np.isclose(np.linalg.norm(ball),R1,atol=1e-6) else ball
|
||||
rs = np.linalg.norm(ball_)
|
||||
if rs > R1+1.e-9:
|
||||
raise ValueError('Coordinate outside of the sphere: {} {} {}.'.format(*ball))
|
||||
|
||||
if np.allclose(ball_,0.0,rtol=0.0,atol=1.0e-16):
|
||||
cube = np.zeros(3)
|
||||
|
|
|
@ -350,6 +350,9 @@ class Rotation:
|
|||
else np.array(homochoric,dtype=float)
|
||||
if P > 0: ho *= -1 # convert from P=1 to P=-1
|
||||
|
||||
if np.linalg.norm(ho) > (3.*np.pi/4.)**(1./3.)+1e-9:
|
||||
raise ValueError('Coordinate outside of the sphere: {} {} {}.'.format(ho))
|
||||
|
||||
return Rotation(Rotation.ho2qu(ho))
|
||||
|
||||
@staticmethod
|
||||
|
@ -358,6 +361,10 @@ class Rotation:
|
|||
|
||||
cu = cubochoric if isinstance(cubochoric, np.ndarray) and cubochoric.dtype == np.dtype(float) \
|
||||
else np.array(cubochoric,dtype=float)
|
||||
|
||||
if np.abs(np.max(cu))>np.pi**(2./3.) * 0.5+1e-9:
|
||||
raise ValueError('Coordinate outside of the cube: {} {} {}.'.format(*cu))
|
||||
|
||||
ho = Rotation.cu2ho(cu)
|
||||
if P > 0: ho *= -1 # convert from P=1 to P=-1
|
||||
|
||||
|
|
Loading…
Reference in New Issue