This commit is contained in:
Martin Diehl 2020-05-17 08:01:34 +02:00
parent 743e91a78d
commit a25dd1c438
2 changed files with 11 additions and 11 deletions

View File

@ -35,8 +35,8 @@ class Rotation:
-----
Vector "a" (defined in coordinate system "A") is passively rotated
resulting in new coordinates "b" when expressed in system "B".
b = Q * a
b = np.dot(Q.asMatrix(),a)
b = Q @ a
b = np.dot(Q.as_matrix(),a)
"""
@ -73,8 +73,8 @@ class Rotation:
raise NotImplementedError('Support for multiple rotations missing')
return '\n'.join([
'Quaternion: (real={:.3f}, imag=<{:+.3f}, {:+.3f}, {:+.3f}>)'.format(*(self.quaternion)),
'Matrix:\n{}'.format(self.asMatrix()),
'Bunge Eulers / deg: ({:3.2f}, {:3.2f}, {:3.2f})'.format(*self.asEulers(degrees=True)),
'Matrix:\n{}'.format(self.as_matrix()),
'Bunge Eulers / deg: ({:3.2f}, {:3.2f}, {:3.2f})'.format(*self.as_Eulers(degrees=True)),
])
@ -112,9 +112,9 @@ class Rotation:
return A*other + B*self.quaternion[1:] + C * np.cross(self.quaternion[1:],other)
elif other.shape == (3,3,):
return np.dot(self.asMatrix(),np.dot(other,self.asMatrix().T))
return np.dot(self.as_matrix(),np.dot(other,self.as_matrix().T))
elif other.shape == (3,3,3,3,):
R = self.asMatrix()
R = self.as_matrix()
return np.einsum('...im,...jn,...ko,...lp,...mnop',R,R,R,R,other)
else:
raise ValueError('Can only rotate vectors, 2nd order ternsors, and 4th order tensors')
@ -150,10 +150,10 @@ class Rotation:
- p_m[...,(i+2)%3]*other[...,(i+1)%3])).reshape(self.shape+(1,))
for i in [0,1,2]])
if self.shape + (3,3) == other.shape:
R = self.asMatrix()
R = self.as_matrix()
return np.einsum('...im,...jn,...mn',R,R,other)
if self.shape + (3,3,3,3) == other.shape:
R = self.asMatrix()
R = self.as_matrix()
return np.einsum('...im,...jn,...ko,...lp,...mnop',R,R,R,R,other)
else:
raise ValueError('Can only rotate vectors, 2nd order ternsors, and 4th order tensors')
@ -654,8 +654,8 @@ class Rotation:
def om2ax(om):
"""Rotation matrix to axis angle pair."""
diag_delta = -_P*np.block([om[...,1,2:3]-om[...,2,1:2],
om[...,2,0:1]-om[...,0,2:3],
om[...,0,1:2]-om[...,1,0:1]
om[...,2,0:1]-om[...,0,2:3],
om[...,0,1:2]-om[...,1,0:1]
])
diag_delta[np.abs(diag_delta)<1.e-6] = 1.0
t = 0.5*(om.trace(axis2=-2,axis1=-1) -1.0).reshape(om.shape[:-2]+(1,))

View File

@ -51,7 +51,7 @@ class TestOrientation:
def test_relationship_reference(self,update,reference_dir,model,lattice):
reference = os.path.join(reference_dir,'{}_{}.txt'.format(lattice,model))
ori = Orientation(Rotation(),lattice)
eu = np.array([o.rotation.asEulers(degrees=True) for o in ori.relatedOrientations(model)])
eu = np.array([o.rotation.as_Eulers(degrees=True) for o in ori.relatedOrientations(model)])
if update:
coords = np.array([(1,i+1) for i,x in enumerate(eu)])
table = damask.Table(eu,{'Eulers':(3,)})