mirror of
https://github.com/3b1b/manim.git
synced 2025-11-14 18:47:46 +00:00
StreamLine test
This commit is contained in:
parent
d0b2d8ee5e
commit
1c868906b9
1 changed files with 25 additions and 4 deletions
|
|
@ -2,7 +2,7 @@ from big_ol_pile_of_manim_imports import *
|
|||
|
||||
|
||||
def pendulum_vector_field(point, mu=0.1, g=9.8, L=3):
|
||||
theta, omega, z = point
|
||||
theta, omega = point[:2]
|
||||
return np.array([
|
||||
omega,
|
||||
-np.sqrt(g / L) * np.sin(theta) - mu * omega,
|
||||
|
|
@ -10,18 +10,39 @@ def pendulum_vector_field(point, mu=0.1, g=9.8, L=3):
|
|||
])
|
||||
|
||||
|
||||
# Scenes
|
||||
|
||||
class VectorFieldTest(Scene):
|
||||
def construct(self):
|
||||
plane = NumberPlane(
|
||||
# axis_config={"unit_size": 2}
|
||||
)
|
||||
mu_tracker = ValueTracker(1)
|
||||
field = VectorField(
|
||||
lambda p: pendulum_vector_field(
|
||||
[*plane.point_to_coords(p), 0],
|
||||
mu=0.1
|
||||
plane.point_to_coords(p),
|
||||
mu=mu_tracker.get_value()
|
||||
),
|
||||
delta_x=0.5,
|
||||
delta_y=0.5,
|
||||
max_magnitude=4,
|
||||
opacity=0.5,
|
||||
# length_func=lambda norm: norm,
|
||||
)
|
||||
stream_lines = StreamLines(
|
||||
field.func,
|
||||
delta_x=0.5,
|
||||
delta_y=0.5,
|
||||
)
|
||||
animated_stream_lines = AnimatedStreamLines(
|
||||
stream_lines,
|
||||
line_anim_class=ShowPassingFlashWithThinningStrokeWidth,
|
||||
)
|
||||
|
||||
self.add(plane, field)
|
||||
self.add(plane, field, animated_stream_lines)
|
||||
self.wait(10)
|
||||
|
||||
|
||||
class NewSceneName(Scene):
|
||||
def construct(self):
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue