Manim's method 19

Overview

I checked manim's method. I tried using LinearTransformationScene.

Sample code

from manimlib.imports import *

class test(LinearTransformationScene):
	CONFIG = {
		"matrix": [[2, -5.0 / 3], [-5.0 / 3, 2]],
		"v": [1, 2],
		"w": [2, 1],
		"v_label": "v",
		"w_label": "w",
		"v_color": YELLOW,
		"w_color": MAROON_B,
		"rhs1": "> 0",
		"rhs2": "< 0",
		"foreground_plane_kwargs": {
			"x_radius": 2 * FRAME_WIDTH,
			"y_radius": 2 * FRAME_HEIGHT,
		},
		"equation_scale_factor": 1.5,
	}
	def construct(self):
		v_mob = self.add_vector(self.v, self.v_color, animate=False)
		w_mob = self.add_vector(self.w, self.w_color, animate=False)
		kwargs = {
			"transformation_name": "T",
			"at_tip": True,
			"animate": False,
		}
		v_label = self.add_transformable_label(v_mob, self.v_label, **kwargs)
		w_label = self.add_transformable_label(w_mob, self.w_label, **kwargs)
		start_equation = self.get_equation(v_label, w_label, self.rhs1)
		start_equation.to_corner(UR)
		self.play(Write(start_equation[0::2]), ReplacementTransform(v_label.copy(), start_equation[1]), ReplacementTransform(w_label.copy(), start_equation[3]), )
		self.wait()
		self.add_foreground_mobject(start_equation)
		self.apply_matrix(self.matrix)
		self.wait()
		end_equation = self.get_equation(v_label, w_label, self.rhs2)
		end_equation.next_to(start_equation, DOWN, aligned_edge=RIGHT)
		self.play(FadeIn(end_equation[0]), ReplacementTransform(start_equation[2::2].copy(), end_equation[2::2], ), ReplacementTransform(v_label.copy(), end_equation[1]), ReplacementTransform(w_label.copy(), end_equation[3]), )
		self.wait(2)
	def get_equation(self, v_label, w_label, rhs):
		equation = VGroup(v_label.copy(), TexMobject("\\cdot"), w_label.copy(), TexMobject(rhs), )
		equation.arrange(RIGHT, buff=SMALL_BUFF)
		equation.add_to_back(BackgroundRectangle(equation))
		equation.scale(self.equation_scale_factor)
		return equation




Generated video

https://www.youtube.com/watch?v=YXsK0QDOSGg

that's all.

Recommended Posts

Manim's method 7
Manim's method 13
Manim's method 2
Manim's method 18
Manim's method 17
Manim's method 5
Manim's method 3
Manim's method 15
Manim's method 11
Manim's method 16
Manim's method 20
Manim's method 10
Manim's method 9
Manim's method 6
Manim's method 21
Manim's method 4
Manim's method 8
Manim's method 22
Manim's method 19
Manim's method 12
Manim's method part 23
manim's manners
Binary method
Special method
Special method
Understand k-means method
Clustering of clustering method
Dictionary items method
[PyTorch] Installation method
Image collection method
Regression analysis method
Gradient method implementation 1
Python-peewee connection method
Class method static method
youtube-dl update method
Monte Carlo method
Mode-Matching Method Simulation_Python
Johnson method (python)
[Python] Semi-Lagrange method