Chemical Patterns
Spots and branching shapes form as two substances react and spread. A simple reaction-diffusion model.
Published
No video preview yet
Source
use "@hyle/maths";
use "@hyle/random";
use models { Reaction, Vessel };
// A 45-cell-diameter volume, not a surface shell or repeated planar layers.
place Reaction in sphere([0,0,0],22.0) {
let distance=position.x*position.x+position.y*position.y+position.z*position.z;
set target.injector=maths::exp(-distance/9.0);
}
// Seven deposits distributed along all three axes; deterministic microscopic noise
// breaks exact symmetry without prescribing any subsequent pattern or trajectory.
for k in -1..2 {
for j in -1..2 {
for i in -1..2 {
if i*i+j*j+k*k <= 1 {
set Reaction in sphere([i*10,j*10,k*10],4.0) {
let key=random::key(91,[position.x,position.y,position.z],0,0);
set self.a=0.5;
set self.b=0.25+random::uniform(key,0,-0.02,0.02);
}
}
}
}
}
// Three open reference rings show the vessel's extent without an opaque wall.
place Vessel in (sphere([0,0,0],24.0)-sphere([0,0,0],23.0))
when position.x == 0 || position.y == 0 || position.z == 0;