Colliding Cars

Manipulate[
With[{θ=ArcTan[((m2 v2)/(m1 v1))],cd=.75,sf=20},With[{vf=((m1 v1)/((m1+m2) Cos[θ]))},Graphics[{RGBColor[.25,.43,.82],Rectangle[{-5,-5},{-1,-1}],Rectangle[{-5,5},{-1,1}],Rectangle[{1,1},{5,5}],Rectangle[{1,-1},{5,-5}],Dashed,Thickness[.01],RGBColor[.48,.11,.56],Line[{{collpos[[1]]-v1/sf cd,collpos[[2]]},collpos}],Line[{collpos-{0,v2/sf cd},collpos}],RGBColor[.79,.71,.26],PointSize[.03],Point[collpos],Line[{collpos,collpos+1.1{ Cos[θ],Sin[θ]}}],RGBColor[.49,0,0],Rotate[Rectangle[collpos+{-v1/sf cd-.6+If[ t<cd,v1/sf t,v1/sf cd],-.17}+If[t>cd,vf/sf(t-cd){ Cos[θ], Sin[θ]},0],collpos+{-v1/sf cd+If[t<cd,v1/sf t,v1/sf cd],.17}+If[t>cd,vf/sf(t-cd){ Cos[θ], Sin[θ]},0]],If[t>cd, θ/2,0]],
RGBColor[.6,.73,.36],Rotate[Rectangle[collpos+{-.17,-v2/sf cd-.6+If[t<cd,v2/sf t,v2/sf cd]}+If[t>cd,vf/sf(t-cd){ Cos[θ], Sin[θ]},0],collpos+{.17,-v2/sf cd+If[t<cd,v2/sf t,v2/sf cd]}+If[t>cd,vf/sf(t-cd){ Cos[θ], Sin[θ]},0]],If[t>cd,2π/2-(π/2-θ)/2,0]],RGBColor[.79,.71,.26],Style[Text[Column[{Row[{"θ",θ},"="],Row[{"(Subscript[v, f])",((m1 v1)/((m1+m2) Cos[θ]))},"="]}],{-3.,-3.}],16],Dashing[None],White,Line[{{-2.8,-0.85},{-1,-0.85}}],Text["10 m",{-1.9,-1}]},Background->Black,PlotRangePadding->0,ImageSize->{350,350},PlotRange->{{-5,2.5},{-5,2.5}}]]],{t,0.,1.1,.01,ImageSize->Small,Appearance->"Labeled"},{{m1,1000.,"(Subscript[m, 1])"},1000.,1400.,.1,ImageSize->Small,Appearance->"Labeled"},{{m2,1000.,"(Subscript[m, 2])"},1000.,1800.,.1,ImageSize->Small,Appearance->"Labeled"},{{v1,40.,"(Subscript[v, 1])"},20.,100.,.1,ImageSize->Small,Appearance->"Labeled"},{{v2,90.,"(Subscript[v, 2])"},20.,100.,.1,ImageSize->Small,Appearance->"Labeled"},{{collpos,{0,0}},{-.7,-.7},{.7,.7},Locator},ControlPlacement->Left]

THIS NOTEBOOK IS THE SOURCE CODE FROM

"Colliding Cars" from The Wolfram Demonstrations Project
 http://demonstrations.wolfram.com/CollidingCars/

Contributed by: Enrique Zeleny

A full-function Wolfram Mathematica 6 system is required to edit this notebook.
GET WOLFRAM MATHEMATICA 6 »

© The Wolfram Demonstrations Project & Contributors   |   Terms of Use   |   Make a new version of this Demonstration »