实现Manim动画
用Manim实现向量的减法的证明,并动画利用Manim实现向量计算的减法_哔哩哔哩_bilibili利用Manim实现数学动画, 视频播放量 0、弹幕量 0、点赞数 0、投硬币枚数 0、收藏人数 0、转发人数 0, 视频作者 Yasen_M, 作者简介 ,相关视频:https://www.bilibili.com/video/BV1gWb5eRE2N/
1.相反向量
我们规定,与向量 长度相等,方向相反的向量,叫做
的相反向量,记作
解释
(1) 与数 𝑥 的相反数是 −𝑥 类似;
(2)
(3) 零向量的相反向量仍是零向量.
2.向量的减法
向量 a 加上 b 的相反向量,叫做a 与b 的差,即a-b=a+(-b).
求两个向量差的运算叫做向量的减法。向量的减法可以转化为向量的加法进行.
3.向量减法的几何意义
当 a,b 同起点时,a−b可以表示为从向量b的终点指向向量a的终点的向量.
这次实现了向量的复制和移动,旋转等特征。
from manim import *
class ParallelogramRule_0223(Scene):
def construct(self):
numberplane = NumberPlane()
dot = Dot(ORIGIN)
self.add(numberplane, dot)
tB = Text("O").next_to(dot, LEFT+DOWN)
vec_B = Arrow(start=dot, end=[-1, 3, 0], buff=0, color=BLUE)
self.play(Create(vec_B))
self.wait(1)
tB = Text("B").next_to(vec_B.get_end(), LEFT)
self.play(Create(tB))
t0 = MathTex(r"\vec{b}")
origin_text_B = t0.next_to([-1, 1, 0], LEFT)
self.play(Create(origin_text_B))
vec_A = Arrow(start=dot, end=[4, 0, 0], buff=0, color=RED)
self.play(Create(vec_A))
self.wait(1)
tA = Text("A").next_to(vec_A.get_end(), UP)
self.play(Create(tA))
t1 = MathTex(r"\vec{a}")
origin_text_A = t1.next_to([2, 0, 0], UP)
self.play(Create(origin_text_A))
rotated_arrow_B = vec_B.copy().rotate(PI, about_point=ORIGIN).set_color(GOLD)
self.play(Create(rotated_arrow_B))
#self.wait(1)
t_B = Text("D").next_to(rotated_arrow_B.get_end(), LEFT)
self.play(Create(t_B))
t2 = MathTex(r"\vec{-b}")
origin_text_bB = t2.next_to(rotated_arrow_B.get_end(), 3*UP + 2*LEFT)
self.play(Create(origin_text_bB))
self.wait(1)
vec_A_copy = Arrow(start=vec_A.get_start(),
end=vec_A.get_end(), buff=0, color=RED)
vec_A01_copy =vec_A_copy.copy() .shift(3*DOWN+RIGHT)
self.play(Transform(vec_A_copy,vec_A01_copy))
t2a = Text("C").next_to(vec_A_copy.get_end(), RIGHT)
self.play(Create(t2a))
t2a = MathTex(r"\vec{a'}")
origin_text_2a = t2a.next_to(vec_A_copy.get_end(), 6*LEFT+DOWN)
self.play(Create(origin_text_2a))
self.wait(1)
vec_minus_B_copy = Arrow(start=rotated_arrow_B.get_start(), end=rotated_arrow_B.get_end(),
buff=0, color=BLUE)
vec_minus_B01_copy =vec_minus_B_copy.copy() .shift(4*RIGHT)
self.play(Transform(vec_minus_B_copy,vec_minus_B01_copy))
t2b = MathTex(r"\vec{-b'}")
origin_text_2b = t2b.next_to(vec_minus_B_copy.get_end(), 4*UP)
self.play(Create(origin_text_2b))
self.wait(1)
vec_OC=Arrow(start=dot,end=vec_minus_B_copy.get_end(),buff=0, color=YELLOW)
self.play(Create(vec_OC))
toc_ = MathTex(r"\vec{oc'}")
origin_text_oc_ = toc_.next_to(vec_OC.get_end(),6*LEFT+7*UP)
self.play(Create(origin_text_oc_))
self.wait(1)
vec_OC1=Arrow(start=dot,end=vec_minus_B_copy.get_end(),buff=0, color=YELLOW)
vec_AB_OC1 =vec_OC1.copy() .shift(3*UP+LEFT)
self.play(Transform(vec_OC1,vec_AB_OC1))
tba = MathTex(r"\vec{BA}=\vec{a}-\vec{b}")
origin_text_2ba = tba.next_to([2,2,0])
self.play(Create(origin_text_2ba))
self.wait(1)
#创建正方形
# 创建长方形
rectangle = Rectangle(fill_color=WHITE, fill_opacity=1,width=6, height=4).shift(3.7*LEFT+2*DOWN)
#self.add(rectangle)
self.play(Create(rectangle))
self.wait(1)
#结论
%manim -qm -v WARNING ParallelogramRule_0223
运行结果如下:
完整运行结果可以在哔哩哔哩上可以看到,视频效果更佳美好。