]> gitweb.factorcode.org Git - factor.git/blob - extra/bubble-chamber/particle/muon/muon.factor
c5ee71c1b04e4394709be78fdb58cd42e6c7e726
[factor.git] / extra / bubble-chamber / particle / muon / muon.factor
1
2 USING: kernel arrays sequences random
3        math
4        math.ranges
5        math.functions
6        math.vectors
7        multi-methods accessors
8        combinators.cleave
9        processing
10        processing.shapes
11        bubble-chamber.common
12        bubble-chamber.particle
13        bubble-chamber.particle.muon.colors ;
14
15 IN: bubble-chamber.particle.muon
16
17 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
18
19 TUPLE: muon < particle ;
20
21 : <muon> ( -- muon ) muon new initialize-particle ;
22
23 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
24
25 METHOD: collide { muon }
26
27   center               >>pos
28   2 32 [a,b] random    >>speed
29   0.0001 0.001 2random >>speed-d
30
31   collision-theta>  -0.1 0.1 2random + >>theta
32   0                                    >>theta-d
33   0                                    >>theta-dd
34
35   [ 0.001 theta-dd-small? ] [ -0.1 0.1 random-theta-dd ] [ ] while
36
37   set-good-color
38   set-anti-color
39
40   drop ;
41
42 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
43
44 METHOD: move { muon }
45
46   dup myc>> 0.16 >>alpha stroke
47   dup pos>> point
48
49   dup mya>> 0.16 >>alpha stroke
50   dup pos>> first2 >r dim swap - r> 2array point
51
52   dup
53     [ speed>> ] [ theta>> { sin cos } <arr> ] bi n*v
54   move-by
55
56   step-theta
57   step-theta-d
58   step-speed-sub
59
60   out-of-bounds? [ collide ] [ drop ] if ;
61
62 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
63