A tough, but cool, way ...
First, have a velocity for every point. Then, have 'connectors'--ie, lines--between them. Different connectors can have different elasticity if you want--make sure to store the ideal length of the connectors, though.
Ok. It's a fairly simple matter to calculate the distance between two points:
Code:
xd = x1 - x2
yd = y1 - y2
zd = z1 - z2
dist = Sqr (xd * xd + yd * yd + zd * zd) 'Sqr is *very* slow! If you can get rid of it, do so.
With the distance, you can find out the ratio of how far apart they *are* to how far apart they *should* be. Find the midpoint, and then accelerate both endpoints towards the midpoint as necessary.
Code:
'I'll try to keep this simple ...
ratio = connect(t) / dist
xa = (x1 + x2) / (2 * elastic) * ratio 'Note: you can double all elastic values and drop the "/ (2 * elastic)" to "/ elastic"
ya = (y1 + y2) / (2 * elastic) * ratio
za = (z1 + z2) / (2 * elastic) * ratio
xv1 = xv1 + xa
yv1 = yv1 + ya
zv1 = zv1 + za
xv2 = xv2 - xa
yv2 = yv2 - ya
zv2 = zv2 - za
That should work, or be close. It may not be quite right. Not sure right at the moment ...
You can give each point a different mass fairly easily.