manim.mobject.matrix

Mobjects representing matrices.

Examples

../_images/MatrixExamples-1.png
MatrixExamples
class MatrixExamples(Scene):
    def construct(self):
        m0 = Matrix([[2, 0], [-1, 1]])
        m1 = Matrix([[1, 0], [0, 1]],
                    left_bracket="\\big(",
                    right_bracket="\\big)")
        m2 = DecimalMatrix(
            [[3.456, 2.122], [33.2244, 12.33]],
            element_to_mobject_config={"num_decimal_places": 2},
            left_bracket="\\{",
            right_bracket="\\}")

        self.add(m0.shift(LEFT - (3, 0, 0)))
        self.add(m1)
        self.add(m2.shift(RIGHT + (3, 0, 0)))

Classes

DecimalMatrix

A mobject that displays a matrix with decimal entries on the screen.

IntegerMatrix

A mobject that displays a matrix with integer entries on the screen.

Matrix

A mobject that displays a matrix on the screen.

MobjectMatrix

A mobject that displays a matrix of mobject entries on the screen.

Functions

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

Helper function to create determinant

Parameters
  • matrix (Matrix) – The matrix whose determinant is to be created

  • determinant (int|str) – The value of the determinant of the matrix

  • background_rect (bool) – The background rectangle

  • initial_scale_factor (float) – The scale of the text det w.r.t the matrix

Returns

A VGroup containing the determinant

Return type

VGroup

Examples

../_images/DeterminantOfAMatrix-1.png
DeterminantOfAMatrix
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)[source]
vector_coordinate_label(vector_mob, integer_labels=True, n_dim=2, color='#FFFFFF')[source]