use 4 space for indentation

This commit is contained in:
Martin Diehl 2020-02-21 10:53:44 +01:00
parent c84a6e90c9
commit 58610e23a7
1 changed files with 243 additions and 254 deletions

View File

@ -493,7 +493,6 @@ class Rotation:
ax = [ qu[1]*s, qu[2]*s, qu[3]*s, omega ] ax = [ qu[1]*s, qu[2]*s, qu[3]*s, omega ]
else: else:
ax = [ qu[1], qu[2], qu[3], np.pi] ax = [ qu[1], qu[2], qu[3], np.pi]
return np.array(ax) return np.array(ax)
@staticmethod @staticmethod
@ -504,14 +503,13 @@ class Rotation:
else: else:
s = np.linalg.norm([qu[1],qu[2],qu[3]]) s = np.linalg.norm([qu[1],qu[2],qu[3]])
ro = [0.0,0.0,P,0.0] if iszero(s) else \ ro = [0.0,0.0,P,0.0] if iszero(s) else \
[ qu[1]/s, qu[2]/s, qu[3]/s, np.tan(np.arccos(np.clip(qu[0],-1.0,1.0)))] # avoid numerical difficulties [ qu[1]/s, qu[2]/s, qu[3]/s, np.tan(np.arccos(np.clip(qu[0],-1.0,1.0)))]
return np.array(ro) return np.array(ro)
@staticmethod @staticmethod
def qu2ho(qu): def qu2ho(qu):
"""Quaternion to homochoric vector.""" """Quaternion to homochoric vector."""
omega = 2.0 * np.arccos(np.clip(qu[0],-1.0,1.0)) # avoid numerical difficulties omega = 2.0 * np.arccos(np.clip(qu[0],-1.0,1.0))
if iszero(omega): if iszero(omega):
ho = np.array([ 0.0, 0.0, 0.0 ]) ho = np.array([ 0.0, 0.0, 0.0 ])
@ -519,7 +517,6 @@ class Rotation:
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.)
return ho return ho
@staticmethod @staticmethod
@ -571,7 +568,6 @@ class Rotation:
ax[0:3] = np.real(vr[0:3,i]) ax[0:3] = np.real(vr[0:3,i])
diagDelta = np.array([om[1,2]-om[2,1],om[2,0]-om[0,2],om[0,1]-om[1,0]]) diagDelta = np.array([om[1,2]-om[2,1],om[2,0]-om[0,2],om[0,1]-om[1,0]])
ax[0:3] = np.where(iszero(diagDelta), ax[0:3],np.abs(ax[0:3])*np.sign(-P*diagDelta)) ax[0:3] = np.where(iszero(diagDelta), ax[0:3],np.abs(ax[0:3])*np.sign(-P*diagDelta))
return np.array(ax) return np.array(ax)
@staticmethod @staticmethod
@ -633,7 +629,6 @@ class Rotation:
ax = -P/tau * np.array([ t*np.cos(delta), t*np.sin(delta), np.sin(sigma) ]) # passive axis angle pair so a minus sign in front ax = -P/tau * np.array([ t*np.cos(delta), t*np.sin(delta), np.sin(sigma) ]) # passive axis angle pair so a minus sign in front
ax = np.append(ax,alpha) ax = np.append(ax,alpha)
if alpha < 0.0: ax *= -1.0 # ensure alpha is positive if alpha < 0.0: ax *= -1.0 # ensure alpha is positive
return ax return ax
@staticmethod @staticmethod
@ -646,7 +641,6 @@ class Rotation:
ro = np.array([ 0.0, 0.0, P, 0.0 ]) ro = np.array([ 0.0, 0.0, P, 0.0 ])
else: else:
ro[3] = np.tan(ro[3]*0.5) ro[3] = np.tan(ro[3]*0.5)
return ro return ro
@staticmethod @staticmethod
@ -670,7 +664,6 @@ class Rotation:
c = np.cos(ax[3]*0.5) c = np.cos(ax[3]*0.5)
s = np.sin(ax[3]*0.5) s = np.sin(ax[3]*0.5)
qu = np.array([ c, ax[0]*s, ax[1]*s, ax[2]*s ]) qu = np.array([ c, ax[0]*s, ax[1]*s, ax[2]*s ])
return qu return qu
@staticmethod @staticmethod
@ -685,7 +678,6 @@ class Rotation:
q = omc*ax[idx[0]] * ax[idx[1]] q = omc*ax[idx[0]] * ax[idx[1]]
om[idx[0],idx[1]] = q + s*ax[idx[2]] om[idx[0],idx[1]] = q + s*ax[idx[2]]
om[idx[1],idx[0]] = q - s*ax[idx[2]] om[idx[1],idx[0]] = q - s*ax[idx[2]]
return om if P < 0.0 else om.T return om if P < 0.0 else om.T
@staticmethod @staticmethod
@ -703,7 +695,6 @@ class Rotation:
# 180 degree case # 180 degree case
ro += [np.inf] if np.isclose(ax[3],np.pi,atol=1.0e-15,rtol=0.0) else \ ro += [np.inf] if np.isclose(ax[3],np.pi,atol=1.0e-15,rtol=0.0) else \
[np.tan(ax[3]*0.5)] [np.tan(ax[3]*0.5)]
return np.array(ro) return np.array(ro)
@staticmethod @staticmethod
@ -748,7 +739,6 @@ class Rotation:
angle = 2.0*np.arctan(ta) angle = 2.0*np.arctan(ta)
ta = 1.0/np.linalg.norm(ro[0:3]) ta = 1.0/np.linalg.norm(ro[0:3])
ax = [ ro[0]/ta, ro[1]/ta, ro[2]/ta, angle ] ax = [ ro[0]/ta, ro[1]/ta, ro[2]/ta, angle ]
return np.array(ax) return np.array(ax)
@staticmethod @staticmethod
@ -759,7 +749,6 @@ class Rotation:
else: else:
f = 2.0*np.arctan(ro[3]) -np.sin(2.0*np.arctan(ro[3])) if np.isfinite(ro[3]) else np.pi f = 2.0*np.arctan(ro[3]) -np.sin(2.0*np.arctan(ro[3])) if np.isfinite(ro[3]) else np.pi
ho = ro[0:3] * (0.75*f)**(1.0/3.0) ho = ro[0:3] * (0.75*f)**(1.0/3.0)
return np.array(ho) return np.array(ho)
@staticmethod @staticmethod