|
|
very short explanation:
(forward) Euler: simplest way of 'simulating' the behaviour of
grids/clothes. Just a step-by-step simulation that is very easy to code. The
steps have to be very small otherwise the grid/cloth will show weird and
erratic movements.
Runge-Kutta: slightly more complicated than Euler, but still not too
difficult to do. Time steps can be bigger and things will work fine.
Think about this: if all the connections between the nodes are incapable of
becoming longer/shorter the grid won't be able to bend in all directions. It
would be able able to bend in U, or V directions only. So If you'd drop the
grid over a sphere, the grid won't be able to fold over the sphere in a nice
way unless some parts of the grid are able to compress/expand.
How I started:
1. write povscript code with only 1 line of particles (about 30) with the
first locked (incapable of moving). Between each 2 particles I put a
connection (spring) that pulls those 2 particles together when they're too
far away. The spring pushes the 2 particles away from eachother when they're
too close. The spring force function is a linear function (imagine a
straight line from the third quadrant to the first with x=dispositioning of
particle and y=spring_force).
2. discover that with more particles povscript is a bit slow ;-)
3. port the thing to another programming language (c, c++, pascal, fortran?)
and increase the amount of springs. Example: particles A, B, C and D. Lowest
amount of springs possible: 3 (A-B, B-C and C-D). Increase the amount of
springs between particles and the thing will be stronger: A-B, A-C, B-C,
B-D, C-D.
And if you have a grid of 3x3 those will be the particles: A(0, 0), B(1, 0),
C(2, 0), D(0, 1), E(1, 1), F(2, 1), G(0, 2), H(1, 2), I(2, 2). The springs
in case the thing is supple: A-B, A-D, A-E, B-C, B-D, B-E, B-F, C-E, C-F,
D-E, D-G, D-H, E-F, E-G, E-H, E-I, F-H, F-I, G-H, H-I. (Hope I didn't forget
something.)
Calculating the forces is more efficient if you do it spring-by-spring
instead of particle-by-particle of course.
Collission detection with spheres is simple: if the distance between the
center of a sphere and a particle is smaller than or equal to the sphere's
radius, you're having a collission. Adding a temporary spring between the
colliding particle and the sphere's surface will prevent the particle to
enter the sphere. (In fact the system should detect the collission BEFORE
the happens, so you'll have to increasing the sphere's radius a bit.) There
are other ways of handling collission detection that are less simple but
maybe more interesting since the spring like grid-object collissions don't
involve friction IIRC.
--
Apache
http://geitenkaas.dns2go.com/experiments/
apa### [at] yahoocom
Post a reply to this message
|
|