2 USING: kernel sequences random accessors multi-methods
3 math math.constants math.ranges math.points combinators.cleave
4 processing processing.shapes
5 bubble-chamber.common bubble-chamber.particle ;
7 IN: bubble-chamber.particle.axion
9 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
11 TUPLE: axion < particle ;
13 : <axion> ( -- axion ) axion new initialize-particle ;
15 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
17 METHOD: collide { axion }
20 2 pi * 1random >>theta
21 1.0 6.0 2random >>speed
22 0.998 1.000 2random >>speed-d
26 [ 0.00001 theta-dd-small? ] [ -0.001 0.001 random-theta-dd ] [ ] while
30 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
32 : dy>alpha ( dy -- alpha ) neg 6 * 30 + 255.0 / ;
34 : axion-white ( dy -- dy ) dup 1 swap dy>alpha {2} stroke ;
35 : axion-black ( dy -- dy ) dup 0 swap dy>alpha {2} stroke ;
37 : axion-point- ( particle dy -- particle ) >r dup pos>> r> v-y point ;
38 : axion-point+ ( particle dy -- particle ) >r dup pos>> r> v+y point ;
40 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
42 METHOD: move { axion }
47 1 4 [a,b] [ axion-white axion-point- ] each
48 1 4 [a,b] [ axion-black axion-point+ ] each
58 [ ] [ speed-d>> 0.9999 * ] bi >>speed-d
62 dup speed>> neg >>speed
63 dup speed-d>> neg 2 + >>speed-d
65 100 random 30 > [ collide ] [ drop ] if