 | | 
06-06-2007
| | Creating | | Join Date: May 2005 Location: Silver Spring, MD, USA
Posts: 4,385
| | Newtonian Bowling A while back, with a mind toward exploring some speculation about time-traveling pool balls made in this post , I wrote a small program to simulate elastic collisions in 2 spatial. The bodies in it are “typed” that is, different program logic can apply to collisions between them, base on what they “are”. My intention was to have a “time travel hole” body that would displace “balls” that collided with it in time.
I’ve not yet gotten around to time travel-type bodies, but have 2 body types: “balls” (or, since they don’t have true angular momentum and they’re only in 2 dimensions, more like “pucks”) and “gutters” – linear objects that balls disappear when they contact.
This is enough to set up a “bowling alley” suitable for a competition.
Here’s the setup: the “alley” is a 9 by 9 square (corners at (1,1) and (9,9)) surrounded by gutters. 10 circular “pins”, each with diameter .5 and mass 1, are set at (5,5), (4,6), (6,6), (3,7), (5,7), (7,7), (2,8), (4,8), (6,8), (8,8). A ball with diameter 1 and mass 3 may be placed at any location (x,2), and given any velocity (h,v). It looks, therefore, something like this: Code: 1 2 3 4 5 6 7 8 9
1 . . . . . . . . .
2 . B .
3 . .
4 . .
5 . 1 .
6 . 2 3 .
7 . 4 5 6 .
8 . 7 8 9 0 .
9 . . . . . . . . .
The object of the game is to remove all of the pins from play by causing them to collide with a gutter – since the surface is frictionless, all this requires in any but the most unusual situation is for each pin to be struck by the ball or another pin. To play, post a value for x (between 1.5 and 8.5), h, and v. I’ll reply with the results.
For example, for x=1.5, (h,v)=(.87,1):
Left the 4 and 10 pins - not a win. Code: c d
f
1
2 3
4 5 6
7 8 9 a
e
Sim T:0
c d
f 1
2 3
4 5 6
7 8 9 a
e
Sim T:3.257532120793722407
c d
1
f
2 3
4 5 6
7 8 9 a
e
Sim T:3.518989094821347538
c d
1
f 3
4 5 6
2
7 8 9 a
e
Sim T:4.662119398181308323
c d
1
f 3
4 5 6
2
7 8 9 a
e
Sim T:5.08496613968448101
c d
1
f 3
4 5 6
2
7 9 a
8
e
Sim T:5.473444378169957758
c d
1
3
f
4 5 6
2
7 9 a
e
Sim T:5.874075482978240739
c d
1
3
f
4 6
7 2 5 9 a
e
Sim T:7.00023810809474893
c d
1
3
4 f 6
7
9 a
2 5
e
Sim T:8.035746865091581241
c d
1
3
4 f 6
7
9 a
2
e
Sim T:8.322891012478744093
c d
1
3
4 f 6
7
9 a
2
e
Sim T:8.677763957767684519
c d
1
3
6
4 f
7
9 a
e
Sim T:8.7871823262624635
c d
3
6
4 f
7
a
9
e
Sim T:9.35499389981379355
c d
3
6
4
f
a
9
e
Sim T:9.73962210175333648
c d
3
6
4
f
a
e
Sim T:10.65367876786687539
c d
6
4
f a
e
Sim T:12.32592343235649738
c d
4
a
f
e
Sim T:16.15223318849125928
c d
4
a
e
Sim T:16.26854475445460678
Here’re some technical details: - The simulation follows the classical laws of conservation of momentum and energy. In other words, it’s a purely Newtonian simulation of completely elastic collisions. (except for the “gutters”, which simply remove bodies, including their momentum and energy, from the system.
- Although the simulation is “event based”, so as accurate as its arithmetic precision permits, it uses a built-in calculator with about 18 decimal digits precision, so has limited precision.
- In the event that more than 2 bodies collide simultaneously, the simulation randomly chooses one body and alters its position slightly (eg: typically about 1e-16) so that only one collision occurs at a time. The way the pins are set up, you’ve got to try pretty hard to get this to happen.
Here’s the simulation’s MUMPS code: Code: n (XELCOL4,X,Y,R,M,VX,VY,T,CB,CT,B,C) x XELCOL4(-2),XELCOL4(-1) ;XELCOL4: elastic collison simulator w/multiple object types
x XELCOL4(0,0) w "Enter:(1)[Mass] (2){Radius|W,H} (3)X,Y (4)[VX,VY] (5)[type] (6)[time]",! f R R,! q:R="" x XELCOL4(0,1) ;XELCOL4(-2): read (default to circle)
s WTI=.25,WT=-WTI f s WT=WT+WTI x XELCOL4(-1,1),XELCOL4(-1,2),XELCOL4(-1,3),XELCOL4(-1,5) s R=1 x XELCOL4(-1,6) q:R?1(1"Q",1"q").e i R?1(1"D",1"d").e x XELCOL4(-1,4),XELCOL4(-1,5) s R=0 x XELCOL4(-1,6) q:R?1(1"Q",1"q").e ;XELCOL4(-1): interactive display
f q:WT'>$o(C(""))!($d(C)<9) X XELCOL4(1) ;XELCOL4(-1,1)
K W s B="" F s B=$o(M(B)) q:B="" S X=WT-T(B)*VX(B)+X(B),Y=WT-T(B)*VY(B)+Y(B),$E(W(Y/.5+.5\1),X/.25+.5\1)=$E("123456789abcdef",B) ;XELCOL4(-1,2)
w ! f W=$o(W("")):1:$o(W(""),-1) W $e($g(W(W)),1,79),! ;XELCOL4(-1,3)
w !,"(1)[Mass] (2){Radius|W,H} (3)X,Y (4)[VX,VY] (5)[type] (6)[time]",! s B="" f s B=$o(M(B)) q:B="" w M(B)," ",R(B)," ",WT-T(B)*VX(B)+X(B),",",WT-T(B)*VY(B)+Y(B)," ",VX(B),$s(VX(B)!VY(B):",",1:""),VY(B)," ",B(B),! ;XELCOL4(-1,4)
W "Sim T:",WT," Sim step T:",WTI," Event:" w:$o(C(""))]"" C($o(C(""))),",",CB(C($o(C("")))) w " Event T:",$o(C("")),! ;XELCOL4(-1,5)
w:R "[D]etails, " w "[Q]uit, Sim step," w:$d(C)>9 " [N] for next event," r " or enter to continue:",R s:R>0 WTI=R s:$tr(R,"n","N")="N"&($d(C)>9) WT="."_$TR($J("",17-$L($P(WT,".")))," ",0)_1+$o(C(""))-WTI ;XELCOL4(-1,6)
n (XELCOL4,X,Y,R,M,VX,VY,T,CB,CT,B,C) k C,CB,CT s T=0,B1="" f s (B1,B2)=$o(M(B1)) q:B1="" x XELCOL4(4) ;XELCOL4(0): initialize
k C,CB,CT,T,R,M,X,Y,VX,VY,B s T=0 ;XELCOL4(0,0): clear bodies
n (XELCOL4,X,Y,R,M,VX,VY,T,CB,CT,B,C) s (B,B1)=$o(M(""),-1)+1,T(B)=+$p(R," ",6),M(B)=$p(R," "),R(B)=$p(R," ",2),X(B)=$p($p(R," ",3),","),Y(B)=$p($p(R," ",3),",",2),VX(B)=$p($p(R," ",4),","),VY(B)=$p($p(R," ",4),",",2),B(B)=$p(R," ",5) s:B(B)="" B(B)=1 x XELCOL4(4) ;XELCOL4(0,1): returns B add body given R:(1)[Mass] (2){Radius|W,H} (3)X,Y (4)[VX,VY] (5)[type] (6)[time]
k:$d(CT(R)) C(CT(R)),CT(R),CT(CB(R)),CB(CB(R)),CB(R) k M(R),R(R),X(R),Y(R),VX(R),VY(R),T(R) ;XELCOL4(0,2): remove body R
n (XELCOL4,X,Y,R,M,VX,VY,T,CB,CT,B,C,CR) i $d(C)>9 s T=$o(C("")) k IVX,IVY x XELCOL4(2),XELCOL4(3,5,B(B1),B(B2)) k C(T),CB(B1),CB(B2),CT(B1),CT(B2) m VX=IVX,VY=IVY s B2P=B2 s B1=B1 x XELCOL4(4),XELCOL4(5) s B1=B2P x XELCOL4(4),XELCOL4(5) ;XELCOL4(1): next event
s B1=C(T),TD=T-T(B1),X(B1)=VX(B1)*TD+X(B1),Y(B1)=VY(B1)*TD+Y(B1),T(B1)=T,B2=CB(B1),TD=T-T(B2),X(B2)=VX(B2)*TD+X(B2),Y(B2)=VY(B2)*TD+Y(B2),T(B2)=T ;XELCOL4(2): move affected body(s) to time T positions
s CX1=VY2*RYX+VX2*M(B2)*RM-(VY1*RYX+VX1*M(B1))*2/(M(B2)*RM*RM+M(B1)*(RYX*RYX+1)),CY1=CX1*RYX,CX2=-CX1*RM,CY2=CX2*RYX ;XELCOL4(3,0,1): elastic collision calculation
i YD s RYX=XD/YD,VX1=VY(B1),VY1=VX(B1),VX2=VY(B2),VY2=VX(B2) x XELCOL4(3,0,1) s IVX(B1)=$g(IVX(B1),VX(B1))+CY1,IVY(B1)=$g(IVY(B1),VY(B1))+CX1,IVX(B2)=$g(IVX(B2),VX(B2))+CY2,IVY(B2)=$g(IVY(B2),VY(B2))+CX2 ;XELCOL4(3,0,1,0)
i XD s RYX=YD/XD,VX1=VX(B1),VY1=VY(B1),VX2=VX(B2),VY2=VY(B2) x XELCOL4(3,0,1) s IVX(B1)=$g(IVX(B1),VX(B1))+CX1,IVY(B1)=$g(IVY(B1),VY(B1))+CY1,IVX(B2)=$g(IVX(B2),VX(B2))+CX2,IVY(B2)=$g(IVY(B2),VY(B2))+CY2 ;XELCOL4(3,0,1,1)
s RM=M(B1)/M(B2),XD=X(B2)-X(B1),YD=Y(B2)-Y(B1) x XELCOL4(3,0,1,$tr(XD,"-")>$tr(YD,"-")) ;XELCOL4(3,5,1,1): circle-circle col effect
s R=B1 x XELCOL4(0,2) ;XELCOL4(3,5,1,2): gutter-circle col effect
s R=B2 x XELCOL4(0,2) ;XELCOL4(3,5,2,1): circle-gutter col effect
k CR i $d(M(B1)) s B2="" f s B2=$o(M(B2)) q:B2="" i B2'=B1 s IT=-1 x XELCOL4(4,5,B(B1),B(B2)) i IT'<0 s CT=IT+T x XELCOL4(4,0,2) ;XELCOL4(4): calculate next collisions
s X1=T-T(B1)*VX(B1)+X(B1),Y1=T-T(B1)*VY(B1)+Y(B1),X2=T-T(B2)*VX(B2)+X(B2),Y2=T-T(B2)*VY(B2)+Y(B2) ;XELCOL4(4,0,1)
s F1=$s($d(CT(B1)):$s(CT(B1)>CT:1,CT(B1)<CT:0,1:""),1:1),F2=$s($d(CT(B2)):$s(CT(B2)>CT:1,CT(B2)<CT:0,1:""),1:1) i $s(F1&F2:1,F1_F2="":$r(2),1:0) s BK=B1,FK=F1 x:$d(CT(BK)) XELCOL4(4,0,2,0) s BK=B2,FK=F2 x:$d(CT(BK)) XELCOL4(4,0,2,0) s C(CT)=B1,(CT(B1),CT(B2))=CT,CB(B1)=B2,CB(B2)=B1 k CR(B1),CR(B2) ;XELCOL4(4,0,2)
s BK2=CB(BK),(CR(BK),CR(BK2))="" k C(CT(BK)),CT(BK2),CT(CB(BK2)),CB(BK2),CB(BK) s:FK="" T(BK2)="."_$TR($J("",17-$L($P(T(BK2),".")))," ",0)_1+T(BK2) ;XELCOL4(4,0,2,0)
x XELCOL4(4,0,1) s XD=X1-X2,YD=Y1-Y2,VXD=VX(B1)-VX(B2),VYD=VY(B1)-VY(B2),A=VXD**2+(VYD**2),B=XD*VXD+(YD*VYD)*2,C=XD**2+(YD**2)-(R(B1)+R(B2)**2),D=B*B-(4*A*C) i D'<0&A s IT=D**.5+B/A/-2 ;XELCOL4(4,5,1,1): circle-circle col detect
s I=B1,B1=B2,B2=I x XELCOL4(4,5,2,1) s I=B1,B1=B2,B2=I ;XELCOL4(4,5,1,2): circle-gutter col detect
s XD=$p(R(B1),","),YD=$p(R(B1),",",2),F=$s(XD&VX(B2):1,YD&VY(B2):2,YD&VX(B2):3,XD&VY(B2):4,1:0) x:F XELCOL4(4,0,1),XELCOL4(4,5,2,1,F) ;XELCOL4(4,5,2,1): gutter-circle col detect
s A=YD/XD,B=VY(B2)/VX(B2),C=A-B i C s IT=A*X1-(B*X2)+Y2-Y1/C-X2/VX(B2) ;XELCOL4(4,5,2,1,1)
s A=XD/YD,B=VX(B2)/VY(B2),C=A-B i C s IT=A*Y1-(B*Y2)+X2-X1/C-Y2/VY(B2) ;XELCOL4(4,5,2,1,2)
s IT=X1-X2/VX(B2) ;XELCOL4(4,5,2,1,3)
s IT=Y1-Y2/VY(B2) ;XELCOL4(4,5,2,1,4)
q ;XELCOL4(4,5,2,2): gutters can't collide
s B1="" f s B1=$o(CR(B1)) q:B1="" x XELCOL4(4) ;XELCOL4(5)
__________________ Moderator: Computers and Technology; Medical Science; Science Projects and Homework; Philosophy of Science; Physics and Mathematics; Environmental Studies
Last edited by CraigD; 06-17-2007 at 09:49 PM.
Reason: Added a display improvement to the MUMPS code
| 
06-06-2007
|  | Ancora Imparo |  Sponsor | | | | Re: Newtonian Bowling Cool
Ill go first:
position (4,2)
velocity (.25,1.5)
__________________ Jay-qu
::Hypography Moderator of..
Chemistry, Physics & Mathematics, Astronomy & Cosmology, Space and Technology & gadgets Forums
Einstein said that if quantum mechanics is right, then the world is crazy. Well, Einstein was right. The world is crazy.
-Daniel Greenberger Physics Guides - Physics Resources and help | 
06-06-2007
| | Creating | | Join Date: May 2005 Location: Silver Spring, MD, USA
Posts: 4,385
| | 2 pins standing - no win Quote:
Originally Posted by Jay-qu position (4,2)
velocity (.25,1.5) | 4 and 7 pins left - no win.
I think the program's ascii diagram looks better than the example I put in post 1. Scroll though the code window to watch the ascii movie. “1” – “a” are the pins, “f” the ball, “c”, “d”, “e” and (not visible) “b” the (poorly represented) gutters  Code: c d
f
1
2 3
4 5 6
7 8 9 a
e
Sim T:0
c d
f
1
2 3
4 5 6
7 8 9 a
e
Sim T:1.682493862571148118
c d
f
1
2 3
4 5 6
7 8 9 a
e
Sim T:2.22180586735190316
c d
f
1
2 3
4 5 6
7 8 9 a
e
Sim T:2.372214842067710483
c d
1
f
2 3
4 5 6
7 8 9 a
e
Sim T:2.80337786458540304
c d
1
f
4 5 3
6
7 2 8 9 a
e
Sim T:3.665867116802858094
c d
1
f
4 5
3 6
7 2 8 9 a
e
Sim T:3.785181457235309326
c d
1
f
4 5
3 6
7 8 9 a
e
Sim T:4.300658001254723145
4
c d
1
f
4 5
3
7 8 9 a
e
Sim T:4.319608390578288404
c d
1
f
4 5
3
7 8 a
9
e
Sim T:4.542272389957696707
c d
1
f
4 5
3
7 8 a
e
Sim T:5.080949236958210883
1
c d
1
4 f 5
3
7 8
a
e
Sim T:5.700236110016146481
c d
1
4 f 5
3
7 8
a
e
Sim T:6.215112636730411789
1
c d
1
4 5
f 3
7
a
e
Sim T:6.948916934697659471
63
c d
1
4 5
f 3
7
e
Sim T:7.253282629038822273
c d
4
5
7 3
f
e
Sim T:10.66667443600961184
c d
4
5
7 3
e
Sim T:11.89386486374767834
c d
4
5
7
e
Sim T:12.72913929773333069
c d
4
7
e
Sim T:30.70859701686344013
__________________ Moderator: Computers and Technology; Medical Science; Science Projects and Homework; Philosophy of Science; Physics and Mathematics; Environmental Studies | 
06-08-2007
| | Creating | | Join Date: May 2005 Location: Silver Spring, MD, USA
Posts: 4,385
| | Come on, give it a try!  Aw, c’mon – after 38 hours, only 1 play?
I was hoping to play the first game until someone won, then try a couple of variation – more difficult pin layouts, and a game where your inputs were subjected to random “inaccuracy” factors – but if nobody plays, none of that’s go’na happen!
Just to assuage any suspicions that the game’s not winnable, here’re the results of a program I ran that played the game for every x value from 1.605 to 5.755 in .01 steps, and every (h,v) from (0,1) to (.86, .510294032886922949) in steps .01 for h (keeping the ball’s speed a constant 1). Excluding plays that removed 0 pins: 7.5% removed 1 pin, 10.7% 2, 8.9% 3, 13.3% 4, 14.9% 5, 14.6% 6, 14.2% 7, 9.7% 8, 5.2% 9, and 0.9% all 10 pins.
If you’d like, you can change the mass of the ball from its given value of 3 times that of each pin. According to the data I gathered via the above program, the way to go with changing the ball mass is not, as you might intuitively expect, increasing it, but decreasing it to about 1.75. For a ball with mass 1.75, the results are: 9.9% removed 1 pin, 7.6% 2, 8.8% 3, 13.0% 4, 13.5% 5, 17.6% 6, 15.0% 7, 9.1% 8, 4.0% 9 and 1.7% all 10 pins.
__________________ Moderator: Computers and Technology; Medical Science; Science Projects and Homework; Philosophy of Science; Physics and Mathematics; Environmental Studies | 
06-08-2007
| | Questioning | | Join Date: Feb 2006
Posts: 489
| | | Re: Newtonian Bowling Ok, x=1.5, (h,v)=(.86,1.3) | 
06-08-2007
| | Creating | | Join Date: May 2005 Location: Silver Spring, MD, USA
Posts: 4,385
| | 6 pins standing - no win Quote:
Originally Posted by chendoh Ok, x=1.5, (h,v)=(.86,1.3) | A nasty split results, leaving the 1, 3, 4, 6, 7 & 8 pins. Code: c d
f
1
2 3
4 5 6
7 8 9 a
e
Sim T:0
c d
f 1
2 3
4 5 6
7 8 9 a
e
Sim T:2.550422007712599994
1
f
3
4 2 5 6
7 8 9 a
e
Sim T:3.25
c d
1
f
3
4 5 6
2
7 8 9 a
e
Sim T:3.5
c d
1
f 3
4 5 6
7 8 9 a
2
e
Sim T:3.75
c d
1
f 3
4 5 6
7 8 9 a
e
Sim T:3.975354576592328396
c d
1
f 3
4 5 6
7 8 9 a
e
Sim T:4.27278087469325183
c d
1
3
f
4 6
5
7 8 9 a
e
Sim T:5.15180413387607972
c d
1
3
f
4 6
7 8 9 a
e
Sim T:6.379778024715319505
c d
1
3
4 f 6
a
7 8 9
e
Sim T:7.29626546289409707
c d
1
3
4 6
f a
7 8
e
Sim T:8.843747701049772658
c d
1
3
4 6
f
7 8
e
Sim T:9.77509489965423258
c d
1
3
4 6
7 8
e
Sim T:14.70981727999254226
I added a couple of non-event images showing the 2 pin’s path.
__________________ Moderator: Computers and Technology; Medical Science; Science Projects and Homework; Philosophy of Science; Physics and Mathematics; Environmental Studies | 
06-08-2007
| | Questioning | | Join Date: Feb 2006
Posts: 489
| | | Re: 6 pins standing - no win Quote:
Originally Posted by CraigD A nasty split results, leaving the 1, 3, 4, 6, 7 & 8 pins. | Owwwww!!!!!.......There goes my 300 game!
How 'bout,  x=5.5, (h,v)=(.20,1.0).
What would I need to play this on my Pc?  | 
06-08-2007
| | Creating | | Join Date: May 2005 Location: Silver Spring, MD, USA
Posts: 4,385
| | 6 pins standing again - still no win Quote:
Originally Posted by chendoh Owwwww!!!!!.......There goes my 300 game!
How 'bout,  x=5.5, (h,v)=(.20,1.0). | Left the 1, 2, 4, 5, 7 and 8 pins. Code: c d
f
1
2 3
4 5 6
7 8 9 a
e
Sim T:0
c d
1 f
2 3
4 5 6
7 8 9 a
e
Sim T:3.265805419256236132
c d
1
f
2
4 5 6
3
7 8 9 a
e
Sim T:4.452220218139312724
c d
1
2 f
4 5 6
7 8 3 9 a
e
Sim T:5.18515941346474536
c d
1
2
f
4 5
6
7 8 a
3
e
Sim T:6.136453831387942497
c d
1
2
f
4 5
6
7 8 a
e
Sim T:6.194847311346391677
c d
1
2
f
4 5
7 8 a
e
Sim T:7.532138137286044254
c d
1
2
4 5 f
7 8 a
e
Sim T:9.55820894341865905
c d
1
2
4 5
f
7 8
e
Sim T:12.34030496315989419
c d
1
2
4 5
7 8
e
Sim T:21.04321358206738898
__________________ Moderator: Computers and Technology; Medical Science; Science Projects and Homework; Philosophy of Science; Physics and Mathematics; Environmental Studies | 
06-08-2007
| | Creating | | Join Date: May 2005 Location: Silver Spring, MD, USA
Posts: 4,385
| | How to run MUMPS code on your PC Quote:
Originally Posted by chendoh What would I need to play this on my Pc?  | A MUMPS language interpreter. A free, non-expiring, single user copy of the one I use can be had at Free Caché Downloads. The vendor, Intersystems, requires you register an email address with them to get it, but in my experience won’t spam you unless you request it, or give the address to any other company.
Pay no attention to the name “Cache”. Intersystems makes a great effort to hide the fact that Cache is, in fact, a (much extended) implementation of the MUMPS language, but it’s one of the best.
Once installed, you need only click on the icon it installs in your system tray, or follow the start menu path to its “Terminal” application, and paste the following into it Code: f r R q:'$l(R) s I=$p($p(R,";",$l(R,";")),":") i $l(I) s @I=R
(making sure to end with exactly 1 Enter keystroke) followed by the code in post #1, followed by a blank line (the Enter key), followed by Code: x XELCOL4
1 .25 5,5
1 .25 4,6
1 .25 6,6
1 .25 3,7
1 .25 5,7
1 .25 7,7
1 .25 2,8
1 .25 4,8
1 .25 6,8
1 .25 8,8
8,0 1,1 2
0,8 1,1 2
0,8 9,1 2
8,0 1,9 2
3 .5 5.5,2 .2,1
, where the last line gives the mass, radius position and velocity of the ball. Pressing enter at the following prompts will step you through the simulation, and, if you want, give you more detailed data than I’ve been posting here.
In addition to letting you run the MUMPS code I post so much of at hypography, the free application has the full IDE and documentation for the language, and a lot of extensions beyond the language standard. You may find, as I do, that MUMPS and Cache are nifty language for prototyping, simulating, and other math and science-y fun.
It goes without saying, let me know if I can be of any help.
__________________ Moderator: Computers and Technology; Medical Science; Science Projects and Homework; Philosophy of Science; Physics and Mathematics; Environmental Studies | 
06-08-2007
|  | Understanding | | Join Date: Apr 2006
Posts: 300
| | | Re: Newtonian Bowling OKay, how about:
Position(3.5,2)
velocity (.30,1)
__________________ "Men are apt to mistake the strength of their feelings for the strength of their argument.
The heated mind resents the chill touch & relentless scruntiny of logic"-W.E. Gladstone |  | | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | » Recent Threads | | | | | | | | | | | | | | | | | | | | | |