2009-02-05, 10:23 PM
![[Image: springmotion4wr8.jpg]](http://img80.imageshack.us/img80/2843/springmotion4wr8.jpg)
I've been putting this together just for fun, but I'm not completely happy with how it works.
The balls are point masses, the lines act like ideal springs (F = -xk) and I'd got a bit of a workaround for the damping coefficient so I'm kinda looking for physics / programming advice.
Currently the damping pseudocode looks kinda like this
Code:
get velocity of 2 end points
project both onto the direction of the spring
use that component to find a weighted average
end1 = c*(end2-end1) type thing
subtract this from each end velocity so they get closer to each otherIt seems to work out pretty well (as seen above) I'm just not sure how physically accurate it is.
I know the damping on a spring drops velocity by a constant, but that's taking 1 end to be fixed, which I can't really do with multiple linked springs.
Also I'm in need of an efficient intersection algorithm (to test when 2 balls collide) so any advice there would be nice too.
And if there's some way to somehow render these to a seperate layer instead of the background so it doesn't keep every iteration that would be helpful too. Right now (aside from screenshot above, where I disabled it to show how it animates) I'm overwriting the entire panel with a white rectangle between every iteration and this is kinda slow.

