3 ms·
Can anyone speak to what's going on in these algorithms? I'm interested in the physics/math behind them. For example, how much about partial differential equati
by j2kun 14y ago
Can anyone speak to what's going on in these algorithms? I'm interested in the physics/math behind them. For example, how much about partial differential equations do I need to know to understand them?
- efraim 14y agoIt's very simple really. It's a grid of point masses with constraints between them (the lines you see) that says to keep the points at a constant distance from each other. Think of the constraints as springs that follow Hooks law[1], only infinitely stiff. You iterate through all the constraints and move the two points of each constraint apart if they are too close, or closer if they are too far apart. You need some basic linear algebra for the distance and direction calculations. It's common to use verlet integration to actually move the points because it's so easy do solve the constraints with it. Add some gravity and it looks very convincing. To tear the "cloth", all you need to do is to remove those particular constraints from the list. [1] http://en.wikipedia.org/wiki/Hooke%27s_law http://en.wikipedia.org/wiki/Hooke%27s_law
- gknoy 14y agoOne of the things I love about encountering things like this on HN are comments like these, which are even more informative than the original post. I'd seen the demo in the OP, and thought, "neat". Later on, I read comments that say, "Oh, you just need to ___ the ___ with ___, and use ___'s Law to ____ for the whole grid" --- most of which is completely over my head. In some perspectives this might seem discouraging -- trivializing the difficulty of learning it. However, I find it tremendously invigorating: the idea that it's simple for someone with the right learning and knowledge means that it's something I could do to, if I wanted to spend the time to learn it. Thanks for posting comments like this. It opens my eyes to questions I didn't even know I had. ("What's a verlet?" "Oh man, I need to re-learn my linear algebra someday...")
- sehugg 14y agoProbably something similar to this: http://gamedev.tutsplus.com/tutorials/implementation/simulate-fabric-and-ragdolls-with-simple-verlet-integration/ http://gamedev.tutsplus.com/tutorials/implementation/simulat...
- dhotson 14y agoYou can achieve most of this with Euler integration to update the positions and velocities of the points—as well as Hooke's law to simulate the connections as a grid of tiny little springs. I've used similar algorithms in a graph layout library of mine: http://getspringy.com/ http://getspringy.com/
- walrus 14y agoYou don't need to know much (if anything) about PDEs. If you've taken an undergrad class in classical mechanics, you'll do just fine. If you're interested specifically in game physics using Verlet integration, http://web.archive.org/web/20100111035201/http://www.teknikus.dk/tj/gdc2001.htm http://web.archive.org/web/20100111035201/http://www.tekniku... is a nice reference. Most of the springy-cloth demos use Verlet integration. Here's a short series on 3D game physics that doesn't rely on a Verlet integration scheme: http://gafferongames.com/game-physics/ http://gafferongames.com/game-physics/. The advantage here is you get a more general ODE solver. It's a little bit more tricky to get right, though. Once you dig a bit deeper into it, you'll find that the hard part is collision detection/response. A nice intro is the two tutorials at http://www.metanetsoftware.com/technique.html http://www.metanetsoftware.com/technique.html. An in-depth reference is Real-Time Collision Detection by Christer Ericson. A community related to this is http://www.bulletphysics.org/Bullet/phpBB3/ http://www.bulletphysics.org/Bullet/phpBB3/.