Projectile Motion Simulator (with Air Drag) & Double Pendulum
Simulate projectile motion with air drag and chaotic double-pendulum dynamics via RK4 integration.
Two mechanics problems, one shared integrator: a hand-written fourth-order Runge-Kutta stepper drives both the projectile simulation and the double pendulum, rather than a closed-form formula that only works for the frictionless textbook case. Turn on air resistance for the projectile and the flight is no longer a parabola; watch the double pendulum for more than a few swings and its motion stops looking predictable at all.
How to use the projectile motion simulator
- Set the initial velocity (1 to 100 m/s), launch angle (-89° to 89°) and release height (0 to 200 m) with the sliders; the trajectory redraws while you drag.
- Tick Quadratic air drag to add air resistance, then adjust the mass, drag coefficient and cross-section area; the starting values describe a 0.145 kg baseball.
- Read apex height, flight time, range, impact speed and impact angle in the results grid under the plot.
- With drag on, compare the colored path against the faint gray drag-free arc to see how much height and distance the air takes away.
Why RK4 instead of a formula
Both simulations advance a state vector — position and velocity for the projectile, angles and angular velocities for the pendulum — through the classic four-stage Runge-Kutta update: sample the derivative at the start of the step, sample it again at two estimated midpoints, sample it once more at the estimated endpoint, then combine all four slopes into a single weighted average step. It is deliberately hand-written rather than pulled from a numerical-methods library, so the whole computation stays visible and client-side.
The projectile stepper uses a fixed 0.002-second step and runs for up to 200,000 steps, stopping the instant the trajectory crosses back down to ground level and linearly interpolating that final fraction of a step so the reported landing point is precise rather than snapped to the nearest sample.
Projectile motion, with or without drag
With drag switched off, the simulator still runs the same RK4 integration, but on level ground the result matches the textbook closed-form equations almost exactly (they are listed in the formulas section below). The project's test suite checks the simulated range and apex height against those formulas; on screen, turning drag on draws the drag-free arc as a faint gray line behind the dragged path, so the gap between the ideal and the realistic flight is visible at a glance.
With drag switched on, a quadratic drag force opposing the velocity vector is added to the equations of motion. You control three of its inputs: mass (0.001 to 20 kg), drag coefficient (0.05 to 1.5) and cross-sectional area (0.0001 to 1 m²). Air density is fixed at the sea-level value of 1.225 kg per cubic meter and gravity at 9.81 m/s², so there are no altitude or planet settings. The defaults model a thrown baseball: 0.145 kg, a drag coefficient of 0.47 (a plain sphere) and a 42-square-centimeter cross-section. Speed adjusts from 1 to 100 m/s, launch angle from -89 to 89 degrees, and release height from 0 to 200 m.
Projectile motion formulas without air resistance
- Range on level ground: R = v0² · sin(2θ) / g. At the default 25 m/s and 45° that is 63.71 m.
- Time of flight on level ground: T = 2 · v0 · sin(θ) / g, or 3.60 s for the same launch.
- Maximum height: H = h0 + (v0 · sin θ)² / (2g), which works from any release height h0 and gives 15.93 m at the defaults.
- Drag force: Fd = ½ · ρ · Cd · A · v², with ρ fixed at 1.225 kg/m³ here; dividing by mass gives the deceleration along the direction of travel.
- Once drag is included there is no closed-form expression for range or flight time, which is why the simulator steps the motion numerically with RK4 at 0.002 s intervals.
What launch angle gives the maximum range?
On level ground with no air resistance the answer is 45°, because sin(2θ) peaks when 2θ is 90°. The simulator reproduces this: at 25 m/s, sweeping the angle slider shows the longest range, 63.71 m, at 45°.
Two things push the best angle lower. Launching from above the landing point gives the projectile extra time to fall, so a flatter shot travels farther: from a 20 m release with drag off, the best whole-degree angle is 38°, reaching about 81.3 m. Drag has a similar effect, because a high lob spends longer fighting the air; with the default baseball settings and drag on, the optimum drops to about 42° and the range to roughly 46 m.
The double pendulum's real equations of motion
The pendulum uses the standard planar two-mass, two-massless-rod model, with the angular accelerations derived from the Euler-Lagrange equations for this exact system — not a linearized small-angle approximation, which would erase the chaotic behavior that makes a double pendulum interesting in the first place. Mass and rod length are adjustable for each arm — masses from 0.1 to 5 kg, rod lengths from 0.2 to 2 m — and both starting angles run from -180 to 180 degrees measured from vertical. Gravity is not a control: it is fixed at 9.81 m/s², the same value the projectile uses.
Total mechanical energy — kinetic plus potential, computed directly from each arm's velocity and height — is tracked alongside the motion. For a frictionless system that number should stay essentially constant for the whole run; watching it drift is a legitimate way to judge whether the integration step is fine enough for a given configuration, and it is exactly the check used to validate the integrator itself before shipping it.
Double pendulum equations fed to the RK4 stepper
The state is four numbers: the two rod angles θ1 and θ2 (measured from vertical) and their angular velocities ω1 and ω2. Their derivatives are θ1' = ω1, θ2' = ω2, and two angular accelerations from the Lagrangian. With Δ = θ1 − θ2 and D = 2m1 + m2 − m2·cos(2Δ), the code uses α1 = [−g(2m1 + m2)·sin θ1 − m2·g·sin(θ1 − 2θ2) − 2·sin Δ·m2·(ω2²·L2 + ω1²·L1·cos Δ)] / (L1·D) and α2 = [2·sin Δ·(ω1²·L1·(m1 + m2) + g·(m1 + m2)·cos θ1 + ω2²·L2·m2·cos Δ)] / (L2·D).
Those four first-order equations go straight into the same RK4 routine as the projectile. The pendulum advances 30 RK4 substeps per animation frame, each 1/1800 of a second at 60 frames per second, and after every frame it plots the second bob's trail, a θ1-versus-ω1 phase portrait and the kinetic, potential and total energy curves.
Reading the chaos honestly
- Two runs started at angles that differ by a fraction of a degree will track each other closely at first and then diverge completely — that divergence is the actual physics of a double pendulum, not a simulation bug.
- The energy trace is your integrity check: if it visibly climbs or decays over a run, the configuration is pushing the fixed step size past what RK4 can track accurately, most often with very fast, high-energy swings.
- Because both systems are deterministic, replaying the identical starting parameters always reproduces the identical trajectory — nothing here uses randomness.
What these simulators are not built for
- There is no rotational friction, hinge damping or air resistance on the pendulum — it is an idealized frictionless system by design, so its motion will run longer than a real physical pendulum would.
- The projectile model has no wind, spin-induced Magnus force, or altitude-dependent air density — drag here is a single quadratic term, good for demonstrating the qualitative effect of air resistance, not for ballistics-grade prediction.
- Neither simulation is symbolic; there's no way to ask it for a general formula, only a specific numerical trajectory for the parameters you entered.
- Gravity (9.81 m/s²) and air density (1.225 kg/m³) are constants in both simulations, so you cannot model the Moon, Mars or a high-altitude launch by changing them.
Questions people ask about 2D Kinematics & Projectile Physics Simulator
- Why doesn't my projectile follow a perfect parabola when I turn drag on?
- Air resistance in this simulator is a quadratic drag force that always points opposite the current velocity, so it slows the projectile more on the way up (when it's fighting gravity too) than it appears to on the way down. That asymmetry flattens and shortens the trajectory compared to a drag-free parabola, which is the real physical effect the simulation is reproducing.
- What integration method does the double pendulum use, and how accurate is it?
- It uses the same fourth-order Runge-Kutta stepper as the projectile, applied to the pendulum's Euler-Lagrange equations of motion. RK4 is accurate to fourth order in the step size, and the simulation's own energy-conservation trace is the built-in way to see when a particular set of masses, lengths and starting angles is pushing the fixed step past reliable accuracy.
- Why do two nearly identical double pendulum starting angles produce completely different motion?
- That's sensitive dependence on initial conditions, the defining property of a chaotic system, not a simulation artifact. Because the equations are genuinely nonlinear rather than a small-angle approximation, any tiny difference in starting angle gets amplified exponentially over time until the two trajectories share no visible resemblance.
- Can I use this to predict where a real ball will land?
- Only roughly. Drag here is a single quadratic term evaluated at fixed sea-level air density, which ignores wind, spin, changes in air density with altitude and surface roughness effects that matter for real projectiles. It's accurate for demonstrating how drag qualitatively reshapes a trajectory, not precise enough to substitute for a ballistics table or wind-tunnel data.
- How do you calculate the range, time of flight and max height of a projectile?
- Without air resistance and on level ground, range is v0²·sin(2θ)/g, flight time is 2·v0·sin(θ)/g and peak height is (v0·sin θ)²/(2g) above the release point. Those shortcuts break down once drag or a raised launch is involved, which is when the numerical simulation earns its keep.
- What launch angle gives the maximum range?
- 45° is optimal only for a drag-free launch that lands at the height it started from. Releasing from higher up, or adding air resistance, lowers the best angle; drag the angle slider with those settings on and watch which value produces the longest range figure.
- Does mass affect projectile motion?
- Not without air resistance: gravity accelerates every mass equally, which is why the mass slider only appears once drag is ticked. With drag on, a heavier projectile of the same shape and size slows down less, because the same drag force produces a smaller deceleration.
- Can I change gravity or air density, for example to simulate the Moon?
- No. Both simulations use a fixed 9.81 m/s² for gravity, and the drag model uses a fixed 1.225 kg/m³ for air density. The adjustable inputs are speed, angle, release height, mass, drag coefficient and area for the projectile, plus masses, lengths and starting angles for the pendulum.
Related tools on BrakeTools
- Interactive 2D/3D Graphing Calculator — Graph Cartesian, polar, parametric, and implicit curves with live sliders, roots, and tangents.
- Universal Multi-Variable Formula Solver — Type any formula, leave one variable blank, and solve it numerically via Newton-Raphson.
- Universal Unit & Dimensional Converter — Convert between 160 units across 31 physical dimensions, with dimension-mismatched conversions made impossible.
Content reviewed 2026-09-27.