Matrix
The defined matrix
VMobject in matrix.py
- Class Matrix(VMobject)
- Class DecimalMatrix(Matrix)
- Class IntegerMatrix(Matrix)
- Class MobjectMatrix(Matrix)
Class Matrix
Matrix(VMobject) is used to generate a matrix form of specified matrix for given parameters.
Example
Code
# folder/file: tut/manim_mobject_matrix_001a.py
from manimlib.scene.scene import Scene
from manimlib.mobject.matrix import Matrix
class manim_mobject_matrix_001a(Scene):
def construct(self):
num=Matrix(["1234555","1.0","0"])
self.add(num.move_to([0,1,0]))
self.wait(2)
self.add(Matrix([(0,1,5),(3,4.5,5)]).move_to([3.5,3,0]))
self.wait(2)
self.add(Matrix([+1234555.2222222222,num],include_background_rectangle=True).move_to([0,0.8,0]))
self.wait(2)
self.add(Matrix(0).move_to([-5,1,0]))
self.wait(2)
Output
Class DecimalMatrix(Matrix)
DecimalMatrix is used to generate a decimal matrix form of specified matrix for given parameters.
Example
Code
# folder/file: tut/manim_mobject_decimalmatrix_001a.py
from manimlib.scene.scene import Scene
from manimlib.mobject.matrix import DecimalMatrix
class manim_mobject_decimalmatrix_001a(Scene):
def construct(self):
num=DecimalMatrix([1234555,1.0,0])
self.add(num.move_to([0,1,0]))
self.wait(2)
self.add(DecimalMatrix([(0,1,5),(3,4.5,5)]).move_to([3.5,3,0]))
self.wait(2)
self.add(DecimalMatrix([(+1234555.2222222222,0),(0,1)],element_to_mobject_config={"group_with_commas": False,
"digit_to_digit_buff": 0.05},include_background_rectangle=True).move_to([0,-2,0]))
self.wait(2)
self.add(DecimalMatrix([(0,1),(1000,0)],element_to_mobject_config={"group_with_commas": True,
"digit_to_digit_buff": 0.1}).move_to([-5,-2,0]))
self.wait(2)
Output
Class IntegerMatrix(Matrix)
IntegerMatrix is used to generate a integer matrix form of specified matrix for given parameters.
Example
Code
# folder/file: tut/manim_mobject_integermatrix_001a.py
from manimlib.scene.scene import Scene
from manimlib.mobject.matrix import IntegerMatrix
class manim_mobject_integermatrix_001a(Scene):
def construct(self):
num=IntegerMatrix([1234555,1.0,0])
self.add(num.move_to([0,1,0]))
self.wait(2)
self.add(IntegerMatrix([(0,1,5),(3,4.5,5)]).move_to([3.5,3,0]))
self.wait(2)
self.add(IntegerMatrix([(+1234555.2222222222,0),(0,1)],element_to_mobject_config={"group_with_commas": False,
"digit_to_digit_buff": 0.05},include_background_rectangle=True).move_to([0,-2,0]))
self.wait(2)
self.add(IntegerMatrix([(0,1),(1000,0)],element_to_mobject_config={"group_with_commas": True,
"digit_to_digit_buff": 0.1}).move_to([-5,-2,0]))
self.wait(2)
Output
Class MobjectMatrix(Matrix)
MobjectMatrix is used to generate a mobject matrix form of specified matrix for given parameters.
Example
Code
# folder/file: tut/manim_mobject_mobjectmatrix_001a.py
from manimlib.scene.scene import Scene
from manimlib.mobject.matrix import MobjectMatrix
from manimlib.mobject.matrix import Matrix
class manim_mobject_mobjectmatrix_001a(Scene):
def construct(self):
matrix=Matrix([(0,1,5),(3,4.5,5),("a",4,6)])
self.add(matrix.move_to([-5,2.5,0]))
self.wait(2)
matrix1=matrix.copy()
self.add(matrix1.move_to([5,2.5,0]))
self.wait(2)
numa=MobjectMatrix([(matrix.mob_matrix[:,1]),(matrix.mob_matrix[:,0])])
self.add(numa)
self.wait(2)
self.add(Matrix([(matrix.mob_matrix[:,1]),(matrix.mob_matrix[:,0])],h_buff=3).move_to([0,-3,0]))
self.wait(2)
Output