矩阵¶
表示矩阵的Mobject。
示例
示例:MatrixExamples ¶

from manim import *
class MatrixExamples(Scene):
def construct(self):
m0 = Matrix([["\\pi", 0], [-1, 1]])
m1 = IntegerMatrix([[1.5, 0.], [12, -1.3]],
left_bracket="(",
right_bracket=")")
m2 = DecimalMatrix(
[[3.456, 2.122], [33.2244, 12.33]],
element_to_mobject_config={"num_decimal_places": 2},
left_bracket=r"\{",
right_bracket=r"\}")
m3 = MobjectMatrix(
[[Circle().scale(0.3), Square().scale(0.3)],
[MathTex("\\pi").scale(2), Star().scale(0.3)]],
left_bracket="\\langle",
right_bracket="\\rangle")
g = Group(m0, m1, m2, m3).arrange_in_grid(buff=2)
self.add(g)
class MatrixExamples(Scene): def construct(self): m0 = Matrix([["\\pi", 0], [-1, 1]]) m1 = IntegerMatrix([[1.5, 0.], [12, -1.3]], left_bracket="(", right_bracket=")") m2 = DecimalMatrix( [[3.456, 2.122], [33.2244, 12.33]], element_to_mobject_config={"num_decimal_places": 2}, left_bracket=r"\{", right_bracket=r"\}") m3 = MobjectMatrix( [[Circle().scale(0.3), Square().scale(0.3)], [MathTex("\\pi").scale(2), Star().scale(0.3)]], left_bracket="\\langle", right_bracket="\\rangle") g = Group(m0, m1, m2, m3).arrange_in_grid(buff=2) self.add(g)
类
在屏幕上显示带有小数项的矩阵的mobject。 |
|
在屏幕上显示带有整数项的矩阵的mobject。 |
|
在屏幕上显示矩阵的mobject。 |
|
在屏幕上显示mobject项的矩阵的mobject。 |
函数
- get_det_text(matrix, determinant=None, background_rect=False, initial_scale_factor=2)[source]¶
创建行列式的辅助函数。
- 参数:
matrix (Matrix) – 要创建行列式的矩阵
determinant (int | str | None) – 矩阵行列式的值
background_rect (bool) – 背景矩形
initial_scale_factor (float) – 文本det相对于矩阵的缩放比例
- 返回:
包含行列式的VGroup
- 返回类型:
示例
示例:DeterminantOfAMatrix ¶
from manim import * class DeterminantOfAMatrix(Scene): def construct(self): matrix = Matrix([ [2, 0], [-1, 1] ]) # scaling down the `det` string det = get_det_text(matrix, determinant=3, initial_scale_factor=1) # must add the matrix self.add(matrix) self.add(det)
class DeterminantOfAMatrix(Scene): def construct(self): matrix = Matrix([ [2, 0], [-1, 1] ]) # scaling down the `det` string det = get_det_text(matrix, determinant=3, initial_scale_factor=1) # must add the matrix self.add(matrix) self.add(det)