Potentially useless ApplyMatrix animation

This commit is contained in:
Grant Sanderson
2015-10-06 18:40:18 -07:00
parent c95f31385e
commit 54de0881f5

View File

@ -148,6 +148,26 @@ class ApplyFunction(Transform):
)
self.name = "ApplyFunctionTo"+str(mobject)
class ApplyMatrix(Animation):
#Truth be told, I'm not sure if this is useful.
def __init__(self, matrix, mobject, **kwargs):
matrix = np.array(matrix)
if matrix.shape == (2, 2):
self.matrix = np.identity(3)
self.matrix[:2, :2] = matrix
elif matrix.shape == (3, 3):
self.matrix = matrix
else:
raise "Matrix has bad dimensions"
Animation.__init__(self, mobject, **kwargs)
def update_mobject(self, alpha):
matrix = interpolate(np.identity(3), self.matrix, alpha)
self.mobject.points = np.dot(
self.starting_mobject.points,
np.transpose(matrix)
)
class ApplyPointwiseFunction(Transform):
DEFAULT_CONFIG = {
"run_time" : DEFAULT_ANIMATION_RUN_TIME