Dynamics Equations & Numerical Notes

Mathematical model used by the browser-side 2-DOF planar pendulum simulator and offline trajectory logs.

LAGRANGIAN

Generalized Equations of Motion

For a multi-link articulated mechanism with joint coordinates q and applied torques tau:

M(q) * qdd + C(q, qd) * qd + g(q) = tau - D * qd

Where M(q) is the symmetric positive-definite inertia matrix, C(q, qd) captures centrifugal and Coriolis coupling, and D denotes viscous joint damping.

RK4

Fourth-Order Runge-Kutta Step

Given state vector y = [θ₁, θ₂, ω₁, ω₂] and derivative function f(y) with fixed substep dt = 0.004 s:

k1 = f(y)
k2 = f(y + 0.5 * dt * k1)
k3 = f(y + 0.5 * dt * k2)
k4 = f(y + dt * k3)
y_next = y + (dt / 6) * (k1 + 2*k2 + 2*k3 + k4)
PARAMETERS

Default Sandbox Configuration

SymbolDefaultUnit / Meaning
m₁, m₂1.4, 1.0kg · Link end masses
L₁, L₂0.92, 0.86m · Link lengths
g9.81m/s² · Gravitational acceleration
dt0.004s · RK4 substep (4 substeps per frame)