Starling Murmuration. November 2024, Florence, Italy
I was in Florence for the day, on vacation from WASP 3D to see the city’s ceramists, and was transfixed by the motion above. I followed these small starlings to a square and stared for hours. They moved with such coordination, creating fleeting organic shapes only to disperse then fold back together. When the birds twist to expose their sides, their form appears; but, as they turn to point away or toward the camera, they seem to disappear.
I wanted to capture the beauty I observed. The following algorithm is derived from past work by Craig Reynolds and V. Hunter Adams.
The algorithm considers individual boid (named after bird-oid object) movement to model the flock’s behavior. We will consider one boid (orange), its immediate neighbors (red), its further neighbors that it can see (blue). The other birds (purple) are outside the boid’s visual range.
The simulation balances social dynamics with environmental constraints using the following factors:
To avoid costly square root operations, neighborhood detection relies on squared Euclidean distance:
$$dist^2 = \Delta x^2 + \Delta y^2$$
For every boid $i$, the velocity $\vec{v}$ is updated by summing the primary steering vectors:
Scouts utilize linear interpolation to steer horizontal velocity ($v_x$) toward a goal ($G$) based on their increasing biasVal:
$$v_{x\_new} = (1 - \text{bias}) \cdot v_x + \text{bias} \cdot G$$
A penalty method applies steering forces proportional to the depth of penetration into the screen margins:
$$\text{Force} = \text{turnFactor} \times \left( \frac{\text{depth}}{\text{margin}} \right) \times 5$$
Note: I used html, javascript, & CSS; all code was developed by myself + AI collaboration.