diff --git a/python/damask/orientation.py b/python/damask/orientation.py index b19037b0c..aae96c8d6 100644 --- a/python/damask/orientation.py +++ b/python/damask/orientation.py @@ -227,12 +227,17 @@ class Rotation: return cls(ax2qu(ax)) @classmethod - def fromMatrix(cls, - matrix, - containsStretch = False): #ToDo: better name? + def fromBasis(cls, + basis, + orthonormal = True, + reciprocal = False, + ): - om = matrix if isinstance(matrix, np.ndarray) else np.array(matrix).reshape((3,3)) # ToDo: Reshape here or require explicit? - if containsStretch: + om = basis if isinstance(basis, np.ndarray) else np.array(basis).reshape((3,3)) + if reciprocal: + om = np.linalg.inv(om.T/np.pi) # transform reciprocal basis set + orthonormal = False # contains stretch + if not orthonormal: (U,S,Vh) = np.linalg.svd(om) # singular value decomposition om = np.dot(U,Vh) if not np.isclose(np.linalg.det(om),1.0): @@ -244,6 +249,13 @@ class Rotation: return cls(om2qu(om)) + @classmethod + def fromMatrix(cls, + om, + ): + + return cls.fromBasis(om) + @classmethod def fromRodrigues(cls, rodrigues,