¿Como crear y animar Curvas PARAMeTRICAS con Manim?
Crear curvas PARAMeTRICAS en 2 y 3 dimensiones con Manim. Ejemplos: la epicicloide.
from manim import *
class curva2d(Scene):
def construct(self):
cielo = "#C4DDFF"
purpura="#800080"
self.camera.background_color = cielo
self.add(Text("Epicicloide",color=RED).move_to(UP * 3.5))
ax = Axes(x_range=[-3.5, 3.5, 1],
y_range=[-3.5, 3.5, 1],
x_length=7,
y_length=7,
axis_config={"include_tip": True},
).move_to(np.array([-3.5, 0, 0]))
ax.set_color(GREY)
self.add(ax)
circulo_grande = ParametricFunction(
lambda u: np.array([
2 * np.sin(u),
2 * np.cos(u),
0
]),
color=BLUE, t_range=np.array([0, 2 * PI, 0.01])
).move_to(ax.coords_to_point(0, 0))
self.play(
Write(circulo_grande, run_time=0.5),
)
self.wait(3)
epicicloide = ParametricFunction(
lambda u: np.array([
2.5 * np.cos(u) - 0.5 * np.cos((5 * u)),
2.5 * np.sin(u) - 0.5 * np.sin((5 * u)),
0
]),
color=purpura, t_range=np.array([0, 4 * PI, 0.01])
).move_to(ax.coords_to_point(0, 0))
self.play(
Write(epicicloide), run_time=15)
namex = MathTex("x=2.5\cos(\theta)-0.5\cos(5\theta)").move_to(RIGHT * 3.5 + UP).set_color(BLACK)
namey = MathTex("y=2.5\sin(\theta)-0.5\sin(5\theta)").move_to(RIGHT * 3.5 + UP * 0).set_color(BLACK)
rango = MathTex("\theta \in (0,5\pi)").move_to(RIGHT * 3.5 + DOWN).set_color(BLACK)
self.play(
Write(namex),
Write(namey),
Write(rango)
)
self.wait(10)