Home / Blog / Engineering & Physics

Vertebrate Physics on Screen: Simulating Real Pendulum Dynamics at 60 FPS

Behind NallaNeram Charm’s swaying charms lies Verlet numerical integration, catenary cord curvature, and angular drag coefficients. How we tuned 60 FPS physics to consume less than 0.2% CPU.

Vertebrate Physics on Screen: Simulating Real Pendulum Dynamics at 60 FPS

The Physics of Delight: Beyond Static Images

What separates a lifeless desktop widget from an organic, tactile screen companion? The answer is physics simulation fidelity. If a digital charm merely swings back and forth using a linear CSS keyframe loop, the human visual cortex instantly flags it as artificial and tunes it out.

To make NallaNeram Charm feel like a genuine physical talisman suspended from your screen bezel, developer Sarangan Raviraj engineered a dedicated Newtonian pendulum physics engine in lightweight JavaScript.

Mathematical Foundations of the Cord Simulation

The core simulation solves the second-order differential equation for a damped physical pendulum:

θ''(t) + (b / m) θ'(t) + (g / L) sin(θ) = 0

Where:

  • θ is the angular displacement from the vertical normal
  • g is gravitational acceleration (tuned to 0.0035 for tactile weight)
  • L is the effective cord suspension length
  • b is the aerodynamic damping coefficient (tuned to 0.985 for natural decay)
Catenary Curve Cord Rendering: Rather than drawing a stiff straight line, NallaNeram Charm computes dynamic SVG quadratic Bezier anchor points (M x1 y1 Q cpx cpy x2 y2), bending the hanging cord realistically based on instantaneous angular velocity and acceleration!

Optimizing for 0.2% CPU Consumption

To ensure NallaNeram Charm never slows down code compilation or video editing timelines, the rendering loop utilizes intelligent sleep states:

  • Automatic At-Rest Sleep: When angular displacement drops below 0.0001 rad and velocity ceases, requestAnimationFrame halts completely.
  • Event-Driven Wakeup: Cursor proximity, window moves, or clicking immediately wakes the loop with zero latency.
  • GPU Composited Transforms: The charm image is positioned exclusively via transform: translate3d() and SVG matrix rotation, triggering zero layout recalculations.

The result is a silky 60 FPS suspension companion that feels as real as physical brass hanging from your screen.

SR

Written by Sarangan Raviraj

Independent software engineer and creator of NallaNeram Charm. Passionate about authentic cultural preservation, tactile desktop interfaces, and building 100% free open-source software under the MIT license. Connect on GitHub or X (Twitter).

Hang this charm on your screen today

40 authentic cultural charms, soothing physics, and zero distractions. Free forever for Mac, Windows, and Mobile Lock Screen.