-
Notifications
You must be signed in to change notification settings - Fork 0
kalenedrael/swarm
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
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.
About
flying thingsssss
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published