rotation paper has angle as last component

This commit is contained in:
Martin Diehl 2019-02-12 10:53:28 +01:00
parent 7da8980cc0
commit 608852df83
4 changed files with 17 additions and 12 deletions

View File

@ -108,8 +108,11 @@ if np.sum(input) != 1: parser.error('needs exactly one input format.')
(options.quaternion,representations['quaternion'][1],'quaternion'), (options.quaternion,representations['quaternion'][1],'quaternion'),
][np.where(input)[0][0]] # select input label that was requested ][np.where(input)[0][0]] # select input label that was requested
r = damask.Rotation.fromAngleAxis(options.crystalrotation,options.degrees) # crystal frame rotation crystalrotation = np.array(options.crystalrotation[1:4] + (options.crystalrotation[0],)) # Compatibility hack
R = damask.Rotation.fromAngleAxis(options.labrotation,options.degrees) # lab frame rotation 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 ------------------------------------------------------------------------ # --- loop over input files ------------------------------------------------------------------------

View File

@ -40,7 +40,8 @@ parser.set_defaults(rotation = (0.,1.,0.,0.),
if options.data is None: if options.data is None:
parser.error('no data column specified.') 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 ------------------------------------------------------------------------- # --- loop over input files -------------------------------------------------------------------------

View File

@ -63,7 +63,8 @@ parser.set_defaults(center = (.0,.0,.0),
if options.dimension is None: if options.dimension is None:
parser.error('no dimension specified.') parser.error('no dimension specified.')
if options.angleaxis is not None: 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: elif options.quaternion is not None:
rotation = damask.Rotation.fromQuaternion(options.quaternion) rotation = damask.Rotation.fromQuaternion(options.quaternion)
else: else:

View File

@ -267,7 +267,7 @@ class Rotation:
degrees = False): degrees = False):
ax = qu2ax(self.quaternion.asArray()) ax = qu2ax(self.quaternion.asArray())
if degrees: ax[0] = np.degrees(ax[0]) if degrees: ax[3] = np.degrees(ax[3])
return ax return ax
@ -321,13 +321,13 @@ class Rotation:
P = -1): P = -1):
ax = angleAxis if isinstance(angleAxis, np.ndarray) else np.array(angleAxis) 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 P > 0: ax[0:3] *= -1 # convert from P=1 to P=-1
if degrees: ax[0] = np.radians(ax[0]) if degrees: ax[3] = np.radians(ax[3])
if normalise: ax[1:4] /=np.linalg.norm(ax[1:4]) if normalise: ax[0:3] /=np.linalg.norm(ax[0:3])
if ax[0] < 0.0 or ax[0] > np.pi: if ax[3] < 0.0 or ax[3] > np.pi:
raise ValueError('Axis angle rotation angle outside of [0..π].\n'.format(ax[0])) raise ValueError('Axis angle rotation angle outside of [0..π].\n'.format(ax[3]))
if not np.isclose(np.linalg.norm(ax[1:4]), 1.0): 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[1:4])) raise ValueError('Axis angle rotation axis is not of unit length.\n{} {} {}'.format(*ax[0:3]))
return cls(ax2qu(ax)) return cls(ax2qu(ax))