'How do I Apply Multiple Linear Transformations
I'm trying to use LinearTransformationScene's apply_matrix multiple times:
from manim import *
class LT(LinearTransformationScene):
def __init__(self):
super().__init__(
self,
show_coordinates=True,
leave_ghost_vectors=True,
)
def construct(self):
P = [[1, 1], [1, -1]];
D = [[2, 0], [0, 0.5]];
P_inv = [[0.5, 0.5], [0.5, 0.5]];
self.apply_matrix(P);
self.wait();
self.apply_matrix(D);
self.wait();
self.apply_matrix(P_inv);
self.wait();
But I get this error: submobjects must be of type VMobject.
I'm hoping to create an animation that:
- Applies the matrix
P - Pauses briefly
- Applies another matrix
D - Pauses briefly again
- And finally, applies the inverse of P,
P_inv.
How do I accomplish this? There were similar questions posted, but no one posted about this specific error.
Solution 1:[1]
These specialized Scene classes are unfortunately not very well maintained, this is a known issue. There is a simple workaround though: after calling self.apply_matrix, add
self.moving_mobjects = []
and the next application of apply_matrix will work as intended again.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Benjamin Hackl |
