I don't know why this vector field draws blue arrows on the dots the field is built around. I assume its because of the function generator, but I don't understand it well enough to see why it would generate them or what it means in the vector field. The documentation on ArrowVectorField did not address this issue.
The picture shows the small blue arrows on the center dot and on the other three attractor states.
# function generator
# https://github.com/3b1b/videos/blob/436842137ee6b89cbb2aa10fa2d4c2e12361dac8/_2018/div_curl.py#L100
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)
Look at the return value of your generator_function
at these values, for example at the origin:
>>> constrained_func(np.array([0, 0, 0]))
array([-0.02338674, 0.05436261, 0. ])
This is a small vector pointing to the top left -- which is exactly what the small blue arrow in the origin is.
If you'd like to get rid of that, you could replace continue
with return np.array([0., 0., 0.])
-- but that might not be in line with the concept modeled by the generator function.