Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'collision effect in 3D' topicStudent Support Forum > General > "collision effect in 3D"

Help | Reply To Topic
Author Comment/Response
philbertz
11/17/03 4:02pm

whilst looking on the internet i found a 2D animation showing an elastic collision and the momentum of the two circles before and after the collision and I'm interested in trying to change this into a 3D animation with spheres travelling up the z axis instead of circles travelling up the y axis. The current code looks like this:

eqns = {m1 v1+m2 v2==m1 v3+m2 v4, m1 v1^2+m2 v2^2==m1 v3^2+m2 v4^2}
sols = Solve[eqns, {v3, v4}]
vsol = sols〚2〛
eqns2 = {xc1==x10+v1 tc, xc2==x20+v2 tc, xc1+r1 == xc2 - r2}
xtsol = Solve[eqns2, {xc1, xc2, tc}]〚1〛

now, I understand it so far but I'm not sure what the first half(the picture[] part) of the next part is showing as I'm a bit of a newbie at mathematica.

picture[t_, tmax_, data : {{m1_, x10_, v1_ /; v1 ≥ 0, r1_}, {m2_, x20_, v2_ /; v2 ≤ 0, r2_}}] := Module[{x1, x2, xc1 = -((r1 v1 + r2 v1 + v2 x10 - v1 x20)/(v1 - v2)), xc2 = -((r1 v2 + r2 v2 + v2
x10 - v1 x20)/(v1 - v2)), tc = -((r1 + r2 + x10 - x20)/(v1 - v2)), v3 = (m1 v1 - m2 v1 + 2
m2 v2)/(m1 + m2), v4 = (2 m1 v1 - m1 v2 + m2 v2)/(m1 + m2), positions, s, xmin, xmax, ymax}positions[s_] := If[s ≤ tc, {x10 + v1 s, x20 + v2 s}, {xc1 + v3(s - tc), xc2 + v4(s -tc)}];
s = Flatten[{positions[0], positions[tmax]}]; ymax = Max[r1, r2];
xmin = Min[s] - ymax;
xmax = Max[s] + ymax;
{x1, x2} = positions[t];
Show[Graphics[{
Circle[{x1, t}, r1],
Circle[{x2, t}, r2]}],
AspectRatio -> Automatic,
PlotRange -> {{xmin, xmax}, {(-ymax),ymax + tmax}} 1.2]

any help with this would be most appreciated and ...well, helpful.
cheers

URL: ,
Help | Reply To Topic