added options to return "natural" versions of asQ, asRodrig, and asAxisAngle

This commit is contained in:
Philip Eisenlohr 2020-01-11 11:36:22 -05:00
parent ac112d2d36
commit 300f1b7015
1 changed files with 26 additions and 14 deletions

View File

@ -170,9 +170,18 @@ class Rotation:
################################################################################################ ################################################################################################
# convert to different orientation representations (numpy arrays) # convert to different orientation representations (numpy arrays)
def asQuaternion(self): def asQuaternion(self,
"""Unit quaternion: (q, p_1, p_2, p_3).""" quaternion = False):
return self.quaternion.asArray() """
Unit quaternion [q, p_1, p_2, p_3] unless quaternion == True: damask.quaternion object.
Parameters
----------
quaternion : bool, optional
return quaternion as DAMASK object.
"""
return self.quaternion if quaternion else self.quaternion.asArray()
def asEulers(self, def asEulers(self,
degrees = False): degrees = False):
@ -190,33 +199,36 @@ class Rotation:
return eu return eu
def asAxisAngle(self, def asAxisAngle(self,
degrees = False): degrees = False,
pair = False):
""" """
Axis angle pair: ([n_1, n_2, n_3], ω). Axis angle representation [n_1, n_2, n_3, ω] unless pair == True: ([n_1, n_2, n_3], ω).
Parameters Parameters
---------- ----------
degrees : bool, optional degrees : bool, optional
return rotation angle in degrees. return rotation angle in degrees.
pair : bool, optional
return tuple of axis and angle.
""" """
ax = qu2ax(self.quaternion.asArray()) ax = qu2ax(self.quaternion.asArray())
if degrees: ax[3] = np.degrees(ax[3]) if degrees: ax[3] = np.degrees(ax[3])
return ax return (ax[:3],np.degrees(ax[3])) if pair else ax
def asMatrix(self): def asMatrix(self):
"""Rotation matrix.""" """Rotation matrix."""
return qu2om(self.quaternion.asArray()) return qu2om(self.quaternion.asArray())
def asRodrigues(self, def asRodrigues(self,
vector=False): vector = False):
""" """
Rodrigues-Frank vector: ([n_1, n_2, n_3], tan(ω/2)). Rodrigues-Frank vector representation [n_1, n_2, n_3, tan(ω/2)] unless vector == True: [n_1, n_2, n_3] * tan(ω/2).
Parameters Parameters
---------- ----------
vector : bool, optional vector : bool, optional
return as array of length 3, i.e. scale the unit vector giving the rotation axis. return as actual Rodrigues--Frank vector, i.e. rotation axis scaled by tan(ω/2).
""" """
ro = qu2ro(self.quaternion.asArray()) ro = qu2ro(self.quaternion.asArray())