Magnetic snakes  APR 02 2009

Taking a bit of code from here and a snippet from there, Robert Hodgin made an animation of 3-D snakes in Processing. Check out Hodgin's use of constraints to spur the invention of a way to keep the snakes from overlapping.

I had no interest in adding a complete 3D physics library because my needs at this time are fairly simple. I am not worried about environment... I just want the snakes to crawl over each other. I decided to try magnetic repulsion despite thinking it probably wouldn't work well enough. The thinking is this: Take each segment of a snake (200 segments each), and check its distance to every single other segment of every other snake on screen. Stupid, right? Yeah, pretty much. But with some optimization and only checking the segment distances if the snakes in question are close enough for overlap to be possible, I got it to run at 60 fps with 10 snakes.

Actually, when you get right down to it -- the atoms in snakes' bodies, that is -- magnetic repulsion isn't that far off from how matter achieves its electromagnetic opacity. Hodgin also made a video in which the snakes react to music. I wonder if this one's gonna end up in iTunes. (via waxy)

Read more posts on kottke.org about:
Processing   Robert Hodgin   video

this is kottke.org

   Front page
   About + contact
   Site archives

You can follow kottke.org on Twitter, Facebook, Tumblr, Feedly, or RSS.

Ad from The Deck

We Work Remotely

 

Enginehosting

Hosting provided EngineHosting