Got that far, but I can't seem to get the 1d collision to act realistically.
First I calculate the projection onto the vector (dx,dy) - the difference in centre - for the 2 particles (v, ov). Then subtract the average speed (I'm not sure this is done properly but I went with what works, doing this in other order led to problems) then multiply each by weight(m) to get momentum, then swap those, then find the overall change.
I think the main trouble I have is that when 2 particles are traveling the same way, with a smaller one following, it'll keep bouncing off the surface of the larger and then swinging back (due to gravity/pendulum) but I've never really tested these irl so, I don't know if that's correct.
![[Image: springmotion11zd4.png]](http://img7.imageshack.us/img7/8060/springmotion11zd4.png)
Every frame where a collision is detected is coloured red, you can see they only make contact about every 10. In the other direction (big following small) they stay closer together, with contact every 2nd frame.
Normally looks like this, I just disable the overwriting to make the animation paths clear.
![[Image: springmotion12ie7.png]](http://img228.imageshack.us/img228/2586/springmotion12ie7.png)
I'd also like to add rotational speed via these collisions, I think it would just be radius*angular v = surface velocity, combine that and the relative motion of the 2 to get a difference in surface speed, and use some sort of friction model to speed up/slow down the rotation speed.
Code:
double rate = (dx*vx + dy*vy)/(Math.pow(dx,2)+Math.pow(dy,2));
double orate = (dx*ovx + dy*ovy)/(Math.pow(dx,2)+Math.pow(dy,2));
// average
double arate = (rate+orate)/2;
// mass weighted
double rm = m*(rate-arate);
double orm = om*(orate-arate);
// elasticity
double a = 0.1;
// new vector other's v avg to balance
double ir = a*(orm-rm)/(m)+arate - rate;
double oir = a*(rm-orm)/(om)+arate - orate;
vx += ir*dx;
vy += ir*dy;
ovx += oir*dx;
ovy += oir*dy;I think the main trouble I have is that when 2 particles are traveling the same way, with a smaller one following, it'll keep bouncing off the surface of the larger and then swinging back (due to gravity/pendulum) but I've never really tested these irl so, I don't know if that's correct.
![[Image: springmotion11zd4.png]](http://img7.imageshack.us/img7/8060/springmotion11zd4.png)
Every frame where a collision is detected is coloured red, you can see they only make contact about every 10. In the other direction (big following small) they stay closer together, with contact every 2nd frame.
Normally looks like this, I just disable the overwriting to make the animation paths clear.
![[Image: springmotion12ie7.png]](http://img228.imageshack.us/img228/2586/springmotion12ie7.png)
I'd also like to add rotational speed via these collisions, I think it would just be radius*angular v = surface velocity, combine that and the relative motion of the 2 to get a difference in surface speed, and use some sort of friction model to speed up/slow down the rotation speed.

