Manim学习笔记05:实现向量的加法动画

 以同一点 O𝑂 为起点的两个已知向量 →a𝑎→, →b𝑏→,以 OA𝑂𝐴,OB𝑂𝐵 为邻边作 □OACB◻𝑂𝐴𝐶𝐵,则以 O𝑂 为起点的向量 −−→OC𝑂𝐶→
(OC𝑂𝐶 是 □OACB◻𝑂𝐴𝐶𝐵 的对角线)就是向量 →a𝑎→ 与 →b𝑏→ 的和.

1.正方形加法

from manim import *

class ParallelogramRule003(Scene):
    def construct(self):
        numberplane = NumberPlane()
        dot = Dot(ORIGIN)
        self.add(numberplane,dot)
        # Create vectors
        vec_a = Arrow(start=dot, end=[1, 3, 0],buff=0,  color=BLUE)
        self.play(Create(vec_a))
        self.wait(1)
        t0 = MathTex(r"\begin{bmatrix}1\\3\end{bmatrix}")
        origin_text_a = t0.next_to([1, 3, 0], LEFT)
        self.play(Create(origin_text_a))
        
        
        vec_b = Arrow(start=dot, end=[3, 0, 0],buff=0, color=RED)
        self.play(Create(vec_b))
        self.wait(1)
        t1 = MathTex(r"\begin{bmatrix}3\\0\end{bmatrix}")
        origin_text_b = t1.next_to([3, 0, 0], DOWN)
        self.play(Create(origin_text_b))
        
        # 创建虚线箭头
        dashed_arrow_a = DashedLine(start=ORIGIN, end=[1, 3, 0], dash_length=0.05, color=BLUE)
        self.add(dashed_arrow_a)
        # 平移虚线箭头到目标位置
        self.play(ApplyMethod(dashed_arrow_a.shift, RIGHT * 3))
        self.wait(1)
        
        dashed_arrow_b = DashedLine(start=ORIGIN, end=[3, 0, 0], dash_length=0.05, color=BLUE)
        self.add(dashed_arrow_b)
        self.play(ApplyMethod(dashed_arrow_b.shift, RIGHT+UP * 3))
        self.wait(1)

    

        
        vec_ac = Arrow(start=dot, end=[4, 3, 0],buff=0,  color=GOLD)
        self.play(Create(vec_ac))
        t2 = MathTex(r"\begin{bmatrix}3 & 4 \\ 0 & 0 \end{bmatrix}")
        origin_text_ac = t2.next_to([4, 3, 0], RIGHT)
        self.play(Create(origin_text_ac))
        
        #self.play(Create(start_arrow))

        self.wait(2)

 实现视频链接如下:

用Manim实现向量的四边形加法

三角形加法 

 已知向量非零向量 →a𝑎→, →b𝑏→,在平面内取任意一点 A𝐴 , 作 −−→AB=→a𝐴𝐵→=𝑎→ , −−→BC=→b𝐵𝐶→=𝑏→,则向量 −−→AC𝐴𝐶→ 叫做 →a𝑎→ 与 →b𝑏→ 的和,记作 →a+→b𝑎→+𝑏→,即 →a+→b=−−→AB+−−→BC=−−→AC𝑎→+𝑏→=𝐴𝐵→+𝐵𝐶→=𝐴𝐶→.

from manim import *

class ParallelogramRule004(Scene):
    def construct(self):
        numberplane = NumberPlane()
        dot = Dot(ORIGIN)
        self.add(numberplane,dot)
        # Create vectors
        vec_a = Arrow(start=dot, end=[1, 3, 0],buff=0,  color=BLUE)
        self.play(Create(vec_a))
        self.wait(1)
        t0 = MathTex(r"\begin{bmatrix}1\\3\end{bmatrix}")
        origin_text_a = t0.next_to([1, 3, 0], LEFT)
        self.play(Create(origin_text_a))
        
        
        vec_b = Arrow(start=dot, end=[3, 0, 0],buff=0, color=RED)
        self.play(Create(vec_b))
        self.wait(1)
        t1 = MathTex(r"\begin{bmatrix}3\\0\end{bmatrix}")
        origin_text_b = t1.next_to([3, 0, 0], DOWN)
        self.play(Create(origin_text_b))
        
        # 移动向量a
        # 平移虚线箭头到目标位置
        self.play(ApplyMethod(vec_a.shift, RIGHT * 3))
        self.wait(1)
        
        vec_ac = Arrow(start=dot, end=[4, 3, 0],buff=0,  color=GOLD)
        self.play(Create(vec_ac))
        t2 = MathTex(r"\begin{bmatrix}3 & 4 \\ 0 & 0 \end{bmatrix}")
        origin_text_ac = t2.next_to([4, 3, 0], RIGHT)
        self.play(Create(origin_text_ac))
        
        #self.play(Create(start_arrow))

        self.wait(2)
        

视频实现如下: 

用Manim实现向量的三角形加法

  • 21
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Yasen.M

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值