using rotation class for rotations

This commit is contained in:
Martin Diehl 2020-05-25 09:39:39 +02:00
parent 39505507f1
commit 77b68ab86f
2 changed files with 5 additions and 9 deletions

View File

@ -32,15 +32,12 @@ parser.add_option('--depth', dest='depth', metavar='string',
if filenames == []: filenames = [None]
if options.frame is None:
parser.error('frame not specified')
parser.error('frame not specified')
if options.depth is None:
parser.error('depth not specified')
parser.error('depth not specified')
theta=-0.75*np.pi
RotMat2TSL=np.array([[1., 0., 0.],
[0., np.cos(theta), np.sin(theta)], # Orientation to account for -135 deg
[0., -np.sin(theta), np.cos(theta)]]) # rotation for TSL convention
rot_to_TSL = damask.Rotation.from_axis_angle([-1,0,0,.75*np.pi])
for name in filenames:
damask.util.report(scriptName,name)
@ -50,8 +47,6 @@ for name in filenames:
coord = - table.get(options.frame)
coord[:,2] += table.get(options.depth)[:,0]
table.add('coord',
np.einsum('ijk,ik->ij',np.broadcast_to(RotMat2TSL,(coord.shape[0],3,3)),coord),
scriptID+' '+' '.join(sys.argv[1:]))
table.add('coord',rot_to_TSL.broadcast_to(coord.shape[0]) @ coord,scriptID+' '+' '.join(sys.argv[1:]))
table.to_ASCII(sys.stdout if name is None else name)

View File

@ -157,6 +157,7 @@ class Rotation:
def broadcast_to(self,shape):
if isinstance(shape,int): shape = (shape,)
if self.shape == ():
q = np.broadcast_to(self.quaternion,shape+(4,))
else: