#N struct 1031-centroid float x;
#N canvas 0 26 626 572 10;
#X floatatom 129 468 5 0 0 0 centroid - -;
#X msg 129 363 1 1 1 1;
#X msg 245 260 0 0 0 0;
#X msg 245 279 -1 1;
#X obj 215 469 bng 15 250 50 0 empty empty result_undefined 17 7 1
10 -262144 -1 -1;
#X msg 129 245 0 1 0;
#X obj 129 439 list-centroid;
#X text 63 25 [list-centroid];
#X text 93 90 centroid = sum(mi * i) / sum(mi);
#X text 71 49 Calculates the centroid or center of mass of a list of
floats according to:;
#X text 67 115 where the index i starts from 0;
#X msg 247 344 -1 3;
#X msg 129 287 1 2 3;
#X text 314 270 these two are undefined!;
#X msg 129 341 5 5 5;
#N canvas 0 0 450 300 randlist 0;
#X obj 134 129 until;
#X msg 246 151 set;
#X msg 134 193 add2 \$1;
#X obj 112 101 t b f b;
#X obj 135 249 outlet;
#X obj 112 31 inlet;
#X obj 112 73 + 1;
#X obj 112 53 random 10;
#X obj 134 151 random 10;
#X obj 134 171 - 5;
#X connect 0 0 8 0;
#X connect 1 0 4 0;
#X connect 2 0 4 0;
#X connect 3 0 4 0;
#X connect 3 1 0 0;
#X connect 3 2 1 0;
#X connect 5 0 7 0;
#X connect 6 0 3 0;
#X connect 7 0 6 0;
#X connect 8 0 9 0;
#X connect 9 0 2 0;
#X restore 295 337 pd randlist;
#X msg 295 363 4;
#X msg 295 315 bang;
#X msg 129 306 10 20 30;
#X msg 129 267 0 2 0 0 0 1;
#X msg 248 325 -1 2;
#X msg 248 407 -10 9;
#X text 305 406 Note: a centroid can be negative!;
#X text 75 520 2007 Frank Barknecht;
#X text 67 146 Negative values are possible.;
#X text 65 174 If all floats add up to 0 \, the result is undefined.
In this case \, no result will be sent to the first outlet \, instead
the second outlet will bang and a console warning will be issued.;
#N canvas 318 53 641 556 graphical-centroid 0;
#N canvas 0 0 450 300 randlist 0;
#X obj 134 129 until;
#X msg 246 151 set;
#X msg 134 193 add2 \$1;
#X obj 112 101 t b f b;
#X obj 135 249 outlet;
#X obj 112 31 inlet;
#X obj 134 151 random 100;
#X obj 134 171 / 100;
#X msg 112 59 10;
#X connect 0 0 6 0;
#X connect 1 0 4 0;
#X connect 2 0 4 0;
#X connect 3 0 4 0;
#X connect 3 1 0 0;
#X connect 3 2 1 0;
#X connect 5 0 8 0;
#X connect 6 0 7 0;
#X connect 7 0 2 0;
#X connect 8 0 3 0;
#X restore 79 388 pd randlist;
#X msg 79 366 bang;
#X obj 79 447 list prepend 0;
#X obj 79 470 s \$0-tab;
#N canvas 0 0 450 300 (subpatch) 0;
#X array \$0-tab 10 float 0;
#X coords 0 1 9 0 200 140 1;
#X restore 79 105 graph;
#N canvas 0 0 694 427 \$0-c 0;
#X scalar 1031-centroid 0 \;;
#X coords 0 0 18 140 200 140 1;
#X restore 79 105 pd \$0-c;
#X floatatom 339 346 5 0 0 0 - - -;
#X obj 339 313 list-centroid;
#N canvas 336 319 712 355 \$0-centroid 0;
#X obj 19 329 outlet;
#X obj 19 86 route change;
#X obj 19 62 struct \$0-centroid float x;
#X obj 228 62 drawpolygon 900 2 x 0 x 140;
#X connect 1 0 0 0;
#X connect 2 0 1 0;
#X restore 453 315 pd \$0-centroid;
#X obj 339 367 set \$0-centroid x;
#N canvas 0 0 503 429 create 0;
#X msg 242 258 traverse pd-\$1 \, bang;
#X obj 242 238 symbol \$0-c;
#X msg 107 79 0;
#X obj 242 278 pointer;
#X msg 243 178 clear;
#X obj 243 205 s pd-\$0-c;
#X obj 107 302 append \$0-centroid x;
#X obj 107 114 t a b b;
#X obj 107 50 loadbang;
#X obj 107 326 outlet;
#X connect 0 0 3 0;
#X connect 1 0 0 0;
#X connect 2 0 7 0;
#X connect 3 0 6 1;
#X connect 4 0 5 0;
#X connect 6 0 9 0;
#X connect 7 0 6 0;
#X connect 7 1 1 0;
#X connect 7 2 4 0;
#X connect 8 0 2 0;
#X restore 468 339 pd create;
#X obj 339 127 metro 50;
#X obj 339 102 tgl 15 0 empty empty show-centroid 17 7 1 10 -258699
-262144 -1 0 1;
#N canvas 473 338 450 300 countto 0;
#X obj 131 154 f 0;
#X obj 156 153 + 1;
#X msg 174 113 0;
#X obj 131 183 outlet;
#X obj 131 59 inlet;
#X obj 131 116 until;
#X obj 131 96 t a b;
#X connect 0 0 1 0;
#X connect 0 0 3 0;
#X connect 1 0 0 1;
#X connect 2 0 0 1;
#X connect 4 0 6 0;
#X connect 5 0 0 0;
#X connect 6 0 5 0;
#X connect 6 1 2 0;
#X restore 362 195 pd countto;
#X obj 362 219 tabread \$0-tab;
#X obj 362 249 list prepend;
#X obj 452 249 t a;
#X msg 362 175 10;
#X obj 339 148 t b b b;
#X obj 339 274 list;
#X text 77 30 Switch on the "show-centroid"-metro and play with the
values in the array.;
#X obj 79 344 loadbang;
#X msg 79 414 0.56 0.59 0.8 0.98 0.3 0.64 0.96 0.57 0.55 0.08;
#X connect 0 0 22 0;
#X connect 1 0 0 0;
#X connect 2 0 3 0;
#X connect 6 0 9 0;
#X connect 7 0 6 0;
#X connect 8 0 9 1;
#X connect 10 0 9 1;
#X connect 11 0 18 0;
#X connect 12 0 11 0;
#X connect 13 0 14 0;
#X connect 14 0 15 0;
#X connect 15 0 16 0;
#X connect 15 0 19 1;
#X connect 16 0 15 1;
#X connect 17 0 13 0;
#X connect 18 0 19 0;
#X connect 18 1 17 0;
#X connect 18 2 15 1;
#X connect 19 0 7 0;
#X connect 21 0 1 0;
#X connect 22 0 2 0;
#X restore 392 510 pd graphical-centroid;
#X text 321 510 Also see:;
#N canvas 520 35 494 396 META 0;
#X text 12 5 KEYWORDS control list_op;
#X text 12 25 LICENSE SIBSD;
#X text 12 135 AUTHOR Frank Barknecht;
#X text 12 155 HELP_PATCH_AUTHORS Frank Barknecht. "pd meta" information
added by Jonathan Wilkes for Pd version 0.42.;
#X text 12 75 INLET_0 list;
#X text 12 95 OUTLET_0 float;
#X text 12 115 OUTLET_1 bang;
#X text 12 45 DESCRIPTION calculate the centroid or center of mass
of a list of floats;
#X restore 544 540 pd META;
#X connect 1 0 6 0;
#X connect 2 0 6 0;
#X connect 3 0 6 0;
#X connect 5 0 6 0;
#X connect 6 0 0 0;
#X connect 6 1 4 0;
#X connect 11 0 6 0;
#X connect 12 0 6 0;
#X connect 14 0 6 0;
#X connect 15 0 16 0;
#X connect 16 0 6 0;
#X connect 17 0 15 0;
#X connect 18 0 6 0;
#X connect 19 0 6 0;
#X connect 20 0 6 0;
#X connect 21 0 6 0;
