]> gitweb.factorcode.org Git - factor.git/blob - unmaintained/bubble-chamber/particle/hadron/hadron.factor
Move a bunch of vocabularies to unmaintained, hopefully temporarily
[factor.git] / unmaintained / bubble-chamber / particle / hadron / hadron.factor
1
2 USING: kernel random math math.constants math.points accessors multi-methods
3        processing processing.shapes
4        bubble-chamber.common
5        bubble-chamber.particle colors ;
6
7 IN: bubble-chamber.particle.hadron
8
9 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10
11 TUPLE: hadron < particle ;
12
13 : <hadron> ( -- hadron ) hadron new initialize-particle ;
14
15 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16
17 METHOD: collide { hadron }
18
19   center              >>pos
20   2 pi *      1random >>theta
21   0.5   3.5   2random >>speed
22   0.996 1.001 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   0 1 0 1 rgba boa >>myc
29
30   drop ;
31
32 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
33
34 METHOD: move { hadron }
35
36   { 1 0.11 } stroke
37   dup pos>> 1 v-y point
38   
39   { 0 0.11 } stroke
40   dup pos>> 1 v+y point
41
42   dup vel>> move-by
43
44   turn
45
46   step-theta
47   step-theta-d
48   step-speed-mul
49
50   1000 random 997 >
51     [
52       1.0     >>speed-d
53       0.00001 >>theta-dd
54
55       100 random 70 > [ dup collide ] when
56     ]
57   when
58
59   out-of-bounds? [ collide ] [ drop ] if ;