Closed WiktorProj closed 3 months ago
I assume that you are aware of the fact that you are trying to divide by zero along the axis-lines? This would make the resulting vectors infinitely long - which is a bit difficult to handle...
class BasicUsage(Scene):
def construct(self):
def func(pos):
if pos[0] != 0 and pos[1] != 0:
return 1/pos[0]*RIGHT + 1/pos[1]*UP
else:
return ORIGIN
self.add(ArrowVectorField(func))
Description of bug / unexpected behavior
I don't even know how i got here!
Expected behavior
Should generate a vector field
How to reproduce the issue
Add a 1/ to the lambda
Code for reproducing the problem
```py class BasicUsage(Scene): def construct(self): func = lambda pos: 1/pos[0]*RIGHT + 1/pos[1]*UP self.add(ArrowVectorField(func)) ```Logs
Terminal output
Exception Traceback (most recent call last) Cell In[8], line 9 4 self.add(ArrowVectorField(func)) 8 # don't remove below command for run button to work ----> 9 get_ipython().run_line_magic('manim', '-qm -v DEBUG BasicUsage') File /usr/local/lib/python3.11/site-packages/IPython/core/interactiveshell.py:2480, in InteractiveShell.run_line_magic(self, magic_name, line, _stack_depth) 2478 kwargs['local_ns'] = self.get_local_scope(stack_depth) 2479 with self.builtin_trap: -> 2480 result = fn(*args, **kwargs) 2482 # The code below prevents the output from being displayed 2483 # when using magics with decorator @output_can_be_silenced 2484 # when the last Python token in the expression is a ';'. 2485 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False): File /usr/local/lib/python3.11/site-packages/manim/utils/ipython_magic.py:143, in ManimMagic.manim(self, line, cell, local_ns) 141 SceneClass = local_ns[config["scene_names"][0]] 142 scene = SceneClass(renderer=renderer) --> 143 scene.render() 144 finally: 145 # Shader cache becomes invalid as the context is destroyed 146 shader_program_cache.clear() File /usr/local/lib/python3.11/site-packages/manim/scene/scene.py:229, in Scene.render(self, preview) 227 self.setup() 228 try: --> 229 self.construct() 230 except EndSceneEarlyException: 231 pass Cell In[8], line 4, in BasicUsage.construct(self) 2 def construct(self): 3 func = lambda pos: 1/pos[0]*RIGHT + 1/pos[1]*UP ----> 4 self.add(ArrowVectorField(func)) File /usr/local/lib/python3.11/site-packages/manim/mobject/vector_field.py:604, in ArrowVectorField.__init__(self, func, color, color_scheme, min_color_scheme_value, max_color_scheme_value, colors, x_range, y_range, z_range, three_dimensions, length_func, opacity, vector_config, **kwargs) 601 y_range = np.arange(*self.y_range) 602 z_range = np.arange(*self.z_range) 603 self.add( --> 604 *[ 605 self.get_vector(x * RIGHT + y * UP + z * OUT) 606 for x, y, z in it.product(x_range, y_range, z_range) 607 ] 608 ) 609 self.set_opacity(self.opacity) File /usr/local/lib/python3.11/site-packages/manim/mobject/vector_field.py:605, in