improved converte, now with test
still needs to figure out how +P is handled
This commit is contained in:
parent
0d7fd587e3
commit
e88182b007
2
PRIVATE
2
PRIVATE
|
@ -1 +1 @@
|
||||||
Subproject commit 8deb37dd4526fb5e1425fe1d2360508d01b6ac3e
|
Subproject commit 144e729811024fd5f99225fa10b6d8fa40e7d492
|
|
@ -95,7 +95,7 @@ for name in filenames:
|
||||||
except:
|
except:
|
||||||
errors.append('Pointwise orientation data ({}) not found'.format(dataset))
|
errors.append('Pointwise orientation data ({}) not found'.format(dataset))
|
||||||
|
|
||||||
texture = [damask.Rotation.fromQuaternion(q,P=+1) for q in quats]
|
texture = [damask.Rotation.fromQuaternion(q,True,P=+1) for q in quats]
|
||||||
|
|
||||||
dataset = os.path.join(group_pointwise,options.phase)
|
dataset = os.path.join(group_pointwise,options.phase)
|
||||||
try:
|
try:
|
||||||
|
@ -118,7 +118,7 @@ for name in filenames:
|
||||||
|
|
||||||
dataset = os.path.join(group_average,options.quaternion)
|
dataset = os.path.join(group_average,options.quaternion)
|
||||||
try:
|
try:
|
||||||
texture = [damask.Rotation.fromQuaternion(q,P=+1) for q in inFile[dataset][...][1:]] # skip first entry (unindexed)
|
texture = [damask.Rotation.fromQuaternion(q,True,P=+1) for q in inFile[dataset][...][1:]] # skip first entry (unindexed)
|
||||||
except:
|
except:
|
||||||
errors.append('Average orientation data ({}) not found'.format(dataset))
|
errors.append('Average orientation data ({}) not found'.format(dataset))
|
||||||
|
|
||||||
|
|
|
@ -301,12 +301,16 @@ class Rotation:
|
||||||
@classmethod
|
@classmethod
|
||||||
def fromQuaternion(cls,
|
def fromQuaternion(cls,
|
||||||
quaternion,
|
quaternion,
|
||||||
|
acceptHomomorph = False,
|
||||||
P = -1):
|
P = -1):
|
||||||
|
|
||||||
qu = quaternion if isinstance(quaternion, np.ndarray) else np.array(quaternion)
|
qu = quaternion if isinstance(quaternion, np.ndarray) else np.array(quaternion)
|
||||||
if P > 0: qu[1:4] *= -1 # convert from P=1 to P=-1
|
if P > 0: qu[1:4] *= -1 # convert from P=1 to P=-1
|
||||||
if qu[0] < 0.0:
|
if qu[0] < 0.0:
|
||||||
raise ValueError('Quaternion has negative first component.\n{}'.format(qu[0]))
|
if acceptHomomorph:
|
||||||
|
qu *= -1.
|
||||||
|
else:
|
||||||
|
raise ValueError('Quaternion has negative first component.\n{}'.format(qu[0]))
|
||||||
if not np.isclose(np.linalg.norm(qu), 1.0):
|
if not np.isclose(np.linalg.norm(qu), 1.0):
|
||||||
raise ValueError('Quaternion is not of unit length.\n{} {} {} {}'.format(*qu))
|
raise ValueError('Quaternion is not of unit length.\n{} {} {} {}'.format(*qu))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue