Skip to content

McAi / Physics lab

Nothing here is keyframed.

Nine simulations where every position falls out of an integrator, not a tween: a Valheim-style wall that loses its footing block by block, comets bent by Newton's exact 1/r² law, twelve pendulums drifting into a wave, and Diablo-style isometric scenes where a hero displaces water, flattens grass and bursts a chest. Each frame is path-traced offline to a looping GIF - pure C#, no game engine.

Newtonian gravity (1/r²) RK4 + impulse collisions 2D wave-equation PDE OnlyCSharp 1.7, BCL-only
9live simulations
1/r²real force law
Path-tracedevery frame
0external assets

Destruction and gravity

Five scenes governed by real force laws

Rigid-body impulse, structural cascade, and three-body Newtonian gravity - integrated, then rendered.

A ball fires into a stacked wall of coloured blocks, which topple.

Rigid-body impulse

Block tower knockdown

A 4 kg ball fires into a wall of unit-mass blocks. Each block is an immutable Body integrated under uniform gravity and linear drag; the strike transfers a normal impulse (restitution e = 0.45) and the stack collapses.

240 x 180 - 30 frames
A brick wall struck by cannonballs collapses as unsupported blocks fall free.

Structural cascade

Valheim-style collapse

Every block tracks its mass, health and which neighbours hold it up. Knock out a supporter and the block loses its footing and drops as a free body under gravity. Five cannonballs fire on staggered timers and the wall cascades into a ragdoll of debris.

280 x 210 - 48 frames
An icy comet whips around a glowing planet on a hyperbolic arc, leaving a fading trail.

Orbital mechanics

Gravitational slingshot

A 1-unit comet on a hyperbolic flyby past a 350-mass planet, driven by Newton's exact 1/r² attraction (Forces.NewtonGravity, G = 20). The ghost trail traces the true conic arc; the tiny recoil is booked back onto the planet, so momentum stays conserved.

280 x 210 - 60 frames
Twelve rainbow pendulums of graded length swing into travelling and standing wave patterns.

Nonlinear dynamics

Pendulum wave

Twelve pendulums with lengths tuned so pendulum k runs (10 + k) swings in 12 s, all released together. Each is the full nonlinear ODE theta″ = -(g/L) sin theta, stepped by RK4 - no small-angle cheat - so the travelling, standing and burst patterns are genuine phase drift.

280 x 210 - 80 frames
A ring of orbiting particles is stretched into a stream as a massive body sweeps past.

N-body gravity

Tidal disruption

A 20-body cluster on circular orbits around a 30-mass core is torn into a tidal stream when a 600-mass perturber sweeps by. Every pair feels Newtonian gravity, so near-side particles are pulled harder than far-side and the cluster elongates.

280 x 210 - 60 frames

Diablo-style / isometric

Four ARPG scenes, each a real solver

A 45° isometric camera over four game moments where the world reacts to the hero - displacement, springs, impulse and a wave PDE.

An isometric hero wades through a pool, pushing particles into a bow wave and wake.

Fluid displacement

Wading through water

The hero pushes through a ParticlePool: the body volume shoves particles aside into a bow wave, splash and a trailing wake. Every droplet position comes out of the integrator.

240 x 178 - 48 frames
A hero runs across a grass field; blades bend away underfoot and spring back.

Damped springs

Grass underfoot

Each blade is a damped torsional spring solved as its own ODE, driven by SimplexNoise2D wind and a radial shove from the passing hero, then springing back to vertical once he clears.

240 x 178 - 48 frames
A chest bursts and showers loot items that bounce and settle on the ground.

Impulse and restitution

Loot burst

A chest bursts and fans items out on a velocity spread. Each piece falls under gravity and bounces with its own restitution - impulse law j = -(1 + e) · v_rel · n / (1/m_a + 1/m_b) - until it comes to rest.

280 x 208 - 60 frames
A hero's footsteps radiate concentric ripples across a pool that reflect off the walls.

Wave equation

Ripple pool

A genuine 2D wave PDE ∂²h/∂t² = c²∇²h on a finite-difference grid, sub-stepped to honour the CFL condition, with reflective (Neumann) walls so the hero's footstep ripples bounce off the pool edges and interfere.

240 x 178 - 52 frames

How it works

Integrators in, path-traced pixels out

Each scene runs a small solver every frame - a Body under Forces.UniformGravity and Forces.LinearDrag, Newtonian NewtonGravity between bodies, an Rk4Step pendulum, a finite-difference wave field - then hands the resulting positions to the OnlyCSharp 1.7 ray tracer, which path-traces the shot and writes it into an animated GIF. No positions are lerped and no frames are hand-drawn.

Everything leans only on the frozen OnlyCSharp 1.7 libraries - PhysicsAndAstronomy.Physics, Mathematics.Fast.Dynamics, ComputerGraphics.RayTracer and ComputerGraphics.ImageCodecs - which depend on nothing outside the .NET base class library. The collision impulses use the standard normal-impulse law, the wave field honours its CFL condition with reflective walls, and the gravity flybys conserve momentum. The physics is auditable line by line; the renders below are just what those numbers look like.