|
18 | 18 | % TODO |
19 | 19 | % bound direction between 0 and 360 ?? |
20 | 20 |
|
21 | | - direction = thisEvent.direction(1); |
| 21 | + dots.direction = thisEvent.direction(1); |
22 | 22 |
|
23 | 23 | speedPixPerFrame = thisEvent.speed(1); |
24 | 24 |
|
25 | 25 | lifeTime = cfg.dot.lifeTime; |
26 | 26 |
|
27 | 27 | % decide which dots are signal dots (1) and those are noise dots (0) |
28 | | - isSignal = rand(cfg.dot.number, 1) < cfg.dot.coherence; |
| 28 | + dots.isSignal = rand(cfg.dot.number, 1) < cfg.dot.coherence; |
29 | 29 |
|
30 | 30 | % for static dots |
31 | | - if direction == -1 |
| 31 | + if dots.direction == -1 |
32 | 32 | speedPixPerFrame = 0; |
33 | 33 | lifeTime = Inf; |
34 | | - isSignal = true(cfg.dot.number, 1); |
| 34 | + dots.isSignal = true(cfg.dot.number, 1); |
35 | 35 | end |
36 | 36 |
|
37 | 37 | %% Set an array of dot positions [xposition, yposition] |
38 | 38 | % These can never be bigger than 1 or lower than 0 |
39 | 39 | % [0,0] is the top / left of the square |
40 | 40 | % [1,1] is the bottom / right of the square |
41 | | - positions = rand(cfg.dot.number, 2) * cfg.screen.winWidth; |
| 41 | + dots.positions = rand(cfg.dot.number, 2) * cfg.screen.winWidth; |
42 | 42 |
|
43 | 43 | %% Set vertical and horizontal speed for all dots |
44 | | - directionAllDots = setDotDirection(cfg, positions, direction, isSignal); |
| 44 | + dots = setDotDirection(cfg, dots); |
45 | 45 |
|
46 | | - [horVector, vertVector] = decomposeMotion(directionAllDots); |
| 46 | + [horVector, vertVector] = decomposeMotion(dots.directionAllDots); |
47 | 47 | speeds = [horVector, vertVector]; |
48 | 48 |
|
49 | 49 | % we were working with unit vectors. we now switch to pixels |
|
61 | 61 | dots.lifeTime = lifeTime; |
62 | 62 | dots.time = time; |
63 | 63 | dots.speeds = speeds; |
64 | | - dots.isSignal = isSignal; |
65 | | - dots.positions = positions; |
66 | | -end |
67 | | - |
68 | | -function directionAllDots = setDotDirection(cfg, positions, direction, isSignal) |
69 | | - |
70 | | - directionAllDots = nan(cfg.dot.number, 1); |
| 64 | + dots.speedPixPerFrame = speedPixPerFrame; |
71 | 65 |
|
72 | | - direction = computeRadialMotionDirection(cfg, positions, direction); |
| 66 | +end |
73 | 67 |
|
74 | | - % Coherent dots |
75 | | - directionAllDots(isSignal) = direction; |
76 | | - % Random direction for the non coherent dots |
77 | | - directionAllDots(~isSignal) = rand(sum(~isSignal), 1) * 360; |
78 | | - directionAllDots = rem(directionAllDots, 360); |
79 | 68 |
|
80 | | -end |
0 commit comments