File: list-centroid.pd

package info (click to toggle)
pd-list-abs 0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 756 kB
  • sloc: makefile: 289
file content (76 lines) | stat: -rw-r--r-- 1,766 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#N canvas 204 70 675 629 10;
#X obj 127 475 f;
#X obj 127 65 inlet;
#X obj 127 561 outlet;
#X obj 163 170 list-enumerate;
#X obj 163 197 t a a;
#X obj 261 406 /;
#X obj 261 376 swap;
#X obj 210 345 select 0;
#N canvas 286 344 401 287 sum(mi*i) 0;
#X obj 126 138 +;
#X obj 153 139 f;
#X msg 168 88 0;
#X obj 126 66 inlet;
#X obj 168 66 inlet;
#X obj 126 171 outlet;
#X obj 126 103 *;
#X connect 0 0 1 0;
#X connect 0 0 5 0;
#X connect 1 0 0 1;
#X connect 2 0 0 1;
#X connect 3 0 6 0;
#X connect 4 0 2 0;
#X connect 6 0 0 0;
#X restore 284 255 pd sum(mi*i);
#N canvas 573 330 450 328 sum(mi) 0;
#X obj 179 137 +;
#X obj 206 138 f;
#X msg 296 77 0;
#X obj 179 55 inlet;
#X obj 296 55 inlet;
#X obj 179 170 outlet;
#X text 143 34 in: (idx value);
#X text 40 89 swap to: (val idx);
#X text 67 172 sum of values;
#X obj 179 89 swap;
#X connect 0 0 1 0;
#X connect 0 0 5 0;
#X connect 1 0 0 1;
#X connect 2 0 0 1;
#X connect 3 0 9 0;
#X connect 4 0 2 0;
#X connect 9 0 0 0;
#X restore 163 253 pd sum(mi);
#X obj 210 559 outlet;
#X obj 127 399 spigot 1;
#X obj 145 285 f;
#X obj 240 528 print list-centroid;
#X obj 210 468 t b b;
#X msg 240 503 warning: sum of items equals 0: centroid is undefined!
;
#X obj 127 89 t b b a b b;
#X text 69 26 centroid (center of mass) = sum(mi * i) / sum(mi);
#X connect 0 0 2 0;
#X connect 1 0 16 0;
#X connect 3 0 4 0;
#X connect 4 0 9 0;
#X connect 4 1 8 0;
#X connect 5 0 0 1;
#X connect 6 0 5 0;
#X connect 6 1 5 1;
#X connect 7 0 14 0;
#X connect 7 1 6 0;
#X connect 8 0 6 1;
#X connect 9 0 12 1;
#X connect 11 0 0 0;
#X connect 12 0 7 0;
#X connect 12 0 11 1;
#X connect 14 0 10 0;
#X connect 14 1 15 0;
#X connect 15 0 13 0;
#X connect 16 0 11 0;
#X connect 16 1 12 0;
#X connect 16 2 3 0;
#X connect 16 3 9 1;
#X connect 16 4 8 1;