Sunday, July 21, 2013

Balls

     A giant pile of balls, neatly stacked into the hexagonal formation that all circles love to pack themselves into. This has been my goal for today. Not a big goal, but one that has successfully distracted me from working on something harder and more important, like the Marker And Cell simulation that I am probably going to finish (read: begin) around 2020.
     So. I have made rigid body ball simulations before, but they used Euler integration, and thus were not very stable. And, to simulate a giant pile of balls, you need stability. So, I had to find a better way. The way I found was Verlet Integration (could you have guessed).
     Verlet Integration, the process by which acceleration, position, and position  ago. This is, for some reason that I don't really understand, a really stable way of integrating the equations of motion.
     So that was the integration scheme I chose, and the rest of it turned out to be fairly simple: correct the balls positions to account for overlap, fix velocities to preserve impulses (a problem with Verlet as it turns out), and then do it again a few times to approach truly rigid bodies.
     So here's the actual demonstration. Warning, it could be stabler, drag around the balls and it might explode. It is also un-optimized, so I could have a lot bigger pile that I do right now, but, work in progress, here it is:
https://sites.google.com/site/stylustechnology/recent-stuff/balls

No comments:

Post a Comment