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.
scene two_swings
support beam orientation=horizontal #blue
pendulum short length=0.6m angle=16deg subject=swing #gold
pendulum long length=1.5m angle=16deg subject=swing #red
short <-> beam
long <-> beam
release short playback=6s
release long playback=6s
show path equilibrium motion
Visual motion is compressed to fit the diagram; readouts still use the physical distance.
Playback speed is adjusted; time readouts still show physical time.
Diagram description
Animated physics diagram: Which swing moves faster?.
Closed circuits
Change only open to closed. The circuit becomes complete and the lamp lights.
scene switch_lamp
source V 6V #blue
switch S open #gray
lamp L 6V 3W #gold
V <-> S <-> L <-> VDiagram description
Static physics diagram: Close the switch: why does the lamp light?.
scene switch_lamp
source V 6V #blue
switch S closed #gray
lamp L 6V 3W #gold
V <-> S <-> L <-> VDiagram description
Static physics diagram: Close the switch: why does the lamp light?.
Lens images
As the candle approaches a convex lens, the real image moves farther away and grows larger.
scene candle_lens_distance
object candle height=5cm #gold
lens L type=converging focal_length=10cm #blue
candle images through L 35cm #red
drive candle object_distance=16cm duration=5s
show principal_rays image_distance magnification
Visual motion is compressed to fit the diagram; readouts still use the physical distance.
Diagram description
Animated physics diagram: Move the candle: where does the image go?; showing object distance, image distance, magnification.