from manim import *
narration_segments = [
"Projectile motion is the motion of an object thrown or projected into the air, subject to only the acceleration of gravity.",
"The trajectory of projectile motion is a parabola, determined by initial velocity and angle of projection.",
"The horizontal and vertical motions are independent; horizontal velocity remains constant while vertical velocity changes due to gravity.",
"Using equations of motion, we can calculate important parameters such as time of flight, maximum height, and range.",
]
AUDIO1_DURATION = 6
AUDIO2_DURATION = 7
AUDIO3_DURATION = 7
AUDIO4_DURATION = 8
class ProjectileMotion(Scene):
def construct(self):
# Segment 1: Introduction to projectile motion
title = Text("Projectile Motion", font_size=48).to_edge(UP)
definition = Tex(
r"Projectile motion: \text{motion of an object thrown or projected into the air,}",
r"\text{subject to only the acceleration due to gravity.}",
font_size=36,
tex_environment="align*",
).next_to(title, DOWN, buff=0.8)
self.add(title, definition)
self.add_sound("audio1.mp3")
self.wait(AUDIO1_DURATION)
# Cleanup before next segment
self.clear()
# Segment 2: Trajectory and initial parameters
title2 = Text("Trajectory of Projectile Motion", font_size=44).to_edge(UP)
trajectory_eq = MathTex(
r"y = x\tan(\theta) - \frac{g x^2}{2 v_0^2 \cos^2(\theta)}",
font_size=40
).next_to(title2, DOWN, buff=0.8)
# Draw a parabola representing the projectile path
axes = Axes(
x_range=[0, 10, 1],
y_range=[0, 6, 1],
x_length=8,
y_length=4.5,
axis_config={"include_tip": False, "stroke_width": 2},
).to_edge(DOWN)
parabola = axes.plot(
lambda x: x * 2 - (9.8 * x**2) / (2 * 25 * (0.8**2)),
x_range=[0, 8],
color=BLUE,
stroke_width=4,
)
label_theta = MathTex(r"\theta", font_size=36).next_to(axes.c2p(1, 0), UP * 0.4 + LEFT * 0.1)
velocity_vec = Arrow(
start=axes.c2p(0, 0),
end=axes.c2p(2.5, 3),
buff=0,
stroke_width=4,
color=RED
)
velocity_label = MathTex(r"\vec{v}_0", font_size=36).next_to(velocity_vec.get_end(), UP)
self.add(title2, trajectory_eq, axes, parabola, velocity_vec, velocity_label, label_theta)
self.add_sound("audio2.mp3")
self.wait(AUDIO2_DURATION)
# Cleanup before next segment
self.clear()
# Segment 3: Independence of horizontal and vertical motion
title3 = Text("Horizontal and Vertical Motion", font_size=44).to_edge(UP)
horiz_motion = MathTex(
r"x(t) = v_0 \cos(\theta) \cdot t",
font_size=40
).to_edge(LEFT).shift(DOWN)
vert_motion = MathTex(
r"y(t) = v_0 \sin(\theta) \cdot t - \frac{1}{2} g t^2",
font_size=40
).to_edge(RIGHT).shift(DOWN)
horiz_arrow = Arrow(start=LEFT, end=RIGHT, color=GREEN, stroke_width=5).next_to(horiz_motion, UP)
vert_arrow = Arrow(start=DOWN, end=UP, color=ORANGE, stroke_width=5).next_to(vert_motion, UP)
horiz_text = Text("Constant Velocity", font_size=36, color=GREEN).next_to(horiz_arrow, UP)
vert_text = Text("Acceleration due to Gravity", font_size=36, color=ORANGE).next_to(vert_arrow, UP)
self.add(title3, horiz_motion, vert_motion, horiz_arrow, vert_arrow, horiz_text, vert_text)
self.add_sound("audio3.mp3")
self.wait(AUDIO3_DURATION)
# Cleanup before next segment
self.clear()
# Segment 4: Calculations of flight parameters
title4 = Text("Time of Flight, Max Height, and Range", font_size=44).to_edge(UP)
tof = MathTex(
r"T = \frac{2 v_0 \sin(\theta)}{g}",
font_size=38
).to_edge(LEFT).shift(DOWN * 0.5)
h_max = MathTex(
r"H = \frac{v_0^2 \sin^2(\theta)}{2 g}",
font_size=38
).next_to(tof, DOWN, aligned_edge=LEFT, buff=1)
range_eq = MathTex(
r"R = \frac{v_0^2 \sin(2 \theta)}{g}",
font_size=38
).next_to(h_max, DOWN, aligned_edge=LEFT, buff=1)
self.add(title4, tof, h_max, range_eq)
self.add_sound("audio4.mp3")
self.wait(AUDIO4_DURATION)
# Final cleanup
self.clear()