Wave 55 at a glance
Polyhedra Explorer
All 5 Platonic and 13 Archimedean solids rendered with perspective projection. Drag to rotate, scroll to zoom, toggle wireframe and vertex labels. Euler's formula V−E+F=2 verified live.
Open simulation →Fish School 3D
200 fish governed by Boids separation, alignment, and cohesion with three depth layers for pseudo-3D realism. A shark predator hunts the school, triggering panic-flee behaviour within 110 px.
Open simulation →SPH Dam Break
300 particles governed by SPH pressure, viscosity, and gravity. A dam of water collapses and washes across the container. Colour by speed, pressure, or density.
Open simulation →๐ท Polyhedra Explorer
Polyhedra โ three-dimensional solids bounded by flat polygonal faces โ are among the most studied objects in mathematics. The ancient Greeks classified the five Platonic solids: convex polyhedra whose faces are all congruent regular polygons and whose vertices are all equivalent. Archimedes extended this to 13 Archimedean solids: convex polyhedra with two or more types of regular polygon faces but still vertex-transitive.
Euler's polyhedron formula
Leonhard Euler (1752) discovered that for any convex polyhedron โ indeed for any simply-connected polyhedral surface homeomorphic to a sphere โ the counts of vertices V, edges E, and faces F satisfy:
The formula generalises: for a surface of genus g (a torus has g=1,) the Euler characteristic is 2−2g. A torus satisfies V−E+F=0. This connection between combinatorial properties (vertex/edge/face counts) and topological properties (genus) is a cornerstone of algebraic topology.
The five Platonic solids and their symmetry groups
The Platonic solids correspond to the finite rotation groups of 3D space. Their symmetry groups are the same as those of the rotational symmetries of these solids:
- Tetrahedron โ T symmetry (chiral tetrahedral), 12 rotations.
- Cube and Octahedron โ O symmetry (octahedral), 24 rotations. These two are duals of each other.
- Dodecahedron and Icosahedron โ I symmetry (icosahedral), 60 rotations. Also duals.
There are only five because the requirement for a regular convex solid limits the possible combinations of regular polygon faces meeting at a vertex: the sum of face angles at each vertex must be strictly less than 360ยฐ. Only triangles, squares, and pentagons produce valid solutions before this angular deficit runs out.
Perspective projection on Canvas 2D
The simulator uses a pure Canvas 2D perspective projection: each 3D
vertex (x, y, z) is first rotated by two quaternion-derived
matrices (yaw and pitch, updated each drag tick), then projected to
screen with
sx = cx + fยทX/(Z+d), sy = cy + fยทY/(Z+d) where
f is the focal length and d is the camera
offset. Faces are painter-sorted by their centroid Z coordinate to give
correct depth ordering.
๐ Fish School 3D — Boids with Predator
In 1986 Craig Reynolds published Boids โ a deceptively simple model that produces strikingly lifelike flocking behaviour from just three local rules. No global coordinator directs the flock; each agent reacts only to its neighbours within a perception radius. The emergent result looks indistinguishable from a real starling murmuration or anchovy school.
The three Boids rules
- Separation โ steer away from neighbours within radius rsep to avoid collisions.
- Alignment โ steer toward the average heading of neighbours within rali.
- Cohesion โ steer toward the centre of mass of neighbours within rcoh.
The net steering force at each tick is a weighted sum:
Depth layering for pseudo-3D
Canvas 2D runs a 2D Boids simulation, but three depth layers simulate the three-dimensional structure of a real fish school. Surface fish (layer 0) are drawn larger and in lighter cyan; mid-water fish (layer 1) are medium-sized in ocean blue; deep fish (layer 2) are smaller and dark navy. The layers use slightly different Boids radii so they maintain distinct sub-schools while still influencing each other through the cohesion and alignment radii.
The predator shark
The shark is a single agent with a dedicated hunting behaviour:
-
Each tick the shark steers toward the nearest fish within
huntRadius. -
Fish within
panicRadius(110 px) enter panic mode: their separation weight spikes and they add a strong flee vector directly away from the shark. - Panicking fish turn yellow โ in real anchovy schools, pale coloration under stress is a documented phenomenon possibly related to reduced iridophore activation.
- If the shark catches a fish (distance < 8 px), the fish respawns at a random edge, mimicking the statistical near-constancy of school size despite predation.
Cluster counting
The stats panel reports the number of distinct clusters each frame. Cluster membership is determined by a simple union-find: two fish are in the same cluster if their mutual distance is below the cohesion radius. During normal flocking the count is typically 1โ3; during a shark attack it often spikes to 6โ10 as the school fragments.
๐ง SPH Dam Break — Smoothed Particle Hydrodynamics
Smoothed Particle Hydrodynamics (SPH) was invented simultaneously and independently by Lucy (1977) and Gingold & Monaghan (1977) to simulate astrophysical phenomena such as stellar collisions. Unlike grid-based (Eulerian) methods, SPH is fully Lagrangian: the fluid is discretised into particles that carry mass, velocity, and thermodynamic variables. No mesh is required; the particles themselves define the computational domain.
The SPH approximation
Any field quantity A at position r can be approximated as a weighted sum over neighbouring particle contributions:
Pressure and viscosity forces
First, density is computed for every particle from the Poly6 sum. Then pressure is derived from a simple equation of state:
The pressure force on particle i from all neighbours j is:
Stability: substeps and damping
The simulation runs 3 substeps per animation frame with a fixed
dt = 0.004 s. Boundary elastic reflection
uses a damping factor of 0.4 so kinetic energy is removed on wall
contact โ modelling the inelastic nature of real concrete/fluid
boundaries. For N ≤ 600 the O(Nยฒ) neighbour search runs in a single
JS loop at 60 fps on modern hardware; grid-acceleration (spatial
hashing) would extend the cap to ~5000 particles.