]> gitweb.factorcode.org Git - factor.git/blob - extra/bubble-chamber/particle/axion/axion.factor
2dafc36cdee54e64e931bdd3bb92287e287f701c
[factor.git] / extra / bubble-chamber / particle / axion / axion.factor
1
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 ;
6
7 IN: bubble-chamber.particle.axion
8
9 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10
11 TUPLE: axion < particle ;
12
13 : <axion> ( -- axion ) axion new initialize-particle ;
14
15 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16
17 METHOD: collide { axion }
18
19   center              >>pos
20   2 pi *      1random >>theta
21   1.0   6.0   2random >>speed
22   0.998 1.000 2random >>speed-d
23   0                   >>theta-d
24   0                   >>theta-dd
25
26   [ 0.00001 theta-dd-small? ] [ -0.001 0.001 random-theta-dd ] [ ] while
27
28   drop ;
29
30 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
31
32 : dy>alpha ( dy -- alpha ) neg 6 * 30 + 255.0 / ;
33
34 : axion-white ( dy -- dy ) dup 1 swap dy>alpha {2} stroke ;
35 : axion-black ( dy -- dy ) dup 0 swap dy>alpha {2} stroke ;
36
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 ;
39
40 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
41
42 METHOD: move { axion }
43
44   { 0.06 0.59 } stroke
45   dup pos>>  point
46
47   1 4 [a,b] [ axion-white axion-point- ] each
48   1 4 [a,b] [ axion-black axion-point+ ] each
49
50   dup vel>> move-by
51
52   turn
53
54   step-theta
55   step-theta-d
56   step-speed-mul
57
58   [ ] [ speed-d>> 0.9999 * ] bi >>speed-d
59
60   1000 random 996 >
61     [
62       dup speed>>   neg     >>speed
63       dup speed-d>> neg 2 + >>speed-d
64
65       100 random 30 > [ collide ] [ drop ] if
66     ]
67     [ drop ]
68   if ;