polishing
This commit is contained in:
parent
c57f96cd6e
commit
c0c37fe6a5
|
@ -502,7 +502,7 @@ class Rotation:
|
||||||
np.ones( qu.shape[:-1]+(1,))*np.pi,
|
np.ones( qu.shape[:-1]+(1,))*np.pi,
|
||||||
np.zeros(qu.shape[:-1]+(1,))]),
|
np.zeros(qu.shape[:-1]+(1,))]),
|
||||||
eu) # TODO: Where can be nested
|
eu) # TODO: Where can be nested
|
||||||
# reduce Euler angles to definition range, i.e a lower limit of 0.0
|
# reduce Euler angles to definition range
|
||||||
eu[np.abs(eu)<1.e-6] = 0.0
|
eu[np.abs(eu)<1.e-6] = 0.0
|
||||||
eu = np.where(eu<0, (eu+2.0*np.pi)%np.array([2.0*np.pi,np.pi,2.0*np.pi]),eu)
|
eu = np.where(eu<0, (eu+2.0*np.pi)%np.array([2.0*np.pi,np.pi,2.0*np.pi]),eu)
|
||||||
return eu
|
return eu
|
||||||
|
@ -559,10 +559,10 @@ class Rotation:
|
||||||
def qu2ho(qu):
|
def qu2ho(qu):
|
||||||
"""Quaternion to homochoric vector."""
|
"""Quaternion to homochoric vector."""
|
||||||
if len(qu.shape) == 1:
|
if len(qu.shape) == 1:
|
||||||
if np.isclose(qu[0],1.0):
|
omega = 2.0 * np.arccos(np.clip(qu[0],-1.0,1.0))
|
||||||
|
if np.abs(omega) < 1.0e-12:
|
||||||
ho = np.zeros(3)
|
ho = np.zeros(3)
|
||||||
else:
|
else:
|
||||||
omega = 2.0 * np.arccos(np.clip(qu[0],-1.0,1.0))
|
|
||||||
ho = np.array([qu[1], qu[2], qu[3]])
|
ho = np.array([qu[1], qu[2], qu[3]])
|
||||||
f = 0.75 * ( omega - np.sin(omega) )
|
f = 0.75 * ( omega - np.sin(omega) )
|
||||||
ho = ho/np.linalg.norm(ho) * f**(1./3.)
|
ho = ho/np.linalg.norm(ho) * f**(1./3.)
|
||||||
|
|
|
@ -167,7 +167,7 @@ class TestRotation:
|
||||||
conversion(qu.reshape(qu.shape[0]//2,-1,4))
|
conversion(qu.reshape(qu.shape[0]//2,-1,4))
|
||||||
co = conversion(qu)
|
co = conversion(qu)
|
||||||
for q,c in zip(qu,co):
|
for q,c in zip(qu,co):
|
||||||
#print(q,c)
|
print(q,c)
|
||||||
assert np.allclose(conversion(q),c)
|
assert np.allclose(conversion(q),c)
|
||||||
|
|
||||||
@pytest.mark.parametrize('conversion',[Rotation.om2qu,
|
@pytest.mark.parametrize('conversion',[Rotation.om2qu,
|
||||||
|
|
Loading…
Reference in New Issue