From 34adefd4ca6a5c90d38ab701d2015d074f805523 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 24 May 2020 18:30:45 +0200 Subject: [PATCH] simplified --- python/damask/_geom.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/python/damask/_geom.py b/python/damask/_geom.py index bfba3465b..57ab5b3b1 100644 --- a/python/damask/_geom.py +++ b/python/damask/_geom.py @@ -590,23 +590,23 @@ class Geom: dtype = float if np.isnan(fill) or int(fill) != fill or self.microstructure.dtype==np.float else int Eulers = R.as_Eulers(degrees=True) - # These rotations are always applied in the reference coordinate system, i.e. (z,x,z) not (z,x',z'') - # this seems to be ok, see https://www.cs.utexas.edu/~theshark/courses/cs354/lectures/cs354-14.pdf - microstructure = ndimage.rotate(self.microstructure,Eulers[2],(0,1),order=0, - prefilter=False,output=dtype,cval=fill) # rotation around z - microstructure = ndimage.rotate(microstructure,Eulers[1],(1,2),order=0, - prefilter=False,output=dtype,cval=fill) # rotation around x - microstructure = ndimage.rotate(microstructure,Eulers[0],(0,1),order=0, - prefilter=False,output=dtype,cval=fill) # rotation around z - origin = self.origin-(np.asarray(microstructure.shape)-self.grid)//2 * self.size/self.grid + microstructure_in = self.get_microstructure() + # These rotations are always applied in the reference coordinate system, i.e. (z,x,z) not (z,x',z'') + # see https://www.cs.utexas.edu/~theshark/courses/cs354/lectures/cs354-14.pdf + for angle,axis in zip(Eulers[::-1], [(0,1),(1,2),(0,1)]): + microstructure_out = ndimage.rotate(microstructure_in,angle,axis,order=0, + prefilter=False,output=dtype,cval=fill) + microstructure_in = microstructure_out + + origin = self.origin-(np.asarray(microstructure_out.shape)-self.grid)//2 * self.size/self.grid #self.add_comments('geom.py:renumber v{}'.format(version) - return self.update(microstructure,origin=origin,rescale=True) + return self.update(microstructure_out,origin=origin,rescale=True) def canvas(self,grid=None,offset=None,fill=None): - """Rotate microstructure (pad if required).""" + """Crop or enlarge/pad microstructure.""" if fill is None: fill = np.nanmax(self.microstructure) + 1 dtype = float if np.isnan(fill) or int(fill) != fill or self.microstructure.dtype==np.float else int