From 608852df839498244e3591ef9170d260f2948b95 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 12 Feb 2019 10:53:28 +0100 Subject: [PATCH] rotation paper has angle as last component --- processing/post/addOrientations.py | 7 +++++-- processing/post/rotateData.py | 3 ++- processing/pre/geom_addPrimitive.py | 3 ++- python/damask/orientation.py | 16 ++++++++-------- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/processing/post/addOrientations.py b/processing/post/addOrientations.py index 8353e0403..c25bfed39 100755 --- a/processing/post/addOrientations.py +++ b/processing/post/addOrientations.py @@ -108,8 +108,11 @@ if np.sum(input) != 1: parser.error('needs exactly one input format.') (options.quaternion,representations['quaternion'][1],'quaternion'), ][np.where(input)[0][0]] # select input label that was requested -r = damask.Rotation.fromAngleAxis(options.crystalrotation,options.degrees) # crystal frame rotation -R = damask.Rotation.fromAngleAxis(options.labrotation,options.degrees) # lab frame rotation +crystalrotation = np.array(options.crystalrotation[1:4] + (options.crystalrotation[0],)) # Compatibility hack +labrotation = np.array(options.labrotation[1:4], + (options.labrotation[0],)) # Compatibility hack +r = damask.Rotation.fromAngleAxis(crystalrotation,options.degrees) # crystal frame rotation +R = damask.Rotation.fromAngleAxis(labrotation,options.degrees) # lab frame rotation + # --- loop over input files ------------------------------------------------------------------------ diff --git a/processing/post/rotateData.py b/processing/post/rotateData.py index 1aafe7eb9..5be38f1e8 100755 --- a/processing/post/rotateData.py +++ b/processing/post/rotateData.py @@ -40,7 +40,8 @@ parser.set_defaults(rotation = (0.,1.,0.,0.), if options.data is None: parser.error('no data column specified.') -r = damask.Rotation.fromAngleAxis(options.rotation,options.degrees,normalise=True) +rotation = np.array(options.rotation[1:4]+(options.rotation[0],)) # Compatibility hack +r = damask.Rotation.fromAngleAxis(rotation,options.degrees,normalise=True) # --- loop over input files ------------------------------------------------------------------------- diff --git a/processing/pre/geom_addPrimitive.py b/processing/pre/geom_addPrimitive.py index e0d1094cf..8e512c44d 100755 --- a/processing/pre/geom_addPrimitive.py +++ b/processing/pre/geom_addPrimitive.py @@ -63,7 +63,8 @@ parser.set_defaults(center = (.0,.0,.0), if options.dimension is None: parser.error('no dimension specified.') if options.angleaxis is not None: - rotation = damask.Rotation.fromAngleAxis(options.angleaxis,options.degrees,normalise=True) + ax = np.array(options.angleaxis[1:4] + (options.angleaxis[0],)) # Compatibility hack + rotation = damask.Rotation.fromAngleAxis(ax,options.degrees,normalise=True) elif options.quaternion is not None: rotation = damask.Rotation.fromQuaternion(options.quaternion) else: diff --git a/python/damask/orientation.py b/python/damask/orientation.py index 85f3fb173..442a98f6e 100644 --- a/python/damask/orientation.py +++ b/python/damask/orientation.py @@ -267,7 +267,7 @@ class Rotation: degrees = False): ax = qu2ax(self.quaternion.asArray()) - if degrees: ax[0] = np.degrees(ax[0]) + if degrees: ax[3] = np.degrees(ax[3]) return ax @@ -321,13 +321,13 @@ class Rotation: P = -1): ax = angleAxis if isinstance(angleAxis, np.ndarray) else np.array(angleAxis) - if P > 0: ax[1:4] *= -1 # convert from P=1 to P=-1 - if degrees: ax[0] = np.radians(ax[0]) - if normalise: ax[1:4] /=np.linalg.norm(ax[1:4]) - if ax[0] < 0.0 or ax[0] > np.pi: - raise ValueError('Axis angle rotation angle outside of [0..π].\n'.format(ax[0])) - if not np.isclose(np.linalg.norm(ax[1:4]), 1.0): - raise ValueError('Axis angle rotation axis is not of unit length.\n{} {} {}'.format(*ax[1:4])) + if P > 0: ax[0:3] *= -1 # convert from P=1 to P=-1 + if degrees: ax[3] = np.radians(ax[3]) + if normalise: ax[0:3] /=np.linalg.norm(ax[0:3]) + if ax[3] < 0.0 or ax[3] > np.pi: + raise ValueError('Axis angle rotation angle outside of [0..π].\n'.format(ax[3])) + if not np.isclose(np.linalg.norm(ax[0:3]), 1.0): + raise ValueError('Axis angle rotation axis is not of unit length.\n{} {} {}'.format(*ax[0:3])) return cls(ax2qu(ax))