def rot90(self, turns=1):
"""
Rotates the blocks in the counter-clockwise direction. (As numpy
does it.)
"""
# Rotate the individual Y-layer matrices
new_blocks = np.array([np.rot90(by, turns) for by in self.blocks])
new_data = np.array([np.rot90(dy, turns) for dy in self.data])
new_mask = np.array([np.rot90(my, turns) for my in self.mask])
# Rotate the data (if applicable)
for y in xrange(new_data.shape[0]):
for z in xrange(new_data.shape[1]):
for x in xrange(new_data.shape[2]):
b = new_blocks[y, z, x]
d = new_data[y, z, x]
new_data[y, z, x] = self.data_rot90(b, d, turns)
return MaskedSubChunk(new_blocks, new_data, new_mask)
评论列表
文章目录