You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何Manim ArrowVectorField中圆点上会出现蓝色箭头?

问题:矢量场中心及吸引子圆点上的蓝色箭头成因解析

问题描述

我搞不懂为什么这个矢量场会在构建时围绕的圆点上画出蓝色箭头,猜这和函数生成器有关,但完全不明白这些蓝色箭头的生成原因以及在矢量场里的意义,而且ArrowVectorField的文档也没提这个问题。图片里能看到中心圆点和另外三个吸引子状态圆点上都有蓝色小箭头。

对应代码

# function generator
def get_force_field_func(*point_strength_pairs, **kwargs):
    radius = kwargs.get("radius", 0.5)

    def func(point):
        result = np.array(ORIGIN)
        for center, strength in point_strength_pairs:
            to_center = center - point
            norm = np.linalg.norm(to_center)
            if norm == 0:
                continue
            elif norm < radius:
                to_center /= radius**3
            elif norm >= radius:
                to_center /= norm**3
            to_center *= -strength
            result += to_center
        return result
    return func

class Test(Scene):
    def construct(self):
        progenitor = Dot()
        self.add(progenitor)

        attractor1 = Dot().move_to(RIGHT * 2 + UP * 3)
        attractor2 = Dot().move_to(UP * 2 + LEFT * 4)
        attractor3 = Dot().move_to(DOWN * 2 + RIGHT * 4)

        constrained_func = get_force_field_func(
            (progenitor.get_center(), 1),
            (attractor1.get_center(), -0.5),
            (attractor2.get_center(), -2),
            (attractor3.get_center(), -1)
        )

        constrained_field = ArrowVectorField(constrained_func)
        self.add(constrained_field)

原因解析

  • 蓝色箭头本质就是对应位置的矢量场取值,和其他区域的箭头没有区别。
  • 看get_force_field_func的逻辑:当计算的point刚好是某个场源圆点的中心时,norm == 0,会跳过当前场源的贡献,但其他场源仍然会对这个位置产生场的叠加。比如中心圆点的位置,会受到三个吸引子的场作用,函数最终返回非零矢量,ArrowVectorField就会在此处绘制箭头。
  • 举个例子:计算吸引子1中心位置的场时,会跳过吸引子1自己的贡献,但会计算中心圆点、吸引子2、吸引子3对该点的场贡献,叠加后得到的矢量就是这个蓝色箭头对应的方向和大小。

内容的提问来源于stack exchange,提问作者basesorbytes

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 06:50:16