Join GitHub today
Fetching latest commit…
Cannot retrieve the latest commit at this time.
|Failed to load latest commit information.|
This is a simple flocking simulation using the Boids algorithm. Originally written for 15-462. Could be adapted into a screensaver, if anyone even uses those anymore. Controls: w,s - move goal point into/out of screen a,d - move goal point left/right q,e - move goal point up/down f - randomly select new goal point on surface of sphere g - toggle follow cam r - reset simulation x - toggle integrator (euler (default) -> midpoint -> RK4) ==================================================== Algorithm overview ==================================================== Forces are calculated as follows: - cohesion: linear with distance to each tile up to CO_DIST - separation: inverse square of distance to each tile up to SEP_DIST and clamped by SEP_MAX - alignment: the component of the average velocity of the surrounding tiles up to ALIGN_DIST that is normal to the current velocity - goal-seeking: linear toward the goal minus the current velocity All weights are as specified at the top of tile.c; separation weight increases with velocity to make the swarm expand as it is moving toward a goal. Banking is done by rotating the things by the arctangent of the magnitude of the lateral force over the up-vector; more lateral force means angle of rotation closer to 90 degrees. ==================================================== Notes ==================================================== Tiles are colored by their velocity for an interesting effect. Try changing NTILES in tiles.c for different effects.