bubble-chamber: use inheritance for the particles
parent
e67978b759
commit
469470347b
|
@ -25,12 +25,6 @@ IN: processing.gallery.bubble-chamber
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
: 2random ( a b -- num ) 2dup swap - 100 / <range> random ;
|
|
||||||
|
|
||||||
: 1random ( b -- num ) 0 swap 2random ;
|
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
|
|
||||||
: move-by ( obj delta -- obj ) over pos>> v+ >>pos ;
|
: move-by ( obj delta -- obj ) over pos>> v+ >>pos ;
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
@ -103,26 +97,37 @@ VARS: particles muons quarks hadrons axions ;
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
GENERIC: collide ( particle -- )
|
TUPLE: particle pos vel speed speed-d theta theta-d theta-dd myc mya ;
|
||||||
GENERIC: move ( particle -- )
|
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
TUPLE: muon pos speed theta speed-d theta-d theta-dd myc mya ;
|
: initialize-particle ( particle -- particle )
|
||||||
|
|
||||||
|
0 0 {2} >>pos
|
||||||
|
0 0 {2} >>vel
|
||||||
|
|
||||||
: <muon> ( -- muon )
|
|
||||||
muon construct-empty
|
|
||||||
0 0 2array >>pos
|
|
||||||
0 >>speed
|
0 >>speed
|
||||||
0 >>speed-d
|
0 >>speed-d
|
||||||
0 >>theta
|
0 >>theta
|
||||||
0 >>theta-d
|
0 >>theta-d
|
||||||
0 >>theta-dd
|
0 >>theta-dd
|
||||||
|
|
||||||
0 0 0 1 <rgba> >>myc
|
0 0 0 1 <rgba> >>myc
|
||||||
0 0 0 1 <rgba> >>mya ;
|
0 0 0 1 <rgba> >>mya ;
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
GENERIC: collide ( particle -- )
|
||||||
|
GENERIC: move ( particle -- )
|
||||||
|
|
||||||
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
TUPLE: muon < particle ;
|
||||||
|
|
||||||
|
: <muon> ( -- muon ) muon construct-empty initialize-particle ;
|
||||||
|
|
||||||
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
METHOD: collide { muon }
|
METHOD: collide { muon }
|
||||||
|
|
||||||
dim 2 / dup 2array >>pos
|
dim 2 / dup 2array >>pos
|
||||||
|
@ -177,18 +182,9 @@ METHOD: move { muon }
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
TUPLE: quark pos vel speed theta speed-d theta-d theta-dd myc ;
|
TUPLE: quark < particle ;
|
||||||
|
|
||||||
: <quark> ( -- quark )
|
: <quark> ( -- quark ) quark construct-empty initialize-particle ;
|
||||||
quark construct-empty
|
|
||||||
0 0 2array >>pos
|
|
||||||
0 0 2array >>vel
|
|
||||||
0 >>speed
|
|
||||||
0 >>speed-d
|
|
||||||
0 >>theta
|
|
||||||
0 >>theta-d
|
|
||||||
0 >>theta-dd
|
|
||||||
0 0 0 1 <rgba> >>myc ;
|
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
@ -228,7 +224,8 @@ METHOD: move { quark }
|
||||||
[ ] [ theta-d>> ] [ theta-dd>> ] tri + >>theta-d
|
[ ] [ theta-d>> ] [ theta-dd>> ] tri + >>theta-d
|
||||||
[ ] [ speed>> ] [ speed-d>> ] tri * >>speed
|
[ ] [ speed>> ] [ speed-d>> ] tri * >>speed
|
||||||
|
|
||||||
1000 random 997 >
|
! 1000 random 997 >
|
||||||
|
3/1000 chance
|
||||||
[
|
[
|
||||||
dup speed>> neg >>speed
|
dup speed>> neg >>speed
|
||||||
2 over speed-d>> - >>speed-d
|
2 over speed-d>> - >>speed-d
|
||||||
|
@ -242,18 +239,9 @@ METHOD: move { quark }
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
TUPLE: hadron pos vel speed theta speed-d theta-d theta-dd myc ;
|
TUPLE: hadron < particle ;
|
||||||
|
|
||||||
: <hadron> ( -- hadron )
|
: <hadron> ( -- hadron ) hadron construct-empty initialize-particle ;
|
||||||
hadron construct-empty
|
|
||||||
0 0 2array >>pos
|
|
||||||
0 0 2array >>vel
|
|
||||||
0 >>speed
|
|
||||||
0 >>speed-d
|
|
||||||
0 >>theta
|
|
||||||
0 >>theta-d
|
|
||||||
0 >>theta-dd
|
|
||||||
0 0 0 1 <rgba> >>myc ;
|
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
@ -296,12 +284,14 @@ METHOD: move { hadron }
|
||||||
[ ] [ theta-d>> ] [ theta-dd>> ] tri + >>theta-d
|
[ ] [ theta-d>> ] [ theta-dd>> ] tri + >>theta-d
|
||||||
[ ] [ speed>> ] [ speed-d>> ] tri * >>speed
|
[ ] [ speed>> ] [ speed-d>> ] tri * >>speed
|
||||||
|
|
||||||
1000 random 997 >
|
! 1000 random 997 >
|
||||||
|
3/1000 chance
|
||||||
[
|
[
|
||||||
1.0 >>speed-d
|
1.0 >>speed-d
|
||||||
0.00001 >>theta-dd
|
0.00001 >>theta-dd
|
||||||
|
|
||||||
100 random 70 >
|
! 100 random 70 >
|
||||||
|
30/100 chance
|
||||||
[
|
[
|
||||||
dim 2 / dup 2array >>pos
|
dim 2 / dup 2array >>pos
|
||||||
dup collide
|
dup collide
|
||||||
|
@ -317,17 +307,9 @@ METHOD: move { hadron }
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
TUPLE: axion pos vel speed theta speed-d theta-d theta-dd ;
|
TUPLE: axion < particle ;
|
||||||
|
|
||||||
: <axion> ( -- axion )
|
: <axion> ( -- axion ) axion construct-empty initialize-particle ;
|
||||||
axion construct-empty
|
|
||||||
0 0 2array >>pos
|
|
||||||
0 0 2array >>vel
|
|
||||||
0 >>speed
|
|
||||||
0 >>speed-d
|
|
||||||
0 >>theta
|
|
||||||
0 >>theta-d
|
|
||||||
0 >>theta-dd ;
|
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
@ -381,12 +363,14 @@ METHOD: move { axion }
|
||||||
|
|
||||||
[ ] [ speed-d>> 0.9999 * ] bi >>speed-d
|
[ ] [ speed-d>> 0.9999 * ] bi >>speed-d
|
||||||
|
|
||||||
1000 random 996 >
|
! 1000 random 996 >
|
||||||
|
4/1000 chance
|
||||||
[
|
[
|
||||||
dup speed>> neg >>speed
|
dup speed>> neg >>speed
|
||||||
dup speed-d>> neg 2 + >>speed-d
|
dup speed-d>> neg 2 + >>speed-d
|
||||||
|
|
||||||
100 random 30 >
|
! 100 random 30 >
|
||||||
|
70/100 chance
|
||||||
[
|
[
|
||||||
dim 2 / dup 2array >>pos
|
dim 2 / dup 2array >>pos
|
||||||
collide
|
collide
|
||||||
|
|
Loading…
Reference in New Issue