矩阵

代表矩阵的Mobjects。

示例

示例:MatrixExamples

../_images/MatrixExamples-1.png
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="\\{",
            right_bracket="\\}")
        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="\\{",
            right_bracket="\\}")
        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)

DecimalMatrix

一个在屏幕上显示带有十进制条目的矩阵的mobject。

IntegerMatrix

一个在屏幕上显示带有整数条目的矩阵的mobject。

Matrix

一个在屏幕上显示矩阵的mobject。

MobjectMatrix

一个在屏幕上显示mobject条目矩阵的mobject。

函数

get_det_text(matrix, determinant=None, background_rect=False, initial_scale_factor=2)[来源]

用于创建行列式的辅助函数。

Parameters:
  • matrix (矩阵) – 要创建其行列式的矩阵

  • determinant (int | str | None) – 矩阵的行列式的值

  • background_rect (bool) – 背景矩形

  • initial_scale_factor (float) – 文本 det 相对于矩阵的比例

Returns:

包含行列式的VGroup

Return type:

VGroup

示例

示例:矩阵的行列式

../_images/DeterminantOfAMatrix-1.png
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)

matrix_to_mobject(matrix)[source]
matrix_to_tex_string(matrix)[来源]