以同一点 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实现向量的三角形加法