To accurately calculate the acceleration of both swinging arms over time without breaking down complex tension forces, we use the Lagrangian formulation of mechanics (Energy instead of Forces): L = T - V (where T is kinetic energy and V is potential energy).
// Angular Acceleration of Top Arm (θ1):
num1 = -g * (2 * m1 + m2) * sin(θ1)
num2 = -m2 * g * sin(θ1 - 2 * θ2)
num3 = -2 * sin(θ1 - θ2) * m2 * (v2² * L2 + v1² * L1 * cos(θ1 - θ2))
den = L1 * (2 * m1 + m2 - m2 * cos(2 * θ1 - 2 * θ2))
a1 = (num1 + num2 + num3) / den
These differential equations are recalculated on every single frame, adjusting the angular velocities, which adjust the angles, which draw the path on the screen.