-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Description
Describe the error
When I was using rotate_vector to write a function for VectorField, there is a dimension error, which is not a problem in past versions.
Code and Error
Code:
from manimlib import * # type: ignore
class Simulation(Scene):
def construct(self) -> None:
axes = NumberPlane()
def div_func(p: np.ndarray) -> np.ndarray:
return p / 3
field_dir = VectorField(div_func, axes)
self.play(FadeIn(field_dir))
def curl_func(p): # <- this function
return rotate_vector(p / 3, PI / 2)
field_curl = VectorField(curl_func, axes)
self.play(
ReplacementTransform(field_dir, field_curl), run_time=1
)
Error:
Traceback (most recent call last):
File "/Users/cengyi/miniconda3/envs/manimgl/bin/manimgl", line 8, in
sys.exit(main())
~~~~^^
File "/Users/cengyi/miniconda3/envs/manimgl/lib/python3.13/site-packages/manimlib/main.py", line 61, in main
run_scenes()
~~~~~~~~~~^^
File "/Users/cengyi/miniconda3/envs/manimgl/lib/python3.13/site-packages/manimlib/main.py", line 39, in run_scenes
scene.run()
~~~~~~~~~^^
File "/Users/cengyi/miniconda3/envs/manimgl/lib/python3.13/site-packages/manimlib/scene/scene.py", line 155, in run
self.construct()
~~~~~~~~~~~~~~^^
File "/Users/cengyi/Manimproduce/manim-learning/note/simulation.py", line 14, in construct
field_curl = VectorField(curl_func, axes)
File "/Users/cengyi/miniconda3/envs/manimgl/lib/python3.13/site-packages/manimlib/mobject/vector_field.py", line 185, in init
max_value = max(map(get_norm, func(self.sample_coords)))
~~~~^^^^^^^^^^^^^^^^^^^^
File "/Users/cengyi/Manimproduce/manim-learning/note/simulation.py", line 13, in curl_func
return rotate_vector(p / 3, PI / 2)
File "/Users/cengyi/miniconda3/envs/manimgl/lib/python3.13/site-packages/manimlib/utils/space_ops.py", line 123, in rotate_vector
return np.dot(vector, rot.as_matrix().T)
~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: shapes (561,2) and (3,3) not aligned: 2 (dim 1) != 3 (dim 0)
Environment
OS System: MacOS
manim version: master (have used the changes in PR #2330)
python version:3.13.2