assumed wrong type

quaternion should have lenght one
This commit is contained in:
Martin Diehl 2018-12-09 12:35:32 +01:00
parent 697d97cd38
commit 65165ffc5e
1 changed files with 6 additions and 4 deletions

View File

@ -14,21 +14,23 @@ scriptID = ' '.join([scriptName,damask.version])
# --------------------------------------------------------------------
def check_Eulers(eulers):
if np.any(eulers < 0.0) or np.any(eulers > 2.0*math.pi) or eulers[1] > math.pi: # Euler angles within valid range?
if np.any(eulers < 0.0) or np.any(eulers > 2.0*math.pi) or eulers[1] > math.pi: # Euler angles within valid range?
raise ValueError('Euler angles outside of [0..2π],[0..π],[0..2π].\n{} {} {}.'.format(*eulers))
return eulers
def check_quaternion(q):
if q.q < 0.0: # positive first quaternion component?
if q[0] < 0.0: # positive first quaternion component?
raise ValueError('quaternion has negative first component.\n{}'.format(q))
if not(np.isclose(np.linalg.norm(q), 1.0)): # unit quaternion?
raise ValueError('quaternion is not of unit length.\n{} {} {} {}'.format(*q))
return q
def check_matrix(M):
if abs(1.0-np.linalg.det(M)) > 1e-8: # proper rotation?
if abs(1.0-np.linalg.det(M)) > 1e-8: # proper rotation?
raise ValueError('matrix is not a proper rotation.\n{}'.format(M))
if abs(np.dot(M[0],M[1])) > 1e-8 \
or abs(np.dot(M[1],M[2])) > 1e-8 \
or abs(np.dot(M[2],M[0])) > 1e-8: # all orthogonal?
or abs(np.dot(M[2],M[0])) > 1e-8: # all orthogonal?
raise ValueError('matrix is not orthogonal.\n{}'.format(M))
return M