kottke.org

...is a weblog about the liberal arts 2.0 edited by Jason Kottke since March 1998 (archives). You can read about me and kottke.org here. If you've got questions, concerns, or interesting links, send them along.

Magnetic snakes

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)

By Jason Kottke    Apr 2, 2009 at 02:50 pm    Processing   Robert Hodgin   video

kottke.org, quickly...

The best way to get a sense of what kottke.org is all about is to head to the front page or check out some random entries from the archives. Follow kottke.org via RSS or Twitter.

Want to share your something special with kottke.org's readers? Sponsor the RSS feed for a week!

Looking for work?

See more on the Job Board.

Recommended sites

David Archer    Matthew Paul Thomas    Rebecky    greg.org    jimr(ay)    evhead    panopticist    strange maps    Nivi    Type for you.    Airbag    Ikeepadiary    The Pop!Tech Blog    Eater    tremble.com    Frumination    Personism    NYT Science    Idle Words    The Laboratorium