]> gitweb.factorcode.org Git - factor.git/blob - extra/bubble-chamber/particle/quark/quark.factor
Remove with-malloc, use destructors instead
[factor.git] / extra / bubble-chamber / particle / quark / quark.factor
1
2 USING: kernel arrays sequences random math accessors multi-methods
3        processing processing.shapes
4        bubble-chamber.common
5        bubble-chamber.particle ;
6
7 IN: bubble-chamber.particle.quark
8
9 TUPLE: quark < particle ;
10
11 : <quark> ( -- quark ) quark new initialize-particle ;
12
13 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14
15 METHOD: collide { quark }
16
17   center                     >>pos
18   collision-theta> -0.11 0.11 2random +  >>theta
19   0.5 3.0 2random                        >>speed
20
21   0.996 1.001 2random                    >>speed-d
22   0                                      >>theta-d
23   0                                      >>theta-dd
24
25   [ 0.00001 theta-dd-small? ] [ -0.001 0.001 random-theta-dd ] [ ] while
26
27   drop ;
28
29 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
30
31 METHOD: move { quark }
32
33   dup myc>> 0.13 >>alpha stroke
34   dup pos>>              point
35
36   dup pos>> first2 >r dim swap - r> 2array point
37
38   [ ] [ vel>> ] bi move-by
39
40   turn
41
42   step-theta
43   step-theta-d
44   step-speed-mul
45
46   1000 random 997 >
47     [
48       dup speed>> neg    >>speed
49       2 over speed-d>> - >>speed-d
50     ]
51   when
52
53   out-of-bounds? [ collide ] [ drop ] if ;