PhysLoomPhysics-as-Code

Physics as code

Build physics models in code

Write down bodies, relationships, and motion, then get a physics model you can edit and play.

Pendulum timing

Release a long and a short pendulum together. The shorter one completes more swings in the same time.

two-swings.phys
scene two_swings

support beam orientation=horizontal #blue
pendulum short 0.6m 16deg subject=swing #gold
pendulum long 1.5m 16deg subject=swing #red

short <-> beam
long <-> beam

animate duration=3s speed=0.5
show short.path short.equilibrium long.path long.equilibrium
Which swing moves faster? Static pendulum diagram L = 0.6m short L = 1.5m long
time 0s Playback speed is adjusted; time readouts still show physical time.
Diagram description

Animated physics diagram: Which swing moves faster?; showing time.