ManimCommunity / manim

A community-maintained Python framework for creating mathematical animations.
https://www.manim.community
MIT License
20.86k stars 1.52k forks source link

Trying to make a vector field, I got a message telling me to make a bug report #3866

Closed Frigorifico9 closed 3 weeks ago

Frigorifico9 commented 1 month ago

Description of bug / unexpected behavior

I'm trying to make a vector field, but I don't really understand how it works. I wanted to normalize it so I thought I'd divide by the magnitude of the field, but I was clearly wrong and I got an error message telling mt to make a bug report, and so have me here

Expected behavior

I just wanted all the arrows to be the same man

How to reproduce the issue

This is the entirety of my code

from manim import *
import numpy as np

class potentialEnergy(Scene):
    def construct(self):

        #func = lambda pos: ((pos[0] * UR + pos[1] * LEFT) - pos) / 3
        gravity = lambda pos: (abs(pos[0])*DOWN/abs(pos[0]))
        self.add(ArrowVectorField(gravity))

Additional media files

This was the previous image I was getting

potentialEnergy_ManimCE_v0 18 1

Images/GIFs

Logs

Terminal output ``` PASTE HERE OR PROVIDE LINK TO https://pastebin.com/ OR SIMILAR ```

System specifications

System Details - OS (with version, e.g., Windows 10 v2004 or macOS 10.15 (Catalina)): - RAM: - Python version (`python/py/python3 --version`): - Installed modules (provide output from `pip list`): ``` PASTE HERE ```
LaTeX details + LaTeX distribution (e.g. TeX Live 2020): + Installed LaTeX packages:

Additional comments

uwezi commented 1 month ago

The problem seems to be nothing but a ordinary division by zero when you divide you vector by abs(pos[0]) for any point along the y-axis (x=0). This can be easily avoided by adding a small value to your denominator. However, I don't understand what exactly you want to show here in the scene...

class potentialEnergy(Scene):
    def construct(self):

        #func = lambda pos: ((pos[0] * UR + pos[1] * LEFT) - pos) / 3
        gravity = lambda pos: (abs(pos[0])*DOWN/(abs(pos[0])+1e-6))
        self.add(ArrowVectorField(gravity))