# Create an animate of an elastic collision with Manipulate?

Posted 4 months ago
719 Views
|
2 Replies
|
1 Total Likes
|
 I am trying to animate an elastic collision and I don't how to code to describe the motion after the impact. Here's where I'm at right now: S1i[t_, V1i_] := 0.2 + t*V1i; S2i[t_, V2i_] := 0.8 + t*V2i; S1f[t_, V1f_] := t*V1f; S2f[t_, V2f_] := t*V2f; V1f[m1_, m2_, V1i_, V2i_] := 2 (m1*V1i + m2*V2i)/(m1*m2) - V1i; V2f[m1_, m2_, V1i_, V2i_] := 2 (m1*V1i + m2*V2i)/(m1*m2) - V2i; ts := (0.6 - r1 - r2)/(V1ie - V2ie); y = 0.4; r1 = 0.06; r2 = 0.06; V1ie = 0.2; V2ie = -0.1; m1e = 0.03; m2e = 0.03; V1fe = 2 (m1e*V1ie + m2e*V2ie)/(m1e*m2e) - V1ie; V2fe = 2 (m1e*V1ie + m2e*V2ie)/(m1e*m2e) - V2ie; xy[t_] := {S1i[t, V1ie], y}; zy[t_] := {S2i[t, V2ie], y}; py[t_] := {S1f[t, V1fe], y}; qy[t_] := {S2f[t, V2fe], y}; traj1 = Table[xy, {t, 0, ts, 0.1}]; traj2 = Table[zy, {t, 0, ts, 0.1}]; traj3 = Table[py, {t, ts, 15, 0.1}]; traj4 = Table[qy, {t, ts, 15, 0.1}]; Manipulate[ Show[ListPlot[traj1], ListPlot[traj2], ListPlot[traj3], ListPlot[traj4], Graphics[{ Black, Circle[xy[t], r1], Red, Circle[zy[t], r2]}], AspectRatio -> Automatic], {t, 0, 10}] where S1f and S2f describe the motion after the impact of the Black Circle and the Red Circle, respectively. Also, ts is the time of the impact. I should also mention that whatever I'd tried didn't lead anywhere.One more question: why doesn't the animation stop at the point of impact unless \I set the ruler to be {t,0,ts} in the Manipulate function. Shouldn't it stop because of this piece of code?: traj1 = Table[xy, {t, 0, ts, 0.1}]; traj2 = Table[zy, {t, 0, ts, 0.1}]; Thank you in advance, and I am begging you to be somewhat thorough with your answer as I've just started using Mathematica. :) Answer
2 Replies
Sort By:
Posted 4 months ago
 Crossposted here. Answer
Posted 4 months ago
 I've written a "simulator" to do that once.You could use iteration and vectors of speed.Each partial has a position, a direction, speed that is updated "per turn".When all particles are updated, it would move it's share of amount because it was updated due to the collisions. Of course, it's all done in vectors so the speed has a vector / directionThat's one way to do it.But be aware this is an "over solved problem", may people have done it already, there are more advanced ways to do things (including whole solar simulators and rendering platforms to visualize events). Answer