diff options
author | Cyrille Henry <nusmuk@users.sourceforge.net> | 2011-07-26 19:29:42 +0000 |
---|---|---|
committer | Cyrille Henry <nusmuk@users.sourceforge.net> | 2011-07-26 19:29:42 +0000 |
commit | e80dc405e548667e8c21b433dfc9030a6c7ed75b (patch) | |
tree | 95fc21d3f0f697182c8f7bc2b4ed42c719979d6d | |
parent | e714804749ab7827221b1477b861938af14f937c (diff) |
adding lot's of message to get links informations
svn path=/trunk/externals/pmpd/; revision=15166
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | pmpd-help.pd | 407 | ||||
-rw-r--r-- | pmpd.c | 290 | ||||
-rw-r--r-- | pmpd2d-help.pd | 573 | ||||
-rw-r--r-- | pmpd2d.c | 1133 | ||||
-rw-r--r-- | pmpd3d-help.pd | 629 | ||||
-rw-r--r-- | pmpd3d.c | 1484 |
7 files changed, 3841 insertions, 677 deletions
@@ -114,7 +114,7 @@ ifeq ($(UNAME),Linux) EXTENSION = pd_linux OS = linux PD_PATH = /usr - OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer -ffast-math -fno-trapping-math + OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer -ffast-math -fno-trapping-math -mfpmath=sse CFLAGS += -fPIC LDFLAGS += -Wl,--export-dynamic -shared -fPIC LIBS += -lc diff --git a/pmpd-help.pd b/pmpd-help.pd index 284071f..82b4235 100644 --- a/pmpd-help.pd +++ b/pmpd-help.pd @@ -1,23 +1,23 @@ -#N canvas 553 116 575 730 10; +#N canvas 37 61 575 730 10; #X obj 4 369 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 0; -#X obj 5 669 cnv 15 550 40 empty empty empty 20 12 0 14 -158509 -66577 +#X obj 5 689 cnv 15 550 40 empty empty empty 20 12 0 14 -158509 -66577 0; #X obj 8 6 cnv 15 550 30 empty empty empty 20 12 0 14 -233017 -66577 0; #X obj 14 389 cnv 15 75 15 empty empty empty 20 12 0 14 -233017 -66577 0; -#X obj 14 584 cnv 15 75 15 empty empty empty 20 12 0 14 -233017 -66577 +#X obj 14 604 cnv 15 75 15 empty empty empty 20 12 0 14 -233017 -66577 0; -#X obj 4 527 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 +#X obj 4 547 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 0; -#X obj 4 562 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 +#X obj 4 582 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 0; #X obj 7 76 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 0; -#X obj 5 619 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 +#X obj 5 639 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 0; -#X obj 5 639 cnv 15 550 30 empty empty empty 20 12 0 14 -233017 -66577 +#X obj 5 659 cnv 15 550 30 empty empty empty 20 12 0 14 -233017 -66577 0; #N canvas 76 31 777 741 More_Info 0; #X text 25 65 It is designed to implement particules physical model @@ -176,13 +176,13 @@ masses at the creation.; #X text 26 46 pmpd is the 1D object of the msd objects collection. ; #X connect 2 0 3 0; -#X restore 16 675 pd More_Info; +#X restore 16 695 pd More_Info; #X text 12 76 Examples:; #X text 9 369 Inlets:; #X text 19 388 - Left:; -#X text 10 526 Arguments:; -#X text 11 562 Outlets:; -#X text 19 619 See Also:; +#X text 10 546 Arguments:; +#X text 11 582 Outlets:; +#X text 19 639 See Also:; #X text 74 48 Full Name:; #N canvas 58 22 262 70 Related_Objects 0; #X obj 3 10 cnv 15 250 15 empty empty empty 20 12 0 14 -158509 -66577 @@ -192,7 +192,7 @@ masses at the creation.; #X text 5 10 Externals and libraries; #X obj 44 37 pmpd2d; #X obj 140 37 pmpd3d; -#X restore 122 675 pd Related_Objects; +#X restore 122 695 pd Related_Objects; #N canvas 541 387 524 302 init 0; #X msg 89 187 Xmax 127 \, Xmin 0; #X obj 89 215 t a; @@ -250,149 +250,112 @@ souple 3 2 1 0.5; #X obj 261 152 unpack f f f f; #X text 101 388 Bang - A bang at the left inlet compute the new model state based on previous instant.; -#X text 158 478 To set the model parameters after creation.; -#X text 158 456 To create the model masses and links.; -#X text 158 501 To get the model parameters; -#N canvas 818 245 561 671 creation________ 0; -#X obj 11 95 cnv 15 100 35 empty empty empty 20 12 0 14 -233017 -66577 -0; -#X obj 5 75 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 -0; -#X obj 5 3 cnv 15 550 15 empty empty empty 20 12 0 14 -233017 -66577 -0; -#X text 7 2 CREATION Messages; -#X obj 10 156 cnv 15 150 140 empty empty empty 20 12 0 14 -233017 -66577 -0; -#X obj 4 137 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 -0; -#X obj 10 332 cnv 15 240 220 empty empty empty 20 12 0 14 -233017 -66577 -0; -#X obj 3 308 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 -0; -#X msg 32 104 reset; -#X text 202 167 Add a mass; -#X text 288 168 \$1 : Id (symbol); -#X text 287 188 \$2 : fixed or mobile (0/1); -#X text 287 206 \$3 : mass; -#X msg 32 167 mass \$1 \$2 \$3 \$4; -#X text 287 224 \$4 : initial position; -#X text 7 137 Masses :; -#X text 7 74 Reset :; -#X text 129 105 Delete all masses \, links and internal variables; -#X text 6 308 Links :; -#X text 271 360 \$1 : Id (symbol); -#X text 271 360 \$1 : Id (symbol); -#X text 271 413 \$4 : rigidity; -#X text 271 378 \$2 : creation No/Id of mass1; -#X text 271 396 \$3 : creation No/Id of mass2; -#X text 266 341 Add link(s); -#X text 271 431 \$5 : damping; -#X text 10 28 Creation messages are used to define the structure of -the model. Messages create links and masses or destroy them.; -#X msg 30 341 link \$1 \$2 \$3 \$4 \$5 (\$6 \$7 \$8); -#X text 271 449 \$6 : Power of the rigidity distance; -#X msg 35 519 tabLink \$1 \$2 \$3 \$4 \$5 \$6 \$7; -#X text 267 468 (\$7) : minimum lenght of link; -#X text 268 485 (\$8) : maximum lenght of link; -#X text 266 535 \$1 : Id (symbol); -#X text 266 535 \$1 : Id (symbol); -#X text 266 553 \$2 : creation No/Id of mass1; -#X text 266 571 \$3 : creation No/Id of mass2; -#X text 261 516 Add non linear link(s); -#X text 264 588 \$4 : table name for the rigidity; -#X text 264 606 \$5 : length of the table; -#X text 264 624 \$6 : table name for the damping; -#X text 263 643 \$7 : length of the table; -#X restore 12 457 pd creation________; -#X text 103 542 None; -#X text 18 583 - Left:; -#X text 101 584 Outputs the model parameters asked with the attributes +#X text 188 478 To set the model parameters after creation.; +#X text 188 456 To create the model masses and links.; +#X text 186 512 To get the model parameters; +#X text 103 562 None; +#X text 18 603 - Left:; +#X text 101 604 Outputs the model parameters asked with the attributes messages.; #X text 101 420 Messages - Different messages are used to control the msd object. They are of three types :; -#X text 9 641 CATEGORY: control; -#N canvas 841 74 1139 731 dynamic 0; -#X obj 5 3 cnv 15 550 15 empty empty empty 20 12 0 14 -233017 -66577 +#X text 9 661 CATEGORY: control; +#X text 9 671 KEYWORDS: physical model mass spring damper link; +#X text 111 639 01_msdtest.pd; +#X obj 157 48 pmpd; +#X text 12 8 HELP: pmpd; +#X text 12 20 DESCRIPTION: physical modeling for pd \, based on msd. +; +#X obj 17 319 pmpd; +#X text 266 696 - Cyrille Henry \, 2011; +#X text 283 712 based on MSD by Nicolas Montgermont; +#X obj 17 187 loadbang; +#N canvas 446 66 1236 814 links_attributes 0; +#X obj 5 3 cnv 15 590 15 empty empty empty 20 12 0 14 -233017 -66577 0; -#X obj 10 85 cnv 15 130 580 empty empty empty 20 12 0 14 -233017 -66577 +#X obj 10 108 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 -66577 0; -#X obj 4 62 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 +#X obj 4 87 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577 0; -#X obj 575 86 cnv 15 130 380 empty empty empty 20 12 0 14 -233017 -66577 +#X text 7 2 ATTRIBUTES Messages; +#X text 7 87 Lists :; +#X obj 11 222 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 -66577 0; -#X obj 568 62 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 +#X obj 11 335 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 -66577 0; -#X text 7 62 Masses :; -#X text 571 62 Links :; -#X text 7 2 DYNAMIC SETTINGS Messages; -#X msg 31 96 posX \$1 \$2; -#X text 190 144 Add force on mass(es); -#X msg 30 152 forceX \$1 \$2; -#X text 192 212 \$1 : Value; -#X text 193 107 \$1 : Id (symbol) or No; -#X text 193 161 \$1 : Id (symbol) or No; -#X msg 30 195 Xmin \$1; -#X msg 30 217 Xmax \$1; -#X msg 29 244 setMobile \$1; -#X msg 29 265 setFixed \$1; -#X text 193 89 Set position of fixed mass(es); -#X text 193 125 \$2 : Value; -#X text 193 179 \$2 : Value; -#X text 189 196 Set minimimum and maximum position of all masses; -#X text 188 244 Set mass to mobile or fixed; -#X msg 594 150 setD \$1 \$2; -#X text 749 136 \$2 : New value; -#X msg 594 99 setK \$1 \$2; -#X text 749 192 \$2 : New value; -#X text 749 245 \$2 : New value; -#X text 743 100 Set rigidity of link(s); -#X text 743 156 Set damping of link(s); -#X msg 594 205 setL \$1 \$2; -#X text 743 209 Set initial lenght of link(s); -#X text 749 118 \$1 : Id (symbol) or No; -#X text 749 174 \$1 : Id (symbol) or No; -#X text 749 227 \$1 : Id (symbol) or No; -#X text 191 261 \$1 : Id (symbol) or No; -#X text 10 25 Dynamic settings messages allows the user to redefine -internal parameters of links and masses.; -#X msg 28 286 setDEnv \$1; -#X text 184 287 Change environement damping; -#X text 196 304 \$1 : damping; -#X msg 588 280 setLinkId \$1 \$2; -#X text 742 281 Change the Id of a link; -#X text 743 298 \$1 : link (number or Id); -#X text 746 315 \$2 : New Id; -#X msg 591 353 setLKTab \$1 \$2; -#X text 750 353 change the table (K) size of a non linear link; -#X text 751 373 \$1 : link (number or Id); -#X text 752 390 \$2 : New KL; -#X text 751 435 \$1 : link (number or Id); -#X msg 591 415 setLDTab \$1 \$2; -#X text 750 415 change the table (D) size of a non linear link; -#X text 752 452 \$2 : New DL; -#X text 191 373 \$2 : New Id; -#X msg 25 339 setMassId \$1 \$2; -#X text 191 339 Change the Id of a mass; -#X text 192 356 \$1 : mass (number or Id); -#X msg 23 400 setForce \$1 \$2; -#X msg 23 468 setSpeed \$1 \$2; -#X msg 24 531 addPos \$1 \$2; -#X text 186 420 \$1 : Id (symbol) or No; -#X text 186 438 \$2 : Value; -#X text 183 403 set force on mass(es); -#X text 185 487 \$1 : Id (symbol) or No; -#X text 185 505 \$2 : Value; -#X text 182 470 set speed of a mass(es); -#X text 184 548 \$1 : Id (symbol) or No; -#X text 184 566 \$2 : Value; -#X text 181 531 add pos of a mass(es); -#X msg 26 593 grabMass \$1 \$2 \$3; -#X text 183 592 grab a mass \, and move it; -#X text 185 614 \$1 : mass number; -#X text 185 630 \$2 : position; -#X text 185 646 \$3 : grab or not (0 or 1); -#X restore 12 478 pd dynamic settings; -#N canvas 888 196 1230 682 attributes______ 0; +#X obj 611 26 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 605 5 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577 +0; +#X obj 612 140 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 +-66577 0; +#X obj 612 253 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 +-66577 0; +#X text 369 530 \$1 (optional): Masses Id; +#X text 834 500 \$2 (optional): Masses Id; +#X text 833 487 \$1 : table name; +#X obj 17 584 cnv 15 150 220 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 11 564 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577 +0; +#X msg 22 597 massesPosMean; +#X text 177 613 \$1 : none or Id; +#X msg 23 629 massesPosStd \$1; +#X text 179 644 \$1 : none or Id; +#X text 173 597 output the average position of masses; +#X text 174 628 output the standard deviation of masses position; +#X text 177 674 \$1 : none or Id; +#X text 179 711 \$1 : none or Id; +#X text 173 658 output the average position of masses; +#X text 174 695 output the standard deviation of masses position; +#X text 177 749 \$1 : none or Id; +#X text 178 786 \$1 : none or Id; +#X text 173 733 output the average position of masses; +#X text 173 770 output the standard deviation of masses position; +#X msg 22 696 massesForcesStd \$1; +#X msg 22 658 massesForcesMean; +#X msg 23 735 massesSpeedsMean; +#X msg 22 771 massesSpeedsStd \$1; +#X text 608 5 tables :; +#X text 15 30 The attributes messages ask the object to output some +of his internal parameters. They can be output by lists for positions +and forces of links; +#X text 14 564 statistics (not implemented yet) :; +#X msg 11 119 linksPosL (\$1); +#X text 170 120 Output all links center positions in a list on outlet +No 1; +#X msg 11 138 linksPosXL (\$1); +#X msg 13 229 linksLengthL (\$1); +#X msg 13 248 linksLengthXL (\$1); +#X obj 12 451 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X msg 14 458 linksLengthSpeedL (\$1); +#X msg 14 477 linksLengthSpeedXL (\$1); +#X text 184 459 Output all link lenght deformation speed in a list +on outlet No 1; +#X msg 615 38 linksPosT \$1 (\$2); +#X msg 616 57 linksPosXT \$1 (\$2); +#X msg 616 152 linksLengthT \$1 (\$2); +#X obj 612 369 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 +-66577 0; +#X text 808 377 Output all link lenght deformation speed in a list +on outlet No 1; +#X msg 614 376 linksLengthSpeedT \$1 (\$2); +#X msg 613 395 linksLengthSpeedXT \$1 (\$2); +#X text 793 47 Output all links center positions in a table (\$1); +#X text 170 233 Output all link lenght in a list on outlet No 1; +#X text 171 349 Output all link center speed in a list on outlet No +1; +#X text 797 154 Output all link length in a list on outlet No 1; +#X msg 16 342 linksPosSpeedL (\$1); +#X msg 16 361 linksPosSpeedXL (\$1); +#X msg 616 259 linksPosSpeedT \$1 (\$2); +#X text 795 264 Output all link center speed in a list on outlet No +1; +#X msg 616 171 linksLengthXT \$1 (\$2); +#X msg 616 278 linksPosSpeedXT \$1 (\$2); +#X restore 12 519 pd links_attributes ___; +#N canvas 888 196 1230 682 attributes__________ 0; #X obj 11 95 cnv 15 100 35 empty empty empty 20 12 0 14 -233017 -66577 0; #X obj 5 75 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577 @@ -489,18 +452,140 @@ name \, \$2 (optional): Masses Id); #X text 339 645 [massesPosName mas x2(; #X text 337 581 [massesPosId 1 x1(; #X text 337 596 [massesPosId 2 x2(; -#X restore 12 499 pd attributes______; -#X text 9 651 KEYWORDS: physical model mass spring damper link; -#X text 111 619 01_msdtest.pd; -#X obj 157 48 pmpd; -#X text 12 8 HELP: pmpd; -#X text 12 20 DESCRIPTION: physical modeling for pd \, based on msd. -; -#X obj 17 319 pmpd; -#X text 266 676 - Cyrille Henry \, 2011; -#X text 283 692 based on MSD by Nicolas Montgermont; -#X obj 17 187 loadbang; -#X connect 21 0 51 0; +#X restore 12 499 pd attributes__________; +#N canvas 841 74 1139 731 dynamic 0; +#X obj 5 3 cnv 15 550 15 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 10 85 cnv 15 130 580 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 4 62 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 +0; +#X obj 575 86 cnv 15 130 380 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 568 62 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 +0; +#X text 7 62 Masses :; +#X text 571 62 Links :; +#X text 7 2 DYNAMIC SETTINGS Messages; +#X msg 31 96 posX \$1 \$2; +#X text 190 144 Add force on mass(es); +#X msg 30 152 forceX \$1 \$2; +#X text 192 212 \$1 : Value; +#X text 193 107 \$1 : Id (symbol) or No; +#X text 193 161 \$1 : Id (symbol) or No; +#X msg 30 195 Xmin \$1; +#X msg 30 217 Xmax \$1; +#X msg 29 244 setMobile \$1; +#X msg 29 265 setFixed \$1; +#X text 193 89 Set position of fixed mass(es); +#X text 193 125 \$2 : Value; +#X text 193 179 \$2 : Value; +#X text 189 196 Set minimimum and maximum position of all masses; +#X text 188 244 Set mass to mobile or fixed; +#X msg 594 150 setD \$1 \$2; +#X text 749 136 \$2 : New value; +#X msg 594 99 setK \$1 \$2; +#X text 749 192 \$2 : New value; +#X text 749 245 \$2 : New value; +#X text 743 100 Set rigidity of link(s); +#X text 743 156 Set damping of link(s); +#X msg 594 205 setL \$1 \$2; +#X text 743 209 Set initial lenght of link(s); +#X text 749 118 \$1 : Id (symbol) or No; +#X text 749 174 \$1 : Id (symbol) or No; +#X text 749 227 \$1 : Id (symbol) or No; +#X text 191 261 \$1 : Id (symbol) or No; +#X text 10 25 Dynamic settings messages allows the user to redefine +internal parameters of links and masses.; +#X msg 28 286 setDEnv \$1; +#X text 184 287 Change environement damping; +#X text 196 304 \$1 : damping; +#X msg 588 280 setLinkId \$1 \$2; +#X text 742 281 Change the Id of a link; +#X text 743 298 \$1 : link (number or Id); +#X text 746 315 \$2 : New Id; +#X msg 591 353 setLKTab \$1 \$2; +#X text 750 353 change the table (K) size of a non linear link; +#X text 751 373 \$1 : link (number or Id); +#X text 752 390 \$2 : New KL; +#X text 751 435 \$1 : link (number or Id); +#X msg 591 415 setLDTab \$1 \$2; +#X text 750 415 change the table (D) size of a non linear link; +#X text 752 452 \$2 : New DL; +#X text 191 373 \$2 : New Id; +#X msg 25 339 setMassId \$1 \$2; +#X text 191 339 Change the Id of a mass; +#X text 192 356 \$1 : mass (number or Id); +#X msg 23 400 setForce \$1 \$2; +#X msg 23 468 setSpeed \$1 \$2; +#X msg 24 531 addPos \$1 \$2; +#X text 186 420 \$1 : Id (symbol) or No; +#X text 186 438 \$2 : Value; +#X text 183 403 set force on mass(es); +#X text 185 487 \$1 : Id (symbol) or No; +#X text 185 505 \$2 : Value; +#X text 182 470 set speed of a mass(es); +#X text 184 548 \$1 : Id (symbol) or No; +#X text 184 566 \$2 : Value; +#X text 181 531 add pos of a mass(es); +#X msg 26 593 grabMass \$1 \$2 \$3; +#X text 183 592 grab a mass \, and move it; +#X text 185 614 \$1 : mass number; +#X text 185 630 \$2 : position; +#X text 185 646 \$3 : grab or not (0 or 1); +#X restore 12 478 pd dynamic settings ___; +#N canvas 818 245 561 671 creation____________ 0; +#X obj 11 95 cnv 15 100 35 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 5 75 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 +0; +#X obj 5 3 cnv 15 550 15 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X text 7 2 CREATION Messages; +#X obj 10 156 cnv 15 150 140 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 4 137 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 +0; +#X obj 10 332 cnv 15 240 220 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 3 308 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 +0; +#X msg 32 104 reset; +#X text 202 167 Add a mass; +#X text 288 168 \$1 : Id (symbol); +#X text 287 188 \$2 : fixed or mobile (0/1); +#X text 287 206 \$3 : mass; +#X msg 32 167 mass \$1 \$2 \$3 \$4; +#X text 287 224 \$4 : initial position; +#X text 7 137 Masses :; +#X text 7 74 Reset :; +#X text 129 105 Delete all masses \, links and internal variables; +#X text 6 308 Links :; +#X text 271 360 \$1 : Id (symbol); +#X text 271 360 \$1 : Id (symbol); +#X text 271 413 \$4 : rigidity; +#X text 271 378 \$2 : creation No/Id of mass1; +#X text 271 396 \$3 : creation No/Id of mass2; +#X text 266 341 Add link(s); +#X text 271 431 \$5 : damping; +#X text 10 28 Creation messages are used to define the structure of +the model. Messages create links and masses or destroy them.; +#X msg 30 341 link \$1 \$2 \$3 \$4 \$5 (\$6 \$7 \$8); +#X text 271 449 \$6 : Power of the rigidity distance; +#X msg 35 519 tabLink \$1 \$2 \$3 \$4 \$5 \$6 \$7; +#X text 267 468 (\$7) : minimum lenght of link; +#X text 268 485 (\$8) : maximum lenght of link; +#X text 266 535 \$1 : Id (symbol); +#X text 266 535 \$1 : Id (symbol); +#X text 266 553 \$2 : creation No/Id of mass1; +#X text 266 571 \$3 : creation No/Id of mass2; +#X text 261 516 Add non linear link(s); +#X text 264 588 \$4 : table name for the rigidity; +#X text 264 606 \$5 : length of the table; +#X text 264 624 \$6 : table name for the damping; +#X text 263 643 \$7 : length of the table; +#X restore 12 457 pd creation____________; +#X connect 21 0 48 0; #X connect 22 0 25 0; #X connect 25 0 24 0; #X connect 27 0 26 0; @@ -511,5 +596,5 @@ name \, \$2 (optional): Masses Id); #X connect 33 1 23 0; #X connect 33 2 31 0; #X connect 33 3 32 0; -#X connect 51 0 20 0; -#X connect 54 0 27 0; +#X connect 48 0 20 0; +#X connect 51 0 27 0; @@ -31,8 +31,8 @@ #include "stdio.h"
#include "math.h"
-#define nb_max_link 100000
-#define nb_max_mass 100000
+#define nb_max_link 10000000
+#define nb_max_mass 1000000
#define max(a,b) ( ((a) > (b)) ? (a) : (b) )
#define min(a,b) ( ((a) < (b)) ? (a) : (b) )
@@ -293,7 +293,8 @@ void pmpd_link(t_pmpd *x, t_symbol *s, int argc, t_atom *argv) {
if ( (atom_getsymbolarg(1,argc,argv) == x->mass[i].Id)&(atom_getsymbolarg(2,argc,argv) == x->mass[j].Id))
{
- if (!( (x->mass[i].Id == x->mass[j].Id) && (i>j) )) // si lien entre 2 serie de masses identique entres elle, alors on ne creer qu'un lien sur 2, pour evider les redondances
+ if (!( (x->mass[i].Id == x->mass[j].Id) && (i>j) ))
+ // si lien entre 2 serie de masses identique entres elle, alors on ne creer qu'un lien sur 2, pour evider les redondances
pmpd_create_link(x, Id, i, j, K, D, Pow, Lmin, Lmax, 0);
}
}
@@ -362,7 +363,8 @@ void pmpd_tabLink(t_pmpd *x, t_symbol *s, int argc, t_atom *argv) {
if ( (atom_getsymbolarg(1,argc,argv) == x->mass[i].Id)&(atom_getsymbolarg(2,argc,argv) == x->mass[j].Id))
{
- if (!( (x->mass[i].Id == x->mass[j].Id) && (i>j) )) // si lien entre 2 serie de masses identique entres elle, alors on ne creer qu'un lien sur 2, pour evider les redondances
+ if (!( (x->mass[i].Id == x->mass[j].Id) && (i>j) ))
+ // si lien entre 2 serie de masses identique entres elle, alors on ne creer qu'un lien sur 2, pour evider les redondances
{
pmpd_create_link(x, Id, i, j, 1, 1, 1, -1000000, 1000000, 2);
x->link[x->nb_link-1].arrayK = arrayK;
@@ -1484,6 +1486,258 @@ void pmpd_massesSpeedsStd(t_pmpd *x, t_symbol *s, int argc, t_atom *argv) outlet_anything(x->main_outlet, gensym("massesSpeedsStd"),1 , std_out);
}
+// --------------------------------------------
+
+void pmpd_linksPosL(t_pmpd *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),(x->link[i].mass1->posX + x->link[i].mass2->posX)/2);
+ }
+ outlet_anything(x->main_outlet, gensym("linksPosXL"),x->nb_link , pos_list);
+}
+
+void pmpd_linksLengthL(t_pmpd *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),x->link[i].mass2->posX - x->link[i].mass1->posX);
+ }
+ outlet_anything(x->main_outlet, gensym("linksLengthXL"),x->nb_link , pos_list);
+}
+
+void pmpd_linksPosSpeedL(t_pmpd *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),(x->link[i].mass1->speedX + x->link[i].mass2->speedX)/2);
+ }
+ outlet_anything(x->main_outlet, gensym("linksPosSpeedXL"),x->nb_link , pos_list);
+}
+
+void pmpd_linksLengthSpeedL(t_pmpd *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),x->link[i].mass2->speedX - x->link[i].mass1->speedX);
+ }
+ outlet_anything(x->main_outlet, gensym("linksLengthSpeedXL"),x->nb_link , pos_list);
+}
+
+void pmpd_linksPosT(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = (x->link[i].mass1->posX + x->link[i].mass2->posX)/2;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = (x->link[j].mass1->posX + x->link[j].mass2->posX)/2;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd_linksLengthT(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = x->link[i].mass2->posX - x->link[i].mass1->posX;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = x->link[j].mass2->posX - x->link[j].mass1->posX;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd_linksPosSpeedT(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = (x->link[i].mass1->speedX + x->link[i].mass2->speedX)/2;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = (x->link[j].mass1->speedX + x->link[j].mass2->speedX)/2;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd_linksLengthSpeedT(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = x->link[i].mass2->speedX - x->link[i].mass1->speedX;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = x->link[j].mass2->speedX - x->link[j].mass1->speedX;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+//----------------------------------------------
+
void pmpd_grabMass(t_pmpd *x, t_float posX, t_float grab)
{
t_float dist, tmp;
@@ -1586,6 +1840,34 @@ void pmpd_setup(void) class_addmethod(pmpd_class, (t_method)pmpd_massesSpeedsMean,gensym("massesSpeedsMean"), A_GIMME, 0);
class_addmethod(pmpd_class, (t_method)pmpd_massesSpeedsStd, gensym("massesSpeedsStd"),A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksPosL, gensym("linksPosXL"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksLengthL, gensym("linksLengthXL"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksPosSpeedL, gensym("linksPosSpeedXL"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksLengthSpeedL, gensym("linksLengthXL"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksPosT, gensym("linksPosXT"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksLengthT, gensym("linksLengthXT"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksPosSpeedT, gensym("linksPosSpeedXT"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksLengthSpeedT, gensym("linksLengthSpeedXT"), A_GIMME, 0);
+
+ class_addmethod(pmpd_class, (t_method)pmpd_linksPosL, gensym("linksPosL"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksLengthL, gensym("linksLengthL"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksPosSpeedL, gensym("linksPosSpeedL"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksLengthSpeedL, gensym("linksLengthL"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksPosT, gensym("linksPosT"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksLengthT, gensym("linksLengthT"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksPosSpeedT, gensym("linksPosSpeedT"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksLengthSpeedT, gensym("linksLengthSpeedT"), A_GIMME, 0);
+
+/* class_addmethod(pmpd_class, (t_method)pmpd_linksPosMean, gensym("linksPosMean"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksLengthMean, gensym("linksLengthMean"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksPosSpeedMean, gensym("linksPosSpeedMean"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksLengthSpeedMean, gensym("linksLengthSpeedMean"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksPosStd, gensym("linksPosStd"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksLengthStd, gensym("linksLengthStd"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksPosSpeedStd, gensym("linksPosSpeedStd"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linksLengthSpeedStd0, gensym("linksLengthSpeedStd"), A_GIMME, 0);
+*/
+
class_addmethod(pmpd_class, (t_method)pmpd_grabMass, gensym("grabMass"), A_DEFFLOAT, A_DEFFLOAT, 0);
}
diff --git a/pmpd2d-help.pd b/pmpd2d-help.pd index 3fcd199..937a5b4 100644 --- a/pmpd2d-help.pd +++ b/pmpd2d-help.pd @@ -1,23 +1,23 @@ -#N canvas 150 72 568 710 10; +#N canvas 150 72 571 767 10; #X obj 4 369 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 0; -#X obj 5 665 cnv 15 550 30 empty empty empty 20 12 0 14 -158509 -66577 +#X obj 5 685 cnv 15 550 30 empty empty empty 20 12 0 14 -158509 -66577 0; #X obj 8 6 cnv 15 550 30 empty empty empty 20 12 0 14 -233017 -66577 0; #X obj 14 389 cnv 15 75 15 empty empty empty 20 12 0 14 -233017 -66577 0; -#X obj 14 584 cnv 15 75 15 empty empty empty 20 12 0 14 -233017 -66577 +#X obj 14 604 cnv 15 75 15 empty empty empty 20 12 0 14 -233017 -66577 0; -#X obj 4 527 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 +#X obj 4 547 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 0; -#X obj 4 562 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 +#X obj 4 582 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 0; #X obj 7 76 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 0; -#X obj 5 615 cnv 15 550 20 empty empty empty 20 12 0 14 -158509 -66577 +#X obj 5 635 cnv 15 550 20 empty empty empty 20 12 0 14 -158509 -66577 0; -#X obj 5 635 cnv 15 550 30 empty empty empty 20 12 0 14 -233017 -66577 +#X obj 5 655 cnv 15 550 30 empty empty empty 20 12 0 14 -233017 -66577 0; #N canvas 76 31 921 714 More_Info 0; #X text 96 12 pmpd : mass - spring - damper model; @@ -226,13 +226,13 @@ their Id.; #X text 28 41 pmpd is the 2D object of the pmpd objects collection. ; #X connect 3 0 4 0; -#X restore 16 673 pd More_Info; +#X restore 16 693 pd More_Info; #X text 12 76 Examples:; #X text 9 369 Inlets:; #X text 19 388 - Left:; -#X text 10 526 Arguments:; -#X text 11 562 Outlets:; -#X text 19 617 See Also:; +#X text 10 546 Arguments:; +#X text 11 582 Outlets:; +#X text 19 637 See Also:; #X text 74 48 Full Name:; #N canvas 58 22 262 70 Related_Objects 0; #X obj 3 10 cnv 15 250 15 empty empty empty 20 12 0 14 -158509 -66577 @@ -242,7 +242,7 @@ their Id.; #X text 5 10 Externals and libraries; #X obj 44 37 pmpd; #X obj 141 39 pmpd3d; -#X restore 122 673 pd Related_Objects; +#X restore 122 693 pd Related_Objects; #N canvas 257 262 759 345 init 0; #X obj 89 215 t a; #X obj 89 33 loadbang; @@ -292,10 +292,232 @@ their Id.; -1 -1; #X text 101 388 Bang - A bang at the left inlet compute the new model state based on previous instant.; -#X text 158 478 To set the model parameters after creation.; -#X text 158 456 To create the model masses and links.; -#X text 158 501 To get the model parameters; -#N canvas 41 48 967 626 creation________ 0; +#X text 182 479 To set the model parameters after creation.; +#X text 182 457 To create the model masses and links.; +#X text 183 509 To get the model parameters; +#X text 103 562 None; +#X text 18 603 - Left:; +#X text 101 604 Outputs the model parameters asked with the attributes +messages.; +#X text 101 420 Messages - Different messages are used to control the +pmpd object. They are of three types :; +#X text 9 659 CATEGORY: control; +#X text 9 669 KEYWORDS: physical model mass spring damper link; +#X text 12 8 HELP: pmpd2d; +#X obj 157 48 pmpd2d; +#X text 112 638 01_pmpd2dtest.pd; +#X obj 18 296 pmpd2d; +#N canvas 731 296 450 300 gemmouse 0; +#X obj 189 77 gemmouse; +#X obj 189 184 pack f f; +#X obj 189 218 spigot; +#X obj 109 243 outlet; +#X obj 109 36 inlet; +#X obj 109 98 t b; +#X obj 238 131 + 4; +#X msg 57 182 posX fix \$1; +#X msg 57 203 posY fix \$2; +#X obj 189 108 / 62.5; +#X obj 237 107 / -62.5; +#X obj 189 131 - 4; +#X obj 109 125 list 0 0; +#X connect 0 0 9 0; +#X connect 0 1 10 0; +#X connect 0 2 2 1; +#X connect 1 0 2 0; +#X connect 2 0 12 1; +#X connect 4 0 5 0; +#X connect 5 0 12 0; +#X connect 6 0 1 1; +#X connect 7 0 3 0; +#X connect 8 0 3 0; +#X connect 9 0 11 0; +#X connect 10 0 6 0; +#X connect 11 0 1 0; +#X connect 12 0 7 0; +#X connect 12 0 8 0; +#X restore 393 295 pd gemmouse; +#X obj 393 274 gemhead; +#X obj 346 216 gemwin; +#X msg 357 193 0 \, destroy; +#N canvas 472 258 550 319 gemrender 0; +#X obj 48 203 translateXYZ; +#X obj 48 229 sphere 0.1; +#X obj 127 24 inlet; +#X obj 360 32 inlet; +#X obj 275 232 curve 2; +#X msg 431 81 \$4 \$5 0; +#X msg 359 77 \$2 \$3 0; +#X obj 359 105 t b a; +#X obj 127 62 unpack f f f; +#X obj 166 88 t b f; +#X msg 48 110 0; +#X obj 48 77 loadbang; +#X obj 48 137 gemhead; +#X msg 275 160 0; +#X obj 275 127 loadbang; +#X obj 275 187 gemhead; +#X connect 0 0 1 0; +#X connect 2 0 8 0; +#X connect 3 0 5 0; +#X connect 3 0 6 0; +#X connect 5 0 4 2; +#X connect 6 0 7 0; +#X connect 7 0 15 0; +#X connect 7 1 4 1; +#X connect 8 1 9 0; +#X connect 8 2 0 2; +#X connect 9 0 12 0; +#X connect 9 1 0 1; +#X connect 10 0 12 0; +#X connect 11 0 10 0; +#X connect 12 0 0 0; +#X connect 13 0 15 0; +#X connect 14 0 13 0; +#X connect 15 0 4 0; +#X restore 172 320 pd gemrender; +#X msg 346 129 reset \, create \, 1; +#X text 135 98 Sorry \, you need GEM for this example...; +#X text 169 132 1 Create window -->; +#X text 169 163 2 Drag the structure with the mouse; +#X text 169 195 3 Destroy the window -->; +#X obj 172 294 route massesPos linksPosNo; +#X text 11 19 DESCRIPTION: Physical modeling for Pd in 2d; +#X text 265 689 - Cyrille Henry 2011; +#X text 265 701 based on MSD by Nicolas Montgermont \, 2005; +#N canvas 446 66 1236 814 links_attributes 0; +#X obj 5 3 cnv 15 590 15 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 10 108 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 4 87 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577 +0; +#X text 7 2 ATTRIBUTES Messages; +#X text 7 87 Lists :; +#X text 169 167 Output all norm of position vector (sqrt(x*x+y*y)) +in a list on outlet No 1; +#X obj 11 222 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 11 335 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 611 26 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 605 5 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577 +0; +#X obj 612 140 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 +-66577 0; +#X obj 612 253 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 +-66577 0; +#X msg 13 286 massesSpeedsNormL (\$1); +#X text 402 546 \$1 (optional): Masses Id; +#X text 850 488 \$2 (optional): Masses Id; +#X text 849 475 \$1 : table name; +#X obj 17 584 cnv 15 150 220 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 11 564 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577 +0; +#X msg 22 597 massesPosMean; +#X text 177 613 \$1 : none or Id; +#X msg 23 629 massesPosStd \$1; +#X text 179 644 \$1 : none or Id; +#X text 173 597 output the average position of masses; +#X text 174 628 output the standard deviation of masses position; +#X text 177 674 \$1 : none or Id; +#X text 179 711 \$1 : none or Id; +#X text 173 658 output the average position of masses; +#X text 174 695 output the standard deviation of masses position; +#X text 177 749 \$1 : none or Id; +#X text 178 786 \$1 : none or Id; +#X text 173 733 output the average position of masses; +#X text 173 770 output the standard deviation of masses position; +#X msg 22 696 massesForcesStd \$1; +#X msg 22 658 massesForcesMean; +#X msg 23 735 massesSpeedsMean; +#X msg 22 771 massesSpeedsStd \$1; +#X text 608 5 tables :; +#X text 15 30 The attributes messages ask the object to output some +of his internal parameters. They can be output by lists for positions +and forces of links; +#X text 14 564 statistics (not implemented yet) :; +#X msg 11 119 linksPosL (\$1); +#X text 170 120 Output all links center positions in a list on outlet +No 1; +#X msg 11 138 linksPosXL (\$1); +#X msg 12 157 linksPosYL (\$1); +#X msg 12 176 linksPosNormL (\$1); +#X msg 13 229 linksLengthL (\$1); +#X msg 13 248 linksLengthXL (\$1); +#X msg 13 267 linksLengthYL (\$1); +#X text 170 144 Output all links x or y in a list on outlet No 1; +#X obj 12 451 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X msg 14 458 linksLengthSpeedL (\$1); +#X msg 14 477 linksLengthSpeedXL (\$1); +#X msg 14 496 linksLengthSpeedYL (\$1); +#X msg 14 515 massesSpeedsSpeedNormL (\$1); +#X text 184 459 Output all link lenght deformation speed in a list +on outlet No 1; +#X text 184 485 Output all link lenght deformation speed in x or y +in a list on outlet No 1; +#X text 215 515 Output all norm of link lenght deformation speed vector +(sqrt(x*x+y*y)) in a list on outlet No 1; +#X msg 615 38 linksPosT \$1 (\$2); +#X msg 616 57 linksPosXT \$1 (\$2); +#X msg 615 76 linksPosYT \$1 (\$2); +#X msg 615 96 linksPosNormT \$1 (\$2); +#X msg 616 152 linksLengthT \$1 (\$2); +#X msg 616 210 linksLengthNormT \$1 (\$2); +#X obj 612 369 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 +-66577 0; +#X text 808 377 Output all link lenght deformation speed in a list +on outlet No 1; +#X text 806 401 Output all link lenght deformation speed in x or y +in a list on outlet No 1; +#X text 839 430 Output all norm of link lenght deformation speed vector +(sqrt(x*x+y*y)) in a list on outlet No 1; +#X msg 614 376 linksLengthSpeedT \$1 (\$2); +#X msg 613 395 linksLengthSpeedXT \$1 (\$2); +#X msg 614 414 linksLengthSpeedYT \$1 (\$2); +#X msg 614 434 massesSpeedsSpeedNormT \$1 (\$2); +#X text 794 35 Output all links center positions in a table (\$1); +#X text 794 67 Output all links center positions x or y in a table +(\$1); +#X text 789 90 Output all norm of links center positions vector (sqrt(x*x+y*y)) +in a table (\$1); +#X text 170 233 Output all link lenght in a list on outlet No 1; +#X text 171 255 Output all link lenght in x or y in a list on outlet +No 1; +#X text 181 280 Output all norm of link lenght vector (sqrt(x*x+y*y)) +in a list on outlet No 1; +#X text 171 349 Output all link center speed in a list on outlet No +1; +#X text 175 363 Output all link center speed in x or y in a list on +outlet No 1; +#X text 192 393 Output all norm of link center speed vector (sqrt(x*x+y*y)) +in a list on outlet No 1; +#X text 797 154 Output all link length in a list on outlet No 1; +#X text 796 181 Output all link length in x or y in a list on outlet +No 1; +#X text 799 201 Output all norm of link length vector (sqrt(x*x+y*y)) +in a list on outlet No 1; +#X msg 16 342 linksPosSpeedL (\$1); +#X msg 16 361 linksPosSpeedXL (\$1); +#X msg 15 380 linksPosSpeedYL (\$1); +#X msg 15 399 linksPosSpeedNormL (\$1); +#X msg 616 259 linksPosSpeedT \$1 (\$2); +#X msg 616 316 linksPosSpeedNormT \$1 (\$2); +#X text 795 264 Output all link center speed in a list on outlet No +1; +#X text 798 282 Output all link center speed in x or y in a list on +outlet No 1; +#X text 813 313 Output all norm of link center speed vector (sqrt(x*x+y*y)) +in a list on outlet No 1; +#X msg 616 171 linksLengthXT \$1 (\$2); +#X msg 616 190 linksLengthYT \$1 (\$2); +#X msg 616 278 linksPosSpeedXT \$1 (\$2); +#X msg 616 297 linksPosSpeedYT \$1 (\$2); +#X restore 12 519 pd links_attributes ___; +#N canvas 41 48 967 626 creation____________ 0; #X obj 5 75 cnv 15 450 15 empty empty empty 20 12 0 14 -158509 -66577 0; #X obj 5 3 cnv 15 450 15 empty empty empty 20 12 0 14 -233017 -66577 @@ -367,114 +589,8 @@ following a vector.; 0; #X text 497 351 Table links :; #X connect 29 0 31 0; -#X restore 12 457 pd creation________; -#X text 103 542 None; -#X text 18 583 - Left:; -#X text 101 584 Outputs the model parameters asked with the attributes -messages.; -#X text 101 420 Messages - Different messages are used to control the -pmpd object. They are of three types :; -#X text 9 639 CATEGORY: control; -#N canvas 100 72 1078 872 dynamic 0; -#X obj 5 3 cnv 15 550 15 empty empty empty 20 12 0 14 -233017 -66577 -0; -#X obj 10 85 cnv 15 150 750 empty empty empty 20 12 0 14 -233017 -66577 -0; -#X obj 4 62 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 -0; -#X obj 574 86 cnv 15 130 350 empty empty empty 20 12 0 14 -233017 -66577 -0; -#X obj 567 62 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 -0; -#X text 7 62 Masses :; -#X text 570 62 Links :; -#X text 7 2 DYNAMIC SETTINGS Messages; -#X msg 31 116 posX \$1 \$2; -#X text 191 178 Add force on mass(es); -#X msg 30 193 forceX \$1 \$2; -#X text 190 114 \$1 : Id (symbol) or No; -#X text 193 195 \$1 : Id (symbol) or No; -#X msg 31 285 Xmin \$1; -#X msg 90 285 Xmax \$1; -#X msg 29 334 setMobile \$1; -#X msg 29 355 setFixed \$1; -#X text 190 96 Set position of fixed mass(es); -#X text 177 268 Set minimimum and maximum position of all masses; -#X text 188 334 Set mass to mobile or fixed; -#X msg 593 150 setD \$1 \$2; -#X text 748 136 \$2 : New value; -#X msg 593 99 setK \$1 \$2; -#X text 748 192 \$2 : New value; -#X text 748 245 \$2 : New value; -#X text 742 100 Set rigidity of link(s); -#X text 742 156 Set damping of link(s); -#X msg 593 205 setL \$1 \$2; -#X text 742 209 Set initial lenght of link(s); -#X text 748 118 \$1 : Id (symbol) or No; -#X text 748 174 \$1 : Id (symbol) or No; -#X text 748 227 \$1 : Id (symbol) or No; -#X text 191 351 \$1 : Id (symbol) or No; -#X text 10 25 Dynamic settings messages allows the user to redefine -internal parameters of links and masses.; -#X msg 29 391 grabMass \$1 \$2 \$3; -#X text 186 391 Grab nearest mass; -#X text 191 407 \$1 \, \$2 : position; -#X text 190 424 \$3 : grab or not (0/1); -#X msg 31 137 posY \$1 \$2; -#X msg 30 214 forceY \$1 \$2; -#X msg 31 307 Ymin \$1; -#X msg 90 307 Ymax \$1; -#X text 191 488 \$2 : New Id; -#X msg 30 456 setMassId \$1 \$2; -#X text 191 454 Change the Id of a mass; -#X text 192 471 \$1 : mass (number or Id); -#X msg 23 583 setSpeed \$1 \$2; -#X text 186 535 \$1 : Id (symbol) or No; -#X text 183 518 set force on mass(es); -#X text 185 602 \$1 : Id (symbol) or No; -#X text 182 585 set speed of a mass(es); -#X text 184 663 \$1 : Id (symbol) or No; -#X text 181 646 add pos of a mass(es); -#X msg 23 737 grabMass \$1 \$2 \$3; -#X text 183 707 grab a mass \, and move it; -#X text 185 729 \$1 : mass number; -#X text 185 745 \$2 : position; -#X text 185 761 \$3 : grab or not (0 or 1); -#X msg 24 515 setForce \$1 \$2 \$3; -#X text 186 553 \$2 / \$3 : Value; -#X msg 24 535 setForceX \$1 \$2; -#X msg 24 554 setForceY \$1 \$2; -#X msg 31 96 pos \$1 \$2 \$3; -#X text 190 132 \$2 / \$3 : Value; -#X msg 30 173 force \$1 \$2 \$3; -#X text 191 213 \$2 / \$3 : Value; -#X text 180 284 \$1 / \$2 : Value; -#X msg 27 805 setDEnv \$1; -#X text 178 798 Change environement damping; -#X text 190 815 \$1 : damping; -#X msg 23 602 setSpeedX \$1 \$2; -#X msg 23 621 setSpeedY \$1 \$2; -#X text 185 619 \$2 / \$3 : Value; -#X text 185 681 \$2 / \$3 : Value; -#X msg 24 646 addPos \$1 \$2 \$3; -#X msg 588 280 setLinkId \$1 \$2; -#X text 742 281 Change the Id of a link; -#X text 743 298 \$1 : link (number or Id); -#X text 746 315 \$2 : New Id; -#X msg 591 353 setLKTab \$1 \$2; -#X text 750 353 change the table (K) size of a non linear link; -#X text 751 373 \$1 : link (number or Id); -#X text 752 390 \$2 : New KL; -#X text 751 435 \$1 : link (number or Id); -#X msg 591 415 setLDTab \$1 \$2; -#X text 750 415 change the table (D) size of a non linear link; -#X text 752 452 \$2 : New DL; -#X msg 31 245 min \$1 \$2; -#X msg 31 265 max \$1 \$2; -#X msg 24 665 addPosX \$1 \$2; -#X msg 24 685 addPosY \$1 \$2; -#X restore 12 478 pd dynamic settings; -#N canvas 30 26 1236 814 attributes______ 0; +#X restore 12 457 pd creation____________; +#N canvas 30 26 1236 814 attributes__________ 0; #X obj 11 95 cnv 15 100 35 empty empty empty 20 12 0 14 -233017 -66577 0; #X obj 5 75 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577 @@ -618,98 +734,121 @@ a table (\$1); #X text 941 729 [massesPosId 2 x1 y2(; #X text 942 765 [massesPosName mas x1 y1(; #X text 942 780 [massesPosName mas x2 y2(; -#X restore 12 499 pd attributes______; -#X text 9 649 KEYWORDS: physical model mass spring damper link; -#X text 12 8 HELP: pmpd2d; -#X obj 157 48 pmpd2d; -#X text 112 618 01_pmpd2dtest.pd; -#X obj 18 296 pmpd2d; -#N canvas 731 296 450 300 gemmouse 0; -#X obj 189 77 gemmouse; -#X obj 189 184 pack f f; -#X obj 189 218 spigot; -#X obj 109 243 outlet; -#X obj 109 36 inlet; -#X obj 109 98 t b; -#X obj 238 131 + 4; -#X msg 57 182 posX fix \$1; -#X msg 57 203 posY fix \$2; -#X obj 189 108 / 62.5; -#X obj 237 107 / -62.5; -#X obj 189 131 - 4; -#X obj 109 125 list 0 0; -#X connect 0 0 9 0; -#X connect 0 1 10 0; -#X connect 0 2 2 1; -#X connect 1 0 2 0; -#X connect 2 0 12 1; -#X connect 4 0 5 0; -#X connect 5 0 12 0; -#X connect 6 0 1 1; -#X connect 7 0 3 0; -#X connect 8 0 3 0; -#X connect 9 0 11 0; -#X connect 10 0 6 0; -#X connect 11 0 1 0; -#X connect 12 0 7 0; -#X connect 12 0 8 0; -#X restore 393 295 pd gemmouse; -#X obj 393 274 gemhead; -#X obj 346 216 gemwin; -#X msg 357 193 0 \, destroy; -#N canvas 472 258 550 319 gemrender 0; -#X obj 48 203 translateXYZ; -#X obj 48 229 sphere 0.1; -#X obj 127 24 inlet; -#X obj 360 32 inlet; -#X obj 275 232 curve 2; -#X msg 431 81 \$4 \$5 0; -#X msg 359 77 \$2 \$3 0; -#X obj 359 105 t b a; -#X obj 127 62 unpack f f f; -#X obj 166 88 t b f; -#X msg 48 110 0; -#X obj 48 77 loadbang; -#X obj 48 137 gemhead; -#X msg 275 160 0; -#X obj 275 127 loadbang; -#X obj 275 187 gemhead; -#X connect 0 0 1 0; -#X connect 2 0 8 0; -#X connect 3 0 5 0; -#X connect 3 0 6 0; -#X connect 5 0 4 2; -#X connect 6 0 7 0; -#X connect 7 0 15 0; -#X connect 7 1 4 1; -#X connect 8 1 9 0; -#X connect 8 2 0 2; -#X connect 9 0 12 0; -#X connect 9 1 0 1; -#X connect 10 0 12 0; -#X connect 11 0 10 0; -#X connect 12 0 0 0; -#X connect 13 0 15 0; -#X connect 14 0 13 0; -#X connect 15 0 4 0; -#X restore 172 320 pd gemrender; -#X msg 346 129 reset \, create \, 1; -#X text 135 98 Sorry \, you need GEM for this example...; -#X text 169 132 1 Create window -->; -#X text 169 163 2 Drag the structure with the mouse; -#X text 169 195 3 Destroy the window -->; -#X obj 172 294 route massesPos linksPosNo; -#X text 11 19 DESCRIPTION: Physical modeling for Pd in 2d; -#X text 265 669 - Cyrille Henry 2011; -#X text 265 681 based on MSD by Nicolas Montgermont \, 2005; -#X connect 21 0 43 0; +#X restore 12 499 pd attributes__________; +#N canvas 100 72 1078 872 dynamic 0; +#X obj 5 3 cnv 15 550 15 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 10 85 cnv 15 150 750 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 4 62 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 +0; +#X obj 574 86 cnv 15 130 350 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 567 62 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 +0; +#X text 7 62 Masses :; +#X text 570 62 Links :; +#X text 7 2 DYNAMIC SETTINGS Messages; +#X msg 31 116 posX \$1 \$2; +#X text 191 168 Add force on mass(es); +#X msg 30 183 forceX \$1 \$2; +#X text 190 114 \$1 : Id (symbol) or No; +#X text 193 185 \$1 : Id (symbol) or No; +#X msg 31 265 Xmin \$1; +#X msg 90 265 Xmax \$1; +#X msg 29 311 setMobile \$1; +#X msg 29 332 setFixed \$1; +#X text 190 96 Set position of fixed mass(es); +#X text 177 248 Set minimimum and maximum position of all masses; +#X text 188 311 Set mass to mobile or fixed; +#X msg 593 150 setD \$1 \$2; +#X text 748 136 \$2 : New value; +#X msg 593 99 setK \$1 \$2; +#X text 748 192 \$2 : New value; +#X text 748 245 \$2 : New value; +#X text 742 100 Set rigidity of link(s); +#X text 742 156 Set damping of link(s); +#X msg 593 205 setL \$1 \$2; +#X text 742 209 Set initial lenght of link(s); +#X text 748 118 \$1 : Id (symbol) or No; +#X text 748 174 \$1 : Id (symbol) or No; +#X text 748 227 \$1 : Id (symbol) or No; +#X text 191 328 \$1 : Id (symbol) or No; +#X text 10 25 Dynamic settings messages allows the user to redefine +internal parameters of links and masses.; +#X msg 29 358 grabMass \$1 \$2 \$3; +#X text 186 358 Grab nearest mass; +#X text 191 374 \$1 \, \$2 : position; +#X text 190 391 \$3 : grab or not (0/1); +#X msg 31 137 posY \$1 \$2; +#X msg 30 204 forceY \$1 \$2; +#X msg 31 287 Ymin \$1; +#X msg 90 287 Ymax \$1; +#X text 191 445 \$2 : New Id; +#X msg 30 413 setMassId \$1 \$2; +#X text 191 411 Change the Id of a mass; +#X text 192 428 \$1 : mass (number or Id); +#X msg 23 530 setSpeed \$1 \$2; +#X text 186 482 \$1 : Id (symbol) or No; +#X text 183 465 set force on mass(es); +#X text 185 549 \$1 : Id (symbol) or No; +#X text 182 532 set speed of a mass(es); +#X text 184 610 \$1 : Id (symbol) or No; +#X text 181 593 add pos of a mass(es); +#X msg 23 684 grabMass \$1 \$2 \$3; +#X text 183 654 grab a mass \, and move it; +#X text 185 676 \$1 : mass number; +#X text 185 692 \$2 : position; +#X text 185 708 \$3 : grab or not (0 or 1); +#X msg 24 462 setForce \$1 \$2 \$3; +#X text 186 500 \$2 / \$3 : Value; +#X msg 24 482 setForceX \$1 \$2; +#X msg 24 501 setForceY \$1 \$2; +#X msg 31 96 pos \$1 \$2 \$3; +#X text 190 132 \$2 / \$3 : Value; +#X msg 30 163 force \$1 \$2 \$3; +#X text 191 203 \$2 / \$3 : Value; +#X text 180 264 \$1 / \$2 : Value; +#X msg 23 549 setSpeedX \$1 \$2; +#X msg 23 568 setSpeedY \$1 \$2; +#X text 185 566 \$2 / \$3 : Value; +#X text 185 628 \$2 / \$3 : Value; +#X msg 24 593 addPos \$1 \$2 \$3; +#X msg 588 280 setLinkId \$1 \$2; +#X text 742 281 Change the Id of a link; +#X text 743 298 \$1 : link (number or Id); +#X text 746 315 \$2 : New Id; +#X msg 591 353 setLKTab \$1 \$2; +#X text 750 353 change the table (K) size of a non linear link; +#X text 751 373 \$1 : link (number or Id); +#X text 752 390 \$2 : New KL; +#X text 751 435 \$1 : link (number or Id); +#X msg 591 415 setLDTab \$1 \$2; +#X text 750 415 change the table (D) size of a non linear link; +#X text 752 452 \$2 : New DL; +#X msg 31 225 min \$1 \$2; +#X msg 31 245 max \$1 \$2; +#X msg 24 612 addPosX \$1 \$2; +#X msg 24 632 addPosY \$1 \$2; +#X text 571 580 if only 1 argument is previded \, message generally +used this argument as the value applayed to all masses (or link); +#X text 186 819 \$2 : damping; +#X text 185 804 \$1 : Id (symbol) or No; +#X msg 22 788 setDEnvOffset \$1 \$2; +#X text 174 788 Change environement damping offset; +#X text 173 733 Change environement damping; +#X msg 23 733 setDEnv \$1 \$2; +#X text 185 764 \$2 : damping; +#X text 184 749 \$1 : Id (symbol) or No; +#X restore 12 478 pd dynamic settings ___; +#X connect 21 0 40 0; #X connect 24 0 23 0; -#X connect 25 0 54 0; +#X connect 25 0 51 0; #X connect 26 0 19 0; -#X connect 43 0 20 0; -#X connect 44 0 22 0; -#X connect 45 0 44 0; -#X connect 47 0 46 0; -#X connect 49 0 46 0; -#X connect 54 0 48 0; -#X connect 54 1 48 1; +#X connect 40 0 20 0; +#X connect 41 0 22 0; +#X connect 42 0 41 0; +#X connect 44 0 43 0; +#X connect 46 0 43 0; +#X connect 51 0 45 0; +#X connect 51 1 45 1; @@ -31,8 +31,8 @@ #include "stdio.h"
#include "math.h"
-#define nb_max_link 100000
-#define nb_max_mass 100000
+#define nb_max_link 10000000
+#define nb_max_mass 1000000
#define max(a,b) ( ((a) > (b)) ? (a) : (b) )
#define min(a,b) ( ((a) < (b)) ? (a) : (b) )
@@ -89,7 +89,7 @@ typedef struct _link { t_float D_L; // longeur du tabeau D
} foo1 ;
-typedef struct _pmpd2d2d {
+typedef struct _pmpd2d {
t_object x_obj;
struct _link link[nb_max_link];
struct _mass mass[nb_max_mass];
@@ -143,7 +143,9 @@ void pmpd2d_infosL(t_pmpd2d *x) post("number, Id, mobile, mass, damping, positionX Y, speedX Y, forcesX Y");
for(i=0; i < x->nb_mass; i++)
{
- post("masse %i: %s, %d, %f, %f, %f, %f, %f, %f, %f, %f",i, x->mass[i].Id->s_name, x->mass[i].mobile, 1/x->mass[i].invM, x->mass[i].D2, x->mass[i].posX, x->mass[i].posY, x->mass[i].speedX, x->mass[i].speedY, x->mass[i].forceX, x->mass[i].forceY );
+ post("masse %i: %s, %d, %f, %f, %f, %f, %f, %f, %f, %f",i, x->mass[i].Id->s_name, \
+ x->mass[i].mobile, 1/x->mass[i].invM, x->mass[i].D2, x->mass[i].posX, x->mass[i].posY, \
+ x->mass[i].speedX, x->mass[i].speedY, x->mass[i].forceX, x->mass[i].forceY );
}
post("list of link");
@@ -153,13 +155,19 @@ void pmpd2d_infosL(t_pmpd2d *x) switch(x->link[i].lType)
{
case 0 :
- post("link %i: %s, %i, %i, %f, %f, %f, %f, %f, %f", i, x->link[i].Id->s_name, x->link[i].mass1->num, x->link[i].mass2->num, x->link[i].K, x->link[i].D, x->link[i].Pow, x->link[i].L, x->link[i].Lmin, x->link[i].Lmax);
+ post("link %i: %s, %i, %i, %f, %f, %f, %f, %f, %f", i, x->link[i].Id->s_name, \
+ x->link[i].mass1->num, x->link[i].mass2->num, x->link[i].K, x->link[i].D, \
+ x->link[i].Pow, x->link[i].L, x->link[i].Lmin, x->link[i].Lmax);
break;
case 1 :
- post("tLink %i: %s, %i, %i, %f, %f, %f, %f, %f, %f, %f, %f", i, x->link[i].Id->s_name, x->link[i].mass1->num, x->link[i].mass2->num, x->link[i].K, x->link[i].D, x->link[i].Pow, x->link[i].L, x->link[i].Lmin, x->link[i].Lmax, x->link[i].VX, x->link[i].VY);
+ post("tLink %i: %s, %i, %i, %f, %f, %f, %f, %f, %f, %f, %f", i, x->link[i].Id->s_name, \
+ x->link[i].mass1->num, x->link[i].mass2->num, x->link[i].K, x->link[i].D, \
+ x->link[i].Pow, x->link[i].L, x->link[i].Lmin, x->link[i].Lmax, x->link[i].VX, x->link[i].VY);
break;
case 2 :
- post("tabLink %i: %s, %i, %i, %f, %f, %s, %f, %s, %f", i, x->link[i].Id->s_name, x->link[i].mass1->num, x->link[i].mass2->num, x->link[i].K, x->link[i].D, x->link[i].arrayK->s_name, x->link[i].K_L, x->link[i].arrayD->s_name, x->link[i].D_L);
+ post("tabLink %i: %s, %i, %i, %f, %f, %s, %f, %s, %f", i, x->link[i].Id->s_name, \
+ x->link[i].mass1->num, x->link[i].mass2->num, x->link[i].K, x->link[i].D, \
+ x->link[i].arrayK->s_name, x->link[i].K_L, x->link[i].arrayD->s_name, x->link[i].D_L);
break;
}
}
@@ -329,13 +337,14 @@ void pmpd2d_link(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) else
if ( ( argv[1].a_type == A_SYMBOL ) && ( argv[2].a_type == A_SYMBOL ) )
{
- for (i=0; i< x->nb_mass; i++)
+ for (i=0; i < x->nb_mass; i++)
{
- for (j=0; j< x->nb_mass; j++)
+ for (j=0; j < x->nb_mass; j++)
{
- if ( (atom_getsymbolarg(1,argc,argv) == x->mass[i].Id)&(atom_getsymbolarg(2,argc,argv) == x->mass[j].Id))
+ if ( (atom_getsymbolarg(1,argc,argv) == x->mass[i].Id)&&(atom_getsymbolarg(2,argc,argv) == x->mass[j].Id))
{
- if (!( (x->mass[i].Id == x->mass[j].Id) && (i>j) )) // si lien entre 2 serie de masses identique entres elle, alors on ne creer qu'un lien sur 2, pour evider les redondances
+ if (!( (x->mass[i].Id == x->mass[j].Id) && (i>j) ))
+ // si lien entre 2 serie de masses identique entres elle, alors on ne creer qu'un lien sur 2, pour evider les redondances
pmpd2d_create_link(x, Id, i, j, K, D, Pow, Lmin, Lmax, 0);
}
}
@@ -406,7 +415,8 @@ void pmpd2d_tLink(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) {
if ( (atom_getsymbolarg(1,argc,argv) == x->mass[i].Id)&(atom_getsymbolarg(2,argc,argv) == x->mass[j].Id))
{
- if (!( (x->mass[i].Id == x->mass[j].Id) && (i>j) )) // si lien entre 2 serie de masses identique entres elle, alors on ne creer qu'un lien sur 2, pour evider les redondances
+ if (!( (x->mass[i].Id == x->mass[j].Id) && (i>j) ))
+ // si lien entre 2 serie de masses identique entres elle, alors on ne creer qu'un lien sur 2, pour evider les redondances
{
pmpd2d_create_link(x, Id, i, j, K, D, Pow, Lmin, Lmax, 1);
x->link[x->nb_link-1].VX = vecteurX;
@@ -480,7 +490,8 @@ void pmpd2d_tabLink(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) {
if ( (atom_getsymbolarg(1,argc,argv) == x->mass[i].Id)&(atom_getsymbolarg(2,argc,argv) == x->mass[j].Id))
{
- if (!( (x->mass[i].Id == x->mass[j].Id) && (i>j) )) // si lien entre 2 serie de masses identique entres elle, alors on ne creer qu'un lien sur 2, pour evider les redondances
+ if (!( (x->mass[i].Id == x->mass[j].Id) && (i>j) ))
+ // si lien entre 2 serie de masses identique entres elle, alors on ne creer qu'un lien sur 2, pour evider les redondances
{
pmpd2d_create_link(x, Id, i, j, 1, 1, 1, 0, 1000000, 2);
x->link[x->nb_link-1].arrayK = arrayK;
@@ -2593,6 +2604,1042 @@ void pmpd2d_massesSpeedsStd(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) outlet_anything(x->main_outlet, gensym("massesSpeedsStd"),3 , std_out);
}
+// --------------------------------------------
+
+void pmpd2d_linksPosXL(t_pmpd2d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),(x->link[i].mass1->posX + x->link[i].mass2->posX)/2);
+ }
+ outlet_anything(x->main_outlet, gensym("linksPosXL"),x->nb_link , pos_list);
+}
+
+void pmpd2d_linksLengthXL(t_pmpd2d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),x->link[i].mass2->posX - x->link[i].mass1->posX);
+ }
+ outlet_anything(x->main_outlet, gensym("linksLengthXL"),x->nb_link , pos_list);
+}
+
+void pmpd2d_linksPosSpeedXL(t_pmpd2d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),(x->link[i].mass1->speedX + x->link[i].mass2->speedX)/2);
+ }
+ outlet_anything(x->main_outlet, gensym("linksPosSpeedXL"),x->nb_link , pos_list);
+}
+
+void pmpd2d_linksLengthSpeedXL(t_pmpd2d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),x->link[i].mass2->speedX - x->link[i].mass1->speedX);
+ }
+ outlet_anything(x->main_outlet, gensym("linksLengthSpeedXL"),x->nb_link , pos_list);
+}
+
+void pmpd2d_linksPosXT(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = (x->link[i].mass1->posX + x->link[i].mass2->posX)/2;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = (x->link[j].mass1->posX + x->link[j].mass2->posX)/2;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd2d_linksLengthXT(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = x->link[i].mass2->posX - x->link[i].mass1->posX;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = x->link[j].mass2->posX - x->link[j].mass1->posX;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd2d_linksPosSpeedXT(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = (x->link[i].mass1->speedX + x->link[i].mass2->speedX)/2;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = (x->link[j].mass1->speedX + x->link[j].mass2->speedX)/2;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd2d_linksLengthSpeedXT(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = x->link[i].mass2->speedX - x->link[i].mass1->speedX;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = x->link[j].mass2->speedX - x->link[j].mass1->speedX;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd2d_linksPosYL(t_pmpd2d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),(x->link[i].mass1->posY + x->link[i].mass2->posY)/2);
+ }
+ outlet_anything(x->main_outlet, gensym("linksPosYL"),x->nb_link , pos_list);
+}
+
+void pmpd2d_linksLengthYL(t_pmpd2d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),x->link[i].mass2->posY - x->link[i].mass1->posY);
+ }
+ outlet_anything(x->main_outlet, gensym("linksLengthYL"),x->nb_link , pos_list);
+}
+
+void pmpd2d_linksPosSpeedYL(t_pmpd2d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),(x->link[i].mass1->speedY + x->link[i].mass2->speedY)/2);
+ }
+ outlet_anything(x->main_outlet, gensym("linksPosSpeedYL"),x->nb_link , pos_list);
+}
+
+void pmpd2d_linksLengthSpeedYL(t_pmpd2d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),x->link[i].mass2->speedY - x->link[i].mass1->speedY);
+ }
+ outlet_anything(x->main_outlet, gensym("linksLengthSpeedYL"),x->nb_link , pos_list);
+}
+
+void pmpd2d_linksPosYT(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = (x->link[i].mass1->posY + x->link[i].mass2->posY)/2;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = (x->link[j].mass1->posY + x->link[j].mass2->posY)/2;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd2d_linksLengthYT(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = x->link[i].mass2->posY - x->link[i].mass1->posY;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = x->link[j].mass2->posY - x->link[j].mass1->posY;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd2d_linksPosSpeedYT(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = (x->link[i].mass1->speedY + x->link[i].mass2->speedY)/2;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = (x->link[j].mass1->speedY + x->link[j].mass2->speedY)/2;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd2d_linksLengthSpeedYT(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = x->link[i].mass2->speedY - x->link[i].mass1->speedY;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = x->link[j].mass2->speedY - x->link[j].mass1->speedY;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd2d_linksPosL(t_pmpd2d *x)
+{
+ int i;
+ t_atom pos_list[2*x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[2*i] ),(x->link[i].mass2->posX + x->link[i].mass1->posX)/2);
+ SETFLOAT(&(pos_list[2*i+1]),(x->link[i].mass2->posY + x->link[i].mass1->posY)/2);
+ }
+ outlet_anything(x->main_outlet, gensym("linksPosL"),2*x->nb_link , pos_list);
+}
+
+void pmpd2d_linksLengthL(t_pmpd2d *x)
+{
+ int i;
+ t_atom pos_list[2*x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[2*i] ),x->link[i].mass2->posX - x->link[i].mass1->posX);
+ SETFLOAT(&(pos_list[2*i+1]),x->link[i].mass2->posY - x->link[i].mass1->posY);
+ }
+ outlet_anything(x->main_outlet, gensym("linksLengthL"),2*x->nb_link , pos_list);
+}
+
+void pmpd2d_linksPosSpeedL(t_pmpd2d *x)
+{
+ int i;
+ t_atom pos_list[2*x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[2*i] ),(x->link[i].mass2->speedX + x->link[i].mass1->speedX)/2);
+ SETFLOAT(&(pos_list[2*i+1]),(x->link[i].mass2->speedY + x->link[i].mass1->speedY)/2);
+ }
+ outlet_anything(x->main_outlet, gensym("linksPosSpeedL"),3*x->nb_link , pos_list);
+}
+
+void pmpd2d_linksLengthSpeedL(t_pmpd2d *x)
+{
+ int i;
+ t_atom pos_list[2*x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[2*i] ),x->link[i].mass2->speedX - x->link[i].mass1->speedX);
+ SETFLOAT(&(pos_list[2*i+1]),x->link[i].mass2->speedY - x->link[i].mass1->speedY);
+ }
+ outlet_anything(x->main_outlet, gensym("linksLengthSpeedL"),2*x->nb_link , pos_list);
+}
+
+void pmpd2d_linksPosT(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, (vecsize-2)/2);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[2*i ].w_float = (x->link[i].mass2->posX + x->link[i].mass1->posX)/2;
+ vec[2*i+1].w_float = (x->link[i].mass2->posY + x->link[i].mass1->posY)/2;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize-2) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->mass[j].Id)
+ {
+ vec[i].w_float = (x->link[j].mass2->posX + x->link[j].mass1->posX)/2;
+ i++;
+ vec[i].w_float = (x->link[j].mass2->posY + x->link[j].mass1->posY)/2;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd2d_linksLengthT(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, (vecsize-2)/2);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[2*i ].w_float = x->link[i].mass2->posX - x->link[i].mass1->posX;
+ vec[2*i+1].w_float = x->link[i].mass2->posY - x->link[i].mass1->posY;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize-2) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->mass[j].Id)
+ {
+ vec[i].w_float = x->link[j].mass2->posX + x->link[j].mass1->posX;
+ i++;
+ vec[i].w_float = x->link[j].mass2->posY + x->link[j].mass1->posY;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd2d_linksPosSpeedT(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, (vecsize-2)/2);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[2*i ].w_float = (x->link[i].mass2->speedX + x->link[i].mass1->speedX)/2;
+ vec[2*i+1].w_float = (x->link[i].mass2->speedY + x->link[i].mass1->speedY)/2;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize-2) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->mass[j].Id)
+ {
+ vec[i].w_float = (x->link[j].mass2->speedX + x->link[j].mass1->speedX)/2;
+ i++;
+ vec[i].w_float = (x->link[j].mass2->speedY + x->link[j].mass1->speedY)/2;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd2d_linksLengthSpeedT(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, (vecsize-2)/2);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[2*i ].w_float = x->link[i].mass2->speedX - x->link[i].mass1->speedX;
+ vec[2*i+1].w_float = x->link[i].mass2->speedY - x->link[i].mass1->speedY;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize-2) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->mass[j].Id)
+ {
+ vec[i].w_float = x->link[j].mass2->speedX + x->link[j].mass1->speedX;
+ i++;
+ vec[i].w_float = x->link[j].mass2->speedY + x->link[j].mass1->speedY;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd2d_linksPosNormL(t_pmpd2d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),sqrt( \
+ sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + \
+ sqr((x->link[i].mass1->posY + x->link[i].mass2->posY)/2) ));
+ }
+ outlet_anything(x->main_outlet, gensym("linksPosNormL"),x->nb_link , pos_list);
+}
+
+void pmpd2d_linksLengthNormL(t_pmpd2d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),sqrt( \
+ sqr(x->link[i].mass2->posX - x->link[i].mass1->posX) + \
+ sqr(x->link[i].mass2->posY - x->link[i].mass1->posY) ));
+ }
+ outlet_anything(x->main_outlet, gensym("linksLengthNormL"),x->nb_link , pos_list);
+}
+
+void pmpd2d_linksPosSpeedNormL(t_pmpd2d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),sqrt( \
+ sqr((x->link[i].mass1->speedX + x->link[i].mass2->speedX)/2) + \
+ sqr((x->link[i].mass1->speedY + x->link[i].mass2->speedY)/2) ));
+ }
+ outlet_anything(x->main_outlet, gensym("linksPosSpeedNormL"),x->nb_link , pos_list);
+}
+
+void pmpd2d_linksLengthSpeedNormL(t_pmpd2d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),sqrt( \
+ sqr(x->link[i].mass2->speedX - x->link[i].mass1->speedX) + \
+ sqr(x->link[i].mass2->speedY - x->link[i].mass1->speedY) ));
+ }
+ outlet_anything(x->main_outlet, gensym("linksLengthSpeedNormL"),x->nb_link , pos_list);
+}
+
+void pmpd2d_linksPosNormT(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = sqrt( \
+ sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + \
+ sqr((x->link[i].mass1->posY + x->link[i].mass2->posY)/2) );
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[j].w_float = sqrt( \
+ sqr((x->link[j].mass1->posX + x->link[j].mass2->posX)/2) + \
+ sqr((x->link[j].mass1->posY + x->link[j].mass2->posY)/2) );
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd2d_linksLengthNormT(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = sqrt( \
+ sqr(x->link[i].mass2->posX - x->link[i].mass1->posX) + \
+ sqr(x->link[i].mass2->posY - x->link[i].mass1->posY) );
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = sqrt( \
+ sqr(x->link[j].mass2->posX - x->link[j].mass1->posX) + \
+ sqr(x->link[j].mass2->posY - x->link[j].mass1->posY) );
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd2d_linksPosSpeedNormT(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = sqrt( \
+ sqr((x->link[i].mass1->speedX + x->link[i].mass2->speedX)/2) + \
+ sqr((x->link[i].mass1->speedY + x->link[i].mass2->speedY)/2) );
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = sqrt( \
+ sqr((x->link[j].mass1->speedX + x->link[j].mass2->speedX)/2) + \
+ sqr((x->link[j].mass1->speedY + x->link[j].mass2->speedY)/2) );
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd2d_linksLengthSpeedNormT(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = sqrt( \
+ sqr(x->link[i].mass2->speedX - x->link[i].mass1->speedX) + \
+ sqr(x->link[i].mass2->speedY - x->link[i].mass1->speedY) );
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = sqrt( \
+ sqr(x->link[j].mass2->speedX - x->link[j].mass1->speedX) + \
+ sqr(x->link[j].mass2->speedY - x->link[j].mass1->speedY) );
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+//----------------------------------------------
+
void pmpd2d_grabMass(t_pmpd2d *x, t_float posX, t_float posY, t_float grab)
{
t_float dist, tmp;
@@ -2712,15 +3759,59 @@ void pmpd2d_setup(void) class_addmethod(pmpd2d_class, (t_method)pmpd2d_massesSpeedsNormT, gensym("massesSpeedsNormT"), A_GIMME, 0);
class_addmethod(pmpd2d_class, (t_method)pmpd2d_massesForcesNormT, gensym("massesForcesNormT"), A_GIMME, 0);
- class_addmethod(pmpd2d_class, (t_method)pmpd2d_massesPosMean, gensym("massesPosMean"), A_GIMME, 0);
- class_addmethod(pmpd2d_class, (t_method)pmpd2d_massesPosStd, gensym("massesPosStd"),A_GIMME, 0);
- class_addmethod(pmpd2d_class, (t_method)pmpd2d_massesForcesMean,gensym("massesForcesMean"), A_GIMME, 0);
- class_addmethod(pmpd2d_class, (t_method)pmpd2d_massesForcesStd, gensym("massesForcesStd"),A_GIMME, 0);
- class_addmethod(pmpd2d_class, (t_method)pmpd2d_massesSpeedsMean,gensym("massesSpeedsMean"), A_GIMME, 0);
- class_addmethod(pmpd2d_class, (t_method)pmpd2d_massesSpeedsStd, gensym("massesSpeedsStd"),A_GIMME, 0);
- // class_addmethod(pmpd2d_class, (t_method)pmpd2d_linkLMean, gensym("linkLMean"),A_GIMME, 0);
- // class_addmethod(pmpd2d_class, (t_method)pmpd2d_linkLStd, gensym("linkLStd"),A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_massesPosMean, gensym("massesPosMean"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_massesPosStd, gensym("massesPosStd"),A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_massesForcesMean, gensym("massesForcesMean"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_massesForcesStd, gensym("massesForcesStd"),A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_massesSpeedsMean, gensym("massesSpeedsMean"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_massesSpeedsStd, gensym("massesSpeedsStd"),A_GIMME, 0);
+
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksPosXL, gensym("linksPosXL"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksLengthXL, gensym("linksLengthXL"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksPosSpeedXL, gensym("linksPosSpeedXL"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksLengthSpeedXL, gensym("linksLengthXL"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksPosXT, gensym("linksPosXT"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksLengthXT, gensym("linksLengthXT"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksPosSpeedXT, gensym("linksPosSpeedXT"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksLengthSpeedXT, gensym("linksLengthSpeedXT"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksPosYL, gensym("linksPosYL"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksLengthYL, gensym("linksLengthYL"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksPosSpeedYL, gensym("linksPosSpeedYL"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksLengthSpeedYL, gensym("linksLengthYL"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksPosYT, gensym("linksPosYT"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksLengthYT, gensym("linksLengthYT"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksPosSpeedYT, gensym("linksPosSpeedYT"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksLengthSpeedYT, gensym("linksLengthSpeedYT"), A_GIMME, 0);
+
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksPosL, gensym("linksPosL"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksLengthL, gensym("linksLengthL"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksPosSpeedL, gensym("linksPosSpeedL"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksLengthSpeedL, gensym("linksLengthL"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksPosT, gensym("linksPosT"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksLengthT, gensym("linksLengthT"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksPosSpeedT, gensym("linksPosSpeedT"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksLengthSpeedT, gensym("linksLengthSpeedT"), A_GIMME, 0);
+
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksPosNormL, gensym("linksPosNormL"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksLengthNormL, gensym("linksLengthNormL"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksPosSpeedNormL, gensym("linksPosSpeedNormL"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksLengthSpeedNormL, gensym("linksLengthNormL"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksPosNormT, gensym("linksPosNormT"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksLengthNormT, gensym("linksLengthNormT"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksPosSpeedNormT, gensym("linksPosSpeedNormT"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksLengthSpeedNormT, gensym("linksLengthSpeedNormT"), A_GIMME, 0);
+
+/* class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksPosMean, gensym("linksPosMean"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksLengthMean, gensym("linksLengthMean"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksPosSpeedMean, gensym("linksPosSpeedMean"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksLengthSpeedMean, gensym("linksLengthSpeedMean"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksPosStd, gensym("linksPosStd"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksLengthStd, gensym("linksLengthStd"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksPosSpeedStd, gensym("linksPosSpeedStd"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linksLengthSpeedStd0, gensym("linksLengthSpeedStd"), A_GIMME, 0);
+*/
+
class_addmethod(pmpd2d_class, (t_method)pmpd2d_grabMass, gensym("grabMass"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
}
diff --git a/pmpd3d-help.pd b/pmpd3d-help.pd index e81aae1..4ce2282 100644 --- a/pmpd3d-help.pd +++ b/pmpd3d-help.pd @@ -1,23 +1,23 @@ -#N canvas 1045 104 613 729 10; +#N canvas 52 60 624 761 10; #X obj 4 369 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 0; -#X obj 5 665 cnv 15 550 30 empty empty empty 20 12 0 14 -158509 -66577 +#X obj 5 695 cnv 15 550 30 empty empty empty 20 12 0 14 -158509 -66577 0; #X obj 8 6 cnv 15 550 30 empty empty empty 20 12 0 14 -233017 -66577 0; #X obj 14 389 cnv 15 75 15 empty empty empty 20 12 0 14 -233017 -66577 0; -#X obj 14 584 cnv 15 75 15 empty empty empty 20 12 0 14 -233017 -66577 +#X obj 14 614 cnv 15 75 15 empty empty empty 20 12 0 14 -233017 -66577 0; -#X obj 4 527 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 +#X obj 4 557 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 0; -#X obj 4 562 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 +#X obj 4 592 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 0; #X obj 7 76 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577 0; -#X obj 5 615 cnv 15 550 20 empty empty empty 20 12 0 14 -158509 -66577 +#X obj 5 645 cnv 15 550 20 empty empty empty 20 12 0 14 -158509 -66577 0; -#X obj 5 635 cnv 15 550 30 empty empty empty 20 12 0 14 -233017 -66577 +#X obj 5 665 cnv 15 550 30 empty empty empty 20 12 0 14 -233017 -66577 0; #N canvas 76 31 921 714 More_Info 0; #X text 96 12 pmpd : mass - spring - damper model; @@ -226,13 +226,13 @@ their Id.; #X text 28 41 pmpd is the 2D object of the pmpd objects collection. ; #X connect 3 0 4 0; -#X restore 16 673 pd More_Info; +#X restore 16 703 pd More_Info; #X text 12 76 Examples:; #X text 9 369 Inlets:; #X text 19 388 - Left:; -#X text 10 526 Arguments:; -#X text 11 562 Outlets:; -#X text 19 617 See Also:; +#X text 10 556 Arguments:; +#X text 11 592 Outlets:; +#X text 19 647 See Also:; #X text 74 48 Full Name:; #N canvas 58 22 262 70 Related_Objects 0; #X obj 3 10 cnv 15 250 15 empty empty empty 20 12 0 14 -158509 -66577 @@ -242,13 +242,122 @@ their Id.; #X text 5 10 Externals and libraries; #X obj 44 37 pmpd; #X obj 141 39 pmpd3d; -#X restore 122 673 pd Related_Objects; +#X restore 122 703 pd Related_Objects; #X text 101 388 Bang - A bang at the left inlet compute the new model state based on previous instant.; -#X text 158 478 To set the model parameters after creation.; -#X text 158 456 To create the model masses and links.; -#X text 158 501 To get the model parameters; -#N canvas 556 79 967 626 creation________ 0; +#X text 188 456 To create the model masses and links.; +#X text 188 510 To get the model parameters; +#X text 103 572 None; +#X text 18 613 - Left:; +#X text 101 614 Outputs the model parameters asked with the attributes +messages.; +#X text 101 420 Messages - Different messages are used to control the +pmpd object. They are of three types :; +#X text 9 669 CATEGORY: control; +#X text 9 679 KEYWORDS: physical model mass spring damper link; +#X text 135 98 Sorry \, you need GEM for this example...; +#X text 265 699 - Cyrille Henry 2011; +#X text 265 711 based on MSD by Nicolas Montgermont \, 2005; +#X text 12 8 HELP: pmpd3d; +#X text 11 19 DESCRIPTION: Physical modeling for Pd in 3d; +#X obj 157 48 pmpd3d; +#N canvas 257 262 759 345 init 0; +#X obj 89 215 t a; +#X obj 89 33 loadbang; +#X obj 89 241 s \$0-in; +#X obj 89 59 t b b b b b; +#X msg 161 80 reset; +#X obj 44 13 inlet; +#X msg 107 161 link souple fix mob 10 10 \, link souple mob mob 10 +10; +#X msg 125 120 mass mob 1 100 0 -2 0 \, mass mob 1 100 2 0 0 \, mass +mob 1 100 0 2 0 \, mass mob 1 100 -2 0 0; +#X msg 89 187 Xmax 4 \, Xmin -4 \, Ymax 4 \, Ymin -4 \, Zmax 4 \, Zmin +-4; +#X msg 143 100 mass fix 0 10 0 0 0; +#X connect 0 0 2 0; +#X connect 1 0 3 0; +#X connect 3 0 8 0; +#X connect 3 1 6 0; +#X connect 3 2 7 0; +#X connect 3 3 9 0; +#X connect 3 4 4 0; +#X connect 4 0 0 0; +#X connect 5 0 3 0; +#X connect 6 0 0 0; +#X connect 7 0 0 0; +#X connect 8 0 0 0; +#X connect 9 0 0 0; +#X restore 17 156 pd init; +#X obj 18 321 s \$0-out; +#X obj 18 272 r \$0-in; +#X obj 393 317 s \$0-in; +#N canvas 565 515 355 193 compute 0; +#X obj 27 29 inlet; +#X obj 27 127 s \$0-in; +#X msg 27 96 bang \, get massesPos \, get linksPos; +#X obj 27 66 gemhead; +#X obj 160 36 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X connect 0 0 3 0; +#X connect 2 0 1 0; +#X connect 3 0 2 0; +#X connect 4 0 2 0; +#X restore 17 209 pd compute; +#X obj 17 181 tgl 15 0 empty empty ON/OFF 25 10 1 10 -262144 -1 -1 +0 1; +#X obj 172 270 r \$0-out; +#X obj 17 126 bng 15 250 50 0 empty empty reset 25 10 1 10 -262144 +-1 -1; +#X obj 336 216 gemwin; +#X msg 336 194 0 \, destroy; +#N canvas 363 318 550 319 gemrender 0; +#X obj 48 203 translateXYZ; +#X obj 48 229 sphere 0.1; +#X obj 127 24 inlet; +#X obj 390 13 inlet; +#X obj 303 213 curve 2; +#X obj 125 136 t b f; +#X obj 127 62 unpack f f f f; +#X msg 390 58 \$2 \$3 \$4; +#X msg 462 62 \$5 \$6 \$7; +#X obj 48 167 gemhead; +#X msg 48 143 0; +#X obj 48 115 loadbang; +#X obj 303 147 gemhead; +#X msg 303 123 0; +#X obj 303 95 loadbang; +#X obj 390 86 t b l; +#X connect 0 0 1 0; +#X connect 2 0 6 0; +#X connect 3 0 8 0; +#X connect 3 0 7 0; +#X connect 5 0 9 0; +#X connect 5 1 0 1; +#X connect 6 1 5 0; +#X connect 6 2 0 2; +#X connect 6 3 0 3; +#X connect 7 0 15 0; +#X connect 8 0 4 2; +#X connect 9 0 0 0; +#X connect 10 0 9 0; +#X connect 11 0 10 0; +#X connect 12 0 4 0; +#X connect 13 0 12 0; +#X connect 14 0 13 0; +#X connect 15 0 12 0; +#X connect 15 1 4 1; +#X restore 172 321 pd gemrender; +#X msg 336 129 reset \, create \, 1; +#X obj 18 296 pmpd3d; +#X msg 393 271 forceZ mob -10; +#X msg 393 293 forceZ mob 10; +#X text 392 246 2 Send forces; +#X text 170 132 1 Create window -->; +#X text 170 195 3 And destroy it -->; +#X obj 172 294 route massesPos linksPosNo; +#X text 112 648 01_pmpd3dtest.pd; +#N canvas 556 79 967 626 creation____________ 0; #X obj 5 75 cnv 15 450 15 empty empty empty 20 12 0 14 -158509 -66577 0; #X obj 5 3 cnv 15 450 15 empty empty empty 20 12 0 14 -233017 -66577 @@ -320,15 +429,8 @@ following a vector.; #X msg 32 167 mass \$1 \$2 \$3 \$4 \$5 \$6; #X text 58 247 \$4 \, \$5 \, \$6 : initial position; #X connect 27 0 29 0; -#X restore 12 457 pd creation________; -#X text 103 542 None; -#X text 18 583 - Left:; -#X text 101 584 Outputs the model parameters asked with the attributes -messages.; -#X text 101 420 Messages - Different messages are used to control the -pmpd object. They are of three types :; -#X text 9 639 CATEGORY: control; -#N canvas 675 81 1078 872 dynamic 0; +#X restore 12 457 pd creation____________; +#N canvas 541 24 1078 872 dynamic 0; #X obj 5 3 cnv 15 550 15 empty empty empty 20 12 0 14 -233017 -66577 0; #X obj 10 85 cnv 15 150 750 empty empty empty 20 12 0 14 -233017 -66577 @@ -369,46 +471,44 @@ pmpd object. They are of three types :; #X text 191 364 \$1 : Id (symbol) or No; #X text 10 25 Dynamic settings messages allows the user to redefine internal parameters of links and masses.; -#X msg 29 404 grabMass \$1 \$2 \$3; -#X text 186 404 Grab nearest mass; -#X text 191 420 \$1 \, \$2 : position; -#X text 190 437 \$3 : grab or not (0/1); +#X msg 29 391 grabMass \$1 \$2 \$3; +#X text 186 391 Grab nearest mass; +#X text 191 407 \$1 \, \$2 : position; +#X text 190 424 \$3 : grab or not (0/1); #X msg 31 134 posY \$1 \$2; #X msg 30 210 forceY \$1 \$2; #X msg 31 307 Ymin \$1; #X msg 90 307 Ymax \$1; -#X text 191 501 \$2 : New Id; -#X msg 29 469 setMassId \$1 \$2; -#X text 191 467 Change the Id of a mass; -#X text 192 484 \$1 : mass (number or Id); -#X msg 24 594 setSpeed \$1 \$2; -#X text 186 548 \$1 : Id (symbol) or No; -#X text 183 531 set force on mass(es); -#X text 185 615 \$1 : Id (symbol) or No; -#X text 182 598 set speed of a mass(es); -#X text 178 694 \$1 : Id (symbol) or No; -#X text 175 677 add pos of a mass(es); -#X msg 27 764 grabMass \$1 \$2 \$3; -#X text 183 733 grab a mass \, and move it; -#X text 185 755 \$1 : mass number; -#X text 185 771 \$2 : position; -#X text 185 787 \$3 : grab or not (0 or 1); -#X msg 24 514 setForce \$1 \$2 \$3; -#X text 186 566 \$2 / \$3 : Value; -#X msg 24 533 setForceX \$1 \$2; -#X msg 24 552 setForceY \$1 \$2; +#X text 191 476 \$2 : New Id; +#X msg 29 444 setMassId \$1 \$2; +#X text 191 442 Change the Id of a mass; +#X text 192 459 \$1 : mass (number or Id); +#X msg 24 564 setSpeed \$1 \$2; +#X text 186 518 \$1 : Id (symbol) or No; +#X text 183 501 set force on mass(es); +#X text 185 585 \$1 : Id (symbol) or No; +#X text 182 568 set speed of a mass(es); +#X text 178 664 \$1 : Id (symbol) or No; +#X text 175 647 add pos of a mass(es); +#X msg 27 734 grabMass \$1 \$2 \$3; +#X text 183 703 grab a mass \, and move it; +#X text 185 725 \$1 : mass number; +#X text 185 741 \$2 : position; +#X text 185 757 \$3 : grab or not (0 or 1); +#X msg 24 484 setForce \$1 \$2 \$3; +#X text 186 536 \$2 / \$3 : Value; +#X msg 24 503 setForceX \$1 \$2; +#X msg 24 522 setForceY \$1 \$2; #X msg 31 96 pos \$1 \$2 \$3; #X text 190 132 \$2 / \$3 : Value; #X msg 30 172 force \$1 \$2 \$3; #X text 191 213 \$2 / \$3 : Value; -#X msg 29 811 setDEnv \$1; -#X text 178 811 Change environement damping; -#X text 190 828 \$1 : damping; -#X msg 24 613 setSpeedX \$1 \$2; -#X msg 24 632 setSpeedY \$1 \$2; -#X text 185 632 \$2 / \$3 : Value; -#X text 179 712 \$2 / \$3 : Value; -#X msg 24 675 addPos \$1 \$2 \$3; +#X text 178 781 Change environement damping; +#X msg 24 583 setSpeedX \$1 \$2; +#X msg 24 602 setSpeedY \$1 \$2; +#X text 185 602 \$2 / \$3 : Value; +#X text 179 682 \$2 / \$3 : Value; +#X msg 24 645 addPos \$1 \$2 \$3; #X msg 588 280 setLinkId \$1 \$2; #X text 742 281 Change the Id of a link; #X text 743 298 \$1 : link (number or Id); @@ -428,32 +528,42 @@ internal parameters of links and masses.; #X text 180 288 \$1 / \$2 / \$3 : Value; #X msg 31 326 Zmin \$1; #X msg 90 326 Zmax \$1; -#X msg 24 571 setForceZ \$1 \$2; -#X msg 24 651 setSpeedZ \$1 \$2; -#X msg 24 694 addPosX \$1 \$2; -#X msg 24 713 addPosY \$1 \$2; -#X msg 25 732 addPosZ \$1 \$2; -#X restore 12 478 pd dynamic settings; -#N canvas 30 26 1236 814 attributes______ 0; -#X obj 11 95 cnv 15 100 35 empty empty empty 20 12 0 14 -233017 -66577 -0; -#X obj 5 75 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577 +#X msg 24 541 setForceZ \$1 \$2; +#X msg 24 621 setSpeedZ \$1 \$2; +#X msg 24 664 addPosX \$1 \$2; +#X msg 24 683 addPosY \$1 \$2; +#X msg 25 702 addPosZ \$1 \$2; +#X msg 29 781 setDEnv \$1 \$2; +#X text 190 812 \$2 : damping; +#X text 189 797 \$1 : Id (symbol) or No; +#X text 571 580 if only 1 argument is previded \, message generally +used this argument as the value applayed to all masses (or link); +#X text 191 855 \$2 : damping; +#X text 190 840 \$1 : Id (symbol) or No; +#X msg 30 824 setDEnvOffset \$1 \$2; +#X text 179 824 Change environement damping offset; +#X restore 12 478 pd dynamic settings ___; +#X text 188 478 To set the model parameters after creation.; +#N canvas 30 26 1241 841 masses_attributes 0; +#X obj 11 115 cnv 15 100 35 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 5 95 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577 0; #X obj 5 3 cnv 15 590 15 empty empty empty 20 12 0 14 -233017 -66577 0; -#X obj 10 158 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 -66577 +#X obj 10 178 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 -66577 0; -#X obj 4 137 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577 +#X obj 4 157 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577 0; #X obj 616 422 cnv 15 110 330 empty empty empty 20 12 0 14 -233017 -66577 0; #X obj 610 398 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577 0; -#X text 7 74 General :; +#X text 7 94 General :; #X text 7 2 ATTRIBUTES Messages; -#X text 7 137 Lists :; -#X text 136 104 Get infos on all masses and links on right outlet; -#X text 170 170 Output all masses positions in a list on outlet No +#X text 7 157 Lists :; +#X text 136 124 Get infos on all masses and links on right outlet; +#X text 170 190 Output all masses positions in a list on outlet No 1; #X text 746 438 Get specific attribute on specific element; #X msg 626 436 get \$1 (\$2); @@ -465,29 +575,26 @@ is made of the asked parameter and the way you asked for it.; #X text 987 609 response; #X text 746 590 Examples with 3 masses numbered 0 \, 1 and 2 and named mas:; -#X text 15 30 The attributes messages ask the object to output some -of his internal parameters. They can be output by lists for positions -and forces of masses.; -#X text 172 399 Output all forces applied on masses in a list on outlet +#X text 172 419 Output all forces applied on masses in a list on outlet No 1; #X text 746 500 (\$2) : - If not defined all the attributes are send for all the elements. - Ids or/and creations No; -#X text 170 202 Output all masses x or y in a list on outlet No 1; -#X msg 33 104 print; -#X text 170 230 Output all norm of position vector (sqrt(x*x+y*y)) +#X text 170 222 Output all masses x or y in a list on outlet No 1; +#X msg 33 124 print; +#X text 170 250 Output all norm of position vector (sqrt(x*x+y*y)) in a list on outlet No 1; -#X obj 11 272 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 -66577 +#X obj 11 292 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 -66577 0; -#X text 171 284 Output all masses speeds in a list on outlet No 1; -#X text 172 316 Output all masses speeds in x or y in a list on outlet +#X text 171 304 Output all masses speeds in a list on outlet No 1; +#X text 172 336 Output all masses speeds in x or y in a list on outlet No 1; -#X text 179 353 Output all norm of speed vector (sqrt(x*x+y*y)) in +#X text 179 373 Output all norm of speed vector (sqrt(x*x+y*y)) in a list on outlet No 1; -#X obj 11 385 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 -66577 +#X obj 11 405 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 -66577 0; -#X text 175 429 Output all masses forces in x or y in a list on outlet +#X text 175 449 Output all masses forces in x or y in a list on outlet No 1; -#X text 175 463 Output all norm of forces vector (sqrt(x*x+y*y)) in +#X text 175 483 Output all norm of forces vector (sqrt(x*x+y*y)) in a list on outlet No 1; #X text 745 457 \$1 : Attribute type ( massesPos / massesPosName / massesSpeeds / massesSpeedsName / massesForces / massesForcesName / @@ -511,15 +618,15 @@ a list on outlet No 1; No 1; #X text 804 322 Output all norm of forces vector (sqrt(x*x+y*y)) in a list on outlet No 1; -#X msg 12 169 massesPosL (\$1); -#X msg 12 188 massesPosXL (\$1); -#X msg 12 207 massesPosYL (\$1); -#X msg 12 245 massesPosNormL (\$1); -#X msg 13 279 massesSpeedsL (\$1); -#X msg 14 355 massesSpeedsNormL (\$1); -#X msg 15 392 massesForcesL (\$1); -#X msg 12 169 massesPosL (\$1); -#X msg 14 468 massesSpeedsNormL (\$1); +#X msg 12 189 massesPosL (\$1); +#X msg 12 208 massesPosXL (\$1); +#X msg 12 227 massesPosYL (\$1); +#X msg 12 265 massesPosNormL (\$1); +#X msg 13 299 massesSpeedsL (\$1); +#X msg 14 375 massesSpeedsNormL (\$1); +#X msg 15 412 massesForcesL (\$1); +#X msg 12 189 massesPosL (\$1); +#X msg 14 488 massesSpeedsNormL (\$1); #X msg 615 38 massesPosT \$1 (\$2); #X msg 615 57 massesPosXT \$1 (\$2); #X msg 615 76 massesPosYT \$1 (\$2); @@ -531,40 +638,40 @@ a list on outlet No 1; #X text 794 67 Output all masses x or y in a table (\$1); #X text 794 95 Output all norm of position vector (sqrt(x*x+y*y)) in a table (\$1); -#X text 174 498 \$1 (optional): Masses Id; +#X text 174 518 \$1 (optional): Masses Id; #X text 815 376 \$2 (optional): Masses Id; #X text 814 363 \$1 : table name; -#X obj 17 544 cnv 15 150 270 empty empty empty 20 12 0 14 -233017 -66577 -0; -#X obj 11 524 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577 -0; -#X text 14 524 statistics :; -#X msg 22 557 massesPosMean; -#X text 177 573 \$1 : none or Id; -#X msg 23 595 massesPosStd \$1; -#X text 179 610 \$1 : none or Id; -#X text 173 557 output the average position of masses; -#X text 174 594 output the standard deviation of masses position; -#X text 177 660 \$1 : none or Id; -#X text 179 697 \$1 : none or Id; -#X text 173 644 output the average position of masses; -#X text 174 681 output the standard deviation of masses position; -#X text 177 745 \$1 : none or Id; -#X text 178 782 \$1 : none or Id; -#X text 173 729 output the average position of masses; -#X text 173 766 output the standard deviation of masses position; -#X msg 22 682 massesForcesStd \$1; -#X msg 22 644 massesForcesMean; -#X msg 23 731 massesSpeedsMean; -#X msg 22 767 massesSpeedsStd \$1; +#X obj 17 564 cnv 15 150 270 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 11 544 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577 +0; +#X text 14 544 statistics :; +#X msg 22 577 massesPosMean; +#X text 177 593 \$1 : none or Id; +#X msg 23 615 massesPosStd \$1; +#X text 179 630 \$1 : none or Id; +#X text 173 577 output the average position of masses; +#X text 174 614 output the standard deviation of masses position; +#X text 177 680 \$1 : none or Id; +#X text 179 717 \$1 : none or Id; +#X text 173 664 output the average position of masses; +#X text 174 701 output the standard deviation of masses position; +#X text 177 765 \$1 : none or Id; +#X text 178 802 \$1 : none or Id; +#X text 173 749 output the average position of masses; +#X text 173 786 output the standard deviation of masses position; +#X msg 22 702 massesForcesStd \$1; +#X msg 22 664 massesForcesMean; +#X msg 23 751 massesSpeedsMean; +#X msg 22 787 massesSpeedsStd \$1; #X text 608 5 tables :; -#X msg 12 226 massesPosZL (\$1); -#X msg 14 298 massesSpeedsXL (\$1); -#X msg 13 317 massesSpeedsYL (\$1); -#X msg 14 336 massesSpeedsZL (\$1); -#X msg 15 411 massesForcesXL (\$1); -#X msg 15 430 massesForcesYL (\$1); -#X msg 14 449 massesForcesZL (\$1); +#X msg 12 246 massesPosZL (\$1); +#X msg 14 318 massesSpeedsXL (\$1); +#X msg 13 337 massesSpeedsYL (\$1); +#X msg 14 356 massesSpeedsZL (\$1); +#X msg 15 431 massesForcesXL (\$1); +#X msg 15 450 massesForcesYL (\$1); +#X msg 14 469 massesForcesZL (\$1); #X text 780 629 [get massesPos( -----> [massesPos 0 x0 y0 z0(; #X text 940 641 [massesPos 1 x1 y1 z1(; #X text 940 656 [massesPos 2 x2 y2 z2(; @@ -585,118 +692,158 @@ z0(; #X msg 616 278 massesForcesXT \$1 (\$2); #X msg 616 297 massesForcesYT \$1 (\$2); #X msg 616 316 massesForcesZT \$1 (\$2); -#X restore 12 499 pd attributes______; -#X text 9 649 KEYWORDS: physical model mass spring damper link; -#X text 135 98 Sorry \, you need GEM for this example...; -#X text 265 669 - Cyrille Henry 2011; -#X text 265 681 based on MSD by Nicolas Montgermont \, 2005; -#X text 12 8 HELP: pmpd3d; -#X text 11 19 DESCRIPTION: Physical modeling for Pd in 3d; -#X obj 157 48 pmpd3d; -#N canvas 257 262 759 345 init 0; -#X obj 89 215 t a; -#X obj 89 33 loadbang; -#X obj 89 241 s \$0-in; -#X obj 89 59 t b b b b b; -#X msg 161 80 reset; -#X obj 44 13 inlet; -#X msg 107 161 link souple fix mob 10 10 \, link souple mob mob 10 -10; -#X msg 125 120 mass mob 1 100 0 -2 0 \, mass mob 1 100 2 0 0 \, mass -mob 1 100 0 2 0 \, mass mob 1 100 -2 0 0; -#X msg 89 187 Xmax 4 \, Xmin -4 \, Ymax 4 \, Ymin -4 \, Zmax 4 \, Zmin --4; -#X msg 143 100 mass fix 0 10 0 0 0; -#X connect 0 0 2 0; -#X connect 1 0 3 0; -#X connect 3 0 8 0; -#X connect 3 1 6 0; -#X connect 3 2 7 0; -#X connect 3 3 9 0; -#X connect 3 4 4 0; -#X connect 4 0 0 0; -#X connect 5 0 3 0; -#X connect 6 0 0 0; -#X connect 7 0 0 0; -#X connect 8 0 0 0; -#X connect 9 0 0 0; -#X restore 17 156 pd init; -#X obj 18 321 s \$0-out; -#X obj 18 272 r \$0-in; -#X obj 393 317 s \$0-in; -#N canvas 565 515 355 193 compute 0; -#X obj 27 29 inlet; -#X obj 27 127 s \$0-in; -#X msg 27 96 bang \, get massesPos \, get linksPos; -#X obj 27 66 gemhead; -#X obj 160 36 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 --1; -#X connect 0 0 3 0; -#X connect 2 0 1 0; -#X connect 3 0 2 0; -#X connect 4 0 2 0; -#X restore 17 209 pd compute; -#X obj 17 181 tgl 15 0 empty empty ON/OFF 25 10 1 10 -262144 -1 -1 -1 1; -#X obj 172 270 r \$0-out; -#X obj 17 126 bng 15 250 50 0 empty empty reset 25 10 1 10 -262144 --1 -1; -#X obj 336 216 gemwin; -#X msg 336 194 0 \, destroy; -#N canvas 363 318 550 319 gemrender 0; -#X obj 48 203 translateXYZ; -#X obj 48 229 sphere 0.1; -#X obj 127 24 inlet; -#X obj 390 13 inlet; -#X obj 303 213 curve 2; -#X obj 125 136 t b f; -#X obj 127 62 unpack f f f f; -#X msg 390 58 \$2 \$3 \$4; -#X msg 462 62 \$5 \$6 \$7; -#X obj 48 167 gemhead; -#X msg 48 143 0; -#X obj 48 115 loadbang; -#X obj 303 147 gemhead; -#X msg 303 123 0; -#X obj 303 95 loadbang; -#X obj 390 86 t b l; -#X connect 0 0 1 0; -#X connect 2 0 6 0; -#X connect 3 0 8 0; -#X connect 3 0 7 0; -#X connect 5 0 9 0; -#X connect 5 1 0 1; -#X connect 6 1 5 0; -#X connect 6 2 0 2; -#X connect 6 3 0 3; -#X connect 7 0 15 0; -#X connect 8 0 4 2; -#X connect 9 0 0 0; -#X connect 10 0 9 0; -#X connect 11 0 10 0; -#X connect 12 0 4 0; -#X connect 13 0 12 0; -#X connect 14 0 13 0; -#X connect 15 0 12 0; -#X connect 15 1 4 1; -#X restore 172 321 pd gemrender; -#X msg 336 129 reset \, create \, 1; -#X obj 18 296 pmpd3d; -#X msg 393 271 forceZ mob -10; -#X msg 393 293 forceZ mob 10; -#X text 392 246 2 Send forces; -#X text 170 132 1 Create window -->; -#X text 170 195 3 And destroy it -->; -#X obj 172 294 route massesPos linksPosNo; -#X text 112 618 01_pmpd3dtest.pd; -#X connect 40 0 50 0; +#X text 15 30 The attributes messages ask the object to output some +of his internal parameters. They can be output by lists for positions +and forces of masses \, or directly send value to a table.; +#X restore 12 499 pd masses_attributes __; +#N canvas 446 66 1236 814 links_attributes 0; +#X obj 5 3 cnv 15 590 15 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 10 108 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 4 87 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577 +0; +#X text 7 2 ATTRIBUTES Messages; +#X text 7 87 Lists :; +#X text 170 180 Output all norm of position vector (sqrt(x*x+y*y)) +in a list on outlet No 1; +#X obj 11 222 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 11 335 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 611 26 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 605 5 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577 +0; +#X obj 612 140 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 +-66577 0; +#X obj 612 253 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 +-66577 0; +#X msg 14 305 massesSpeedsNormL (\$1); +#X text 402 546 \$1 (optional): Masses Id; +#X text 833 502 \$2 (optional): Masses Id; +#X text 832 489 \$1 : table name; +#X obj 17 584 cnv 15 150 220 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X obj 11 564 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577 +0; +#X msg 22 597 massesPosMean; +#X text 177 613 \$1 : none or Id; +#X msg 23 629 massesPosStd \$1; +#X text 179 644 \$1 : none or Id; +#X text 173 597 output the average position of masses; +#X text 174 628 output the standard deviation of masses position; +#X text 177 674 \$1 : none or Id; +#X text 179 711 \$1 : none or Id; +#X text 173 658 output the average position of masses; +#X text 174 695 output the standard deviation of masses position; +#X text 177 749 \$1 : none or Id; +#X text 178 786 \$1 : none or Id; +#X text 173 733 output the average position of masses; +#X text 173 770 output the standard deviation of masses position; +#X msg 22 696 massesForcesStd \$1; +#X msg 22 658 massesForcesMean; +#X msg 23 735 massesSpeedsMean; +#X msg 22 771 massesSpeedsStd \$1; +#X text 608 5 tables :; +#X text 15 30 The attributes messages ask the object to output some +of his internal parameters. They can be output by lists for positions +and forces of links; +#X text 14 564 statistics (not implemented yet) :; +#X msg 11 119 linksPosL (\$1); +#X text 170 120 Output all links center positions in a list on outlet +No 1; +#X msg 11 138 linksPosXL (\$1); +#X msg 12 157 linksPosYL (\$1); +#X msg 12 176 linksPosZL (\$1); +#X msg 12 195 linksPosNormL (\$1); +#X msg 13 229 linksLengthL (\$1); +#X msg 13 248 linksLengthXL (\$1); +#X msg 13 267 linksLengthYL (\$1); +#X msg 14 286 linksLengthZL (\$1); +#X text 170 152 Output all links x or y in a list on outlet No 1; +#X obj 12 451 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 -66577 +0; +#X msg 14 458 linksLengthSpeedL (\$1); +#X msg 14 477 linksLengthSpeedXL (\$1); +#X msg 14 496 linksLengthSpeedYL (\$1); +#X msg 15 515 linksLengthSpeedZL (\$1); +#X msg 15 534 massesSpeedsSpeedNormL (\$1); +#X text 184 459 Output all link lenght deformation speed in a list +on outlet No 1; +#X text 184 495 Output all link lenght deformation speed in x or y +in a list on outlet No 1; +#X text 214 523 Output all norm of link lenght deformation speed vector +(sqrt(x*x+y*y)) in a list on outlet No 1; +#X msg 615 38 linksPosT \$1 (\$2); +#X msg 616 57 linksPosXT \$1 (\$2); +#X msg 615 76 linksPosYT \$1 (\$2); +#X msg 615 95 linksPosZT \$1 (\$2); +#X msg 614 114 linksPosNormT \$1 (\$2); +#X msg 616 152 linksLengthT \$1 (\$2); +#X msg 615 228 linksLengthNormT \$1 (\$2); +#X obj 612 369 cnv 15 150 110 empty empty empty 20 12 0 14 -233017 +-66577 0; +#X text 808 377 Output all link lenght deformation speed in a list +on outlet No 1; +#X text 808 413 Output all link lenght deformation speed in x or y +in a list on outlet No 1; +#X text 838 441 Output all norm of link lenght deformation speed vector +(sqrt(x*x+y*y)) in a list on outlet No 1; +#X msg 614 376 linksLengthSpeedT \$1 (\$2); +#X msg 613 395 linksLengthSpeedXT \$1 (\$2); +#X msg 614 414 linksLengthSpeedYT \$1 (\$2); +#X msg 615 433 linksLengthSpeedZT \$1 (\$2); +#X msg 615 452 massesSpeedsSpeedNormT \$1 (\$2); +#X text 794 35 Output all links center positions in a table (\$1); +#X text 794 67 Output all links center positions x or y in a table +(\$1); +#X text 793 105 Output all norm of links center positions vector (sqrt(x*x+y*y)) +in a table (\$1); +#X text 170 233 Output all link lenght in a list on outlet No 1; +#X text 172 266 Output all link lenght in x or y in a list on outlet +No 1; +#X text 181 294 Output all norm of link lenght vector (sqrt(x*x+y*y)) +in a list on outlet No 1; +#X text 171 349 Output all link center speed in a list on outlet No +1; +#X text 175 379 Output all link center speed in x or y in a list on +outlet No 1; +#X text 194 415 Output all norm of link center speed vector (sqrt(x*x+y*y)) +in a list on outlet No 1; +#X text 797 154 Output all link length in a list on outlet No 1; +#X text 796 181 Output all link length in x or y in a list on outlet +No 1; +#X text 799 218 Output all norm of link length vector (sqrt(x*x+y*y)) +in a list on outlet No 1; +#X msg 16 342 linksPosSpeedL (\$1); +#X msg 16 361 linksPosSpeedXL (\$1); +#X msg 15 380 linksPosSpeedYL (\$1); +#X msg 15 399 linksPosSpeedsZL (\$1); +#X msg 14 418 linksPosSpeedNormL (\$1); +#X msg 616 259 linksPosSpeedT \$1 (\$2); +#X msg 616 335 linksPosSpeedNormT \$1 (\$2); +#X text 795 264 Output all link center speed in a list on outlet No +1; +#X text 799 294 Output all link center speed in x or y in a list on +outlet No 1; +#X text 815 326 Output all norm of link center speed vector (sqrt(x*x+y*y)) +in a list on outlet No 1; +#X msg 616 171 linksLengthXT \$1 (\$2); +#X msg 616 190 linksLengthYT \$1 (\$2); +#X msg 616 209 linksLengthZT \$1 (\$2); +#X msg 616 278 linksPosSpeedXT \$1 (\$2); +#X msg 616 297 linksPosSpeedYT \$1 (\$2); +#X msg 616 316 linksPosSpeedZT \$1 (\$2); +#X restore 12 519 pd links_attributes ___; +#X connect 36 0 46 0; +#X connect 39 0 38 0; +#X connect 40 0 52 0; +#X connect 41 0 34 0; #X connect 43 0 42 0; -#X connect 44 0 56 0; -#X connect 45 0 38 0; -#X connect 47 0 46 0; -#X connect 49 0 46 0; -#X connect 50 0 39 0; -#X connect 51 0 41 0; -#X connect 52 0 41 0; -#X connect 56 0 48 0; -#X connect 56 1 48 1; +#X connect 45 0 42 0; +#X connect 46 0 35 0; +#X connect 47 0 37 0; +#X connect 48 0 37 0; +#X connect 52 0 44 0; +#X connect 52 1 44 1; @@ -31,8 +31,8 @@ #include "stdio.h"
#include "math.h"
-#define nb_max_link 100000
-#define nb_max_mass 100000
+#define nb_max_link 10000000
+#define nb_max_mass 1000000
#define max(a,b) ( ((a) > (b)) ? (a) : (b) )
#define min(a,b) ( ((a) < (b)) ? (a) : (b) )
@@ -68,6 +68,7 @@ typedef struct _mass { t_float forceY;
t_float forceZ;
t_float D2;
+ t_float D2offset;
int num;
} foo;
@@ -92,7 +93,7 @@ typedef struct _link { t_float D_L; // longeur du tabeau D
} foo1 ;
-typedef struct _pmpd3d2d {
+typedef struct _pmpd3d {
t_object x_obj;
struct _link link[nb_max_link];
struct _mass mass[nb_max_mass];
@@ -148,7 +149,10 @@ void pmpd3d_infosL(t_pmpd3d *x) post("number, Id, mobile, mass, Damping, positionX Y Z, speedX Y Z, forcesX Y Z");
for(i=0; i < x->nb_mass; i++)
{
- post("masse %i: %s, %d, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f",i, x->mass[i].Id->s_name, x->mass[i].mobile, 1/x->mass[i].invM, x->mass[i].D2, x->mass[i].posX, x->mass[i].posY, x->mass[i].posZ, x->mass[i].speedX, x->mass[i].speedY, x->mass[i].speedZ, x->mass[i].forceX, x->mass[i].forceY, x->mass[i].forceZ );
+ post("masse %i: %s, %d, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f",i, x->mass[i].Id->s_name, \
+ x->mass[i].mobile, 1/x->mass[i].invM, x->mass[i].D2, x->mass[i].posX, x->mass[i].posY, \
+ x->mass[i].posZ, x->mass[i].speedX, x->mass[i].speedY, x->mass[i].speedZ, \
+ x->mass[i].forceX, x->mass[i].forceY, x->mass[i].forceZ );
}
post("list of link");
@@ -158,13 +162,20 @@ void pmpd3d_infosL(t_pmpd3d *x) switch (x->link[i].lType)
{
case 0:
- post("link %i: %s, %i, %i, %f, %f, %f, %f, %f, %f", i, x->link[i].Id->s_name, x->link[i].mass1->num, x->link[i].mass2->num, x->link[i].K, x->link[i].D, x->link[i].Pow, x->link[i].L, x->link[i].Lmin, x->link[i].Lmax);
+ post("link %i: %s, %i, %i, %f, %f, %f, %f, %f, %f", i, x->link[i].Id->s_name, \
+ x->link[i].mass1->num, x->link[i].mass2->num, x->link[i].K, x->link[i].D, \
+ x->link[i].Pow, x->link[i].L, x->link[i].Lmin, x->link[i].Lmax);
break;
case 1:
- post("tLink %i: %s, %i, %i, %f, %f, %f, %f, %f, %f, %f, %f, %f", i, x->link[i].Id->s_name, x->link[i].mass1->num, x->link[i].mass2->num, x->link[i].K, x->link[i].D, x->link[i].Pow, x->link[i].L, x->link[i].Lmin, x->link[i].Lmax, x->link[i].VX, x->link[i].VY, x->link[i].VZ);
+ post("tLink %i: %s, %i, %i, %f, %f, %f, %f, %f, %f, %f, %f, %f", i, x->link[i].Id->s_name, \
+ x->link[i].mass1->num, x->link[i].mass2->num, x->link[i].K, x->link[i].D, \
+ x->link[i].Pow, x->link[i].L, x->link[i].Lmin, x->link[i].Lmax, \
+ x->link[i].VX, x->link[i].VY, x->link[i].VZ);
break;
case 2:
- post("tabLink %i: %s, %i, %i, %f, %f, %s, %f, %s, %f", i, x->link[i].Id->s_name, x->link[i].mass1->num, x->link[i].mass2->num, x->link[i].K, x->link[i].D, x->link[i].arrayK->s_name, x->link[i].K_L, x->link[i].arrayD->s_name, x->link[i].D_L);
+ post("tabLink %i: %s, %i, %i, %f, %f, %s, %f, %s, %f", i, x->link[i].Id->s_name, \
+ x->link[i].mass1->num, x->link[i].mass2->num, x->link[i].K, x->link[i].D, \
+ x->link[i].arrayK->s_name, x->link[i].K_L, x->link[i].arrayD->s_name, x->link[i].D_L);
break;
}
}
@@ -173,7 +184,7 @@ void pmpd3d_infosL(t_pmpd3d *x) void pmpd3d_bang(t_pmpd3d *x)
{
// this part is doing all the PM
- t_float F, L, Lx,Ly, Lz, Fx, Fy, Fz, tmpX, tmpY, tmpZ;
+ t_float F, L, Lx,Ly, Lz, Fx, Fy, Fz, tmpX, tmpY, tmpZ, speed;
t_int i;
// post("bang");
@@ -190,7 +201,8 @@ void pmpd3d_bang(t_pmpd3d *x) x->mass[i].posX += x->mass[i].speedX ;
x->mass[i].posY += x->mass[i].speedY ;
x->mass[i].posZ += x->mass[i].speedZ ;
- if ( (x->mass[i].posX < x->minX) || (x->mass[i].posX > x->maxX) || (x->mass[i].posY < x->minY) || (x->mass[i].posY > x->maxY) || (x->mass[i].posZ < x->minZ) || (x->mass[i].posZ > x->maxZ) )
+ if ( (x->mass[i].posX < x->minX) || (x->mass[i].posX > x->maxX) || (x->mass[i].posY < x->minY)
+ || (x->mass[i].posY > x->maxY) || (x->mass[i].posZ < x->minZ) || (x->mass[i].posZ > x->maxZ) )
{
tmpX = min(x->maxX,max(x->minX,x->mass[i].posX));
tmpY = min(x->maxY,max(x->minY,x->mass[i].posY));
@@ -205,6 +217,12 @@ void pmpd3d_bang(t_pmpd3d *x) x->mass[i].forceX = -x->mass[i].D2 * x->mass[i].speedX;
x->mass[i].forceY = -x->mass[i].D2 * x->mass[i].speedY;
x->mass[i].forceZ = -x->mass[i].D2 * x->mass[i].speedZ;
+ speed = sqrt(x->mass[i].speedX * x->mass[i].speedX + x->mass[i].speedY * x->mass[i].speedY + x->mass[i].speedZ * x->mass[i].speedZ);
+ if (speed != 0) {
+ x->mass[i].forceX += x->mass[i].D2offset * (x->mass[i].speedX/speed);
+ x->mass[i].forceY += x->mass[i].D2offset * (x->mass[i].speedY/speed);
+ x->mass[i].forceZ += x->mass[i].D2offset * (x->mass[i].speedZ/speed);
+ }
}
for (i=0; i<x->nb_link; i++)
@@ -250,7 +268,8 @@ void pmpd3d_bang(t_pmpd3d *x) }
}
-void pmpd3d_mass(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)//, t_symbol *Id, t_float mobile, t_float M, t_float posX, t_float posY, t_float posZ )
+void pmpd3d_mass(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+//, t_symbol *Id, t_float mobile, t_float M, t_float posX, t_float posY, t_float posZ )
{ // add a mass : Id, invM speedX posX
if(argv[0].a_type == A_SYMBOL)
{
@@ -269,6 +288,9 @@ void pmpd3d_mass(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)//, t_symbol * x->mass[x->nb_mass].forceY = 0;
x->mass[x->nb_mass].forceZ = 0;
x->mass[x->nb_mass].num = x->nb_mass;
+ x->mass[x->nb_mass].D2 = 0;
+ x->mass[x->nb_mass].D2offset = 0;
+
x->nb_mass++ ;
x->nb_mass = min ( nb_max_mass -1, x->nb_mass );
@@ -286,7 +308,8 @@ void pmpd3d_create_link(t_pmpd3d *x, t_symbol *Id, int mass1, int mass2, t_float x->link[x->nb_link].mass2 = &x->mass[mass2];
x->link[x->nb_link].K = K;
x->link[x->nb_link].D = D;
- x->link[x->nb_link].L = sqrt(sqr(x->mass[mass1].posX - x->mass[mass2].posX) + sqr(x->mass[mass1].posY - x->mass[mass2].posY) + sqr(x->mass[mass1].posZ - x->mass[mass2].posZ));
+ x->link[x->nb_link].L = sqrt(sqr(x->mass[mass1].posX - x->mass[mass2].posX) +
+ sqr(x->mass[mass1].posY - x->mass[mass2].posY) + sqr(x->mass[mass1].posZ - x->mass[mass2].posZ));
x->link[x->nb_link].Pow = Pow;
x->link[x->nb_link].Lmin = Lmin;
x->link[x->nb_link].Lmax = Lmax;
@@ -350,7 +373,8 @@ void pmpd3d_link(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) {
if ( (atom_getsymbolarg(1,argc,argv) == x->mass[i].Id)&(atom_getsymbolarg(2,argc,argv) == x->mass[j].Id))
{
- if (!( (x->mass[i].Id == x->mass[j].Id) && (i>j) )) // si lien entre 2 serie de masses identique entres elle, alors on ne creer qu'un lien sur 2, pour evider les redondances
+ if (!( (x->mass[i].Id == x->mass[j].Id) && (i>j) ))
+ // si lien entre 2 serie de masses identique entres elle, alors on ne creer qu'un lien sur 2, pour evider les redondances
pmpd3d_create_link(x, Id, i, j, K, D, Pow, Lmin, Lmax, 0);
}
}
@@ -421,7 +445,8 @@ void pmpd3d_tLink(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) {
if ( (atom_getsymbolarg(1,argc,argv) == x->mass[i].Id)&(atom_getsymbolarg(2,argc,argv) == x->mass[j].Id))
{
- if (!( (x->mass[i].Id == x->mass[j].Id) && (i>j) )) // si lien entre 2 serie de masses identique entres elle, alors on ne creer qu'un lien sur 2, pour evider les redondances
+ if (!( (x->mass[i].Id == x->mass[j].Id) && (i>j) ))
+ // si lien entre 2 serie de masses identique entres elle, alors on ne creer qu'un lien sur 2, pour evider les redondances
{
pmpd3d_create_link(x, Id, i, j, K, D, Pow, Lmin, Lmax, 1);
x->link[x->nb_link-1].VX = vecteurX;
@@ -494,7 +519,8 @@ void pmpd3d_tabLink(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) {
if ( (atom_getsymbolarg(1,argc,argv) == x->mass[i].Id)&(atom_getsymbolarg(2,argc,argv) == x->mass[j].Id))
{
- if (!( (x->mass[i].Id == x->mass[j].Id) && (i>j) )) // si lien entre 2 serie de masses identique entres elle, alors on ne creer qu'un lien sur 2, pour evider les redondances
+ if (!( (x->mass[i].Id == x->mass[j].Id) && (i>j) ))
+ // si lien entre 2 serie de masses identique entres elle, alors on ne creer qu'un lien sur 2, pour evider les redondances
{
pmpd3d_create_link(x, Id, i, j, 1, 1, 1, 0, 1000000, 2);
x->link[x->nb_link-1].arrayK = arrayK;
@@ -1018,6 +1044,35 @@ void pmpd3d_setD2(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) }
}
+void pmpd3d_setD2offset(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int tmp, i;
+
+ if ( ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) )
+ {
+ tmp = atom_getfloatarg(0, argc, argv);
+ tmp = max(0, min( x->nb_mass-1, tmp));
+ x->mass[tmp].D2offset = atom_getfloatarg(1, argc, argv);
+ }
+ if ( ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) )
+ {
+ for (i=0; i< x->nb_mass; i++)
+ {
+ if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id)
+ {
+ x->mass[i].D2offset = atom_getfloatarg(1, argc, argv);
+ }
+ }
+ }
+ if ( ( argv[0].a_type == A_FLOAT ) && ( argc == 1 ) )
+ {
+ for (i=0; i< x->nb_mass; i++)
+ {
+ x->mass[i].D2offset = atom_getfloatarg(0, argc, argv);
+ }
+ }
+}
+
void pmpd3d_setSpeedX(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
{
int tmp, i;
@@ -2208,9 +2263,9 @@ void pmpd3d_massesPosL(t_pmpd3d *x) for (i=0; i < x->nb_mass; i++)
{
- SETFLOAT(&(pos_list[2*i] ),x->mass[i].posX);
- SETFLOAT(&(pos_list[2*i+1]),x->mass[i].posY);
- SETFLOAT(&(pos_list[2*i+2]),x->mass[i].posZ);
+ SETFLOAT(&(pos_list[3*i] ),x->mass[i].posX);
+ SETFLOAT(&(pos_list[3*i+1]),x->mass[i].posY);
+ SETFLOAT(&(pos_list[3*i+2]),x->mass[i].posZ);
}
outlet_anything(x->main_outlet, gensym("massesPosL"),3*x->nb_mass , pos_list);
}
@@ -2222,9 +2277,9 @@ void pmpd3d_massesForcesL(t_pmpd3d *x) for (i=0; i< x->nb_mass; i++)
{
- SETFLOAT(&(pos_list[2*i] ),x->mass[i].forceX);
- SETFLOAT(&(pos_list[2*i+1]),x->mass[i].forceY);
- SETFLOAT(&(pos_list[2*i+2]),x->mass[i].forceZ);
+ SETFLOAT(&(pos_list[3*i] ),x->mass[i].forceX);
+ SETFLOAT(&(pos_list[3*i+1]),x->mass[i].forceY);
+ SETFLOAT(&(pos_list[3*i+2]),x->mass[i].forceZ);
}
outlet_anything(x->main_outlet, gensym("massesForcesL"),3*x->nb_mass , pos_list);
}
@@ -2236,9 +2291,9 @@ void pmpd3d_massesSpeedsL(t_pmpd3d *x) for (i=0; i< x->nb_mass; i++)
{
- SETFLOAT(&(pos_list[2*i] ),x->mass[i].speedX);
- SETFLOAT(&(pos_list[2*i+1]),x->mass[i].speedY);
- SETFLOAT(&(pos_list[2*i+2]),x->mass[i].speedZ);
+ SETFLOAT(&(pos_list[3*i] ),x->mass[i].speedX);
+ SETFLOAT(&(pos_list[3*i+1]),x->mass[i].speedY);
+ SETFLOAT(&(pos_list[3*i+2]),x->mass[i].speedZ);
}
outlet_anything(x->main_outlet, gensym("massesSpeedsL"),3*x->nb_mass , pos_list);
}
@@ -2993,6 +3048,1318 @@ void pmpd3d_massesSpeedsStd(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) outlet_anything(x->main_outlet, gensym("massesSpeedsStd"),4 , std_out);
}
+// --------------------------------------------
+
+void pmpd3d_linksPosXL(t_pmpd3d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),(x->link[i].mass1->posX + x->link[i].mass2->posX)/2);
+ }
+ outlet_anything(x->main_outlet, gensym("linksPosXL"),x->nb_link , pos_list);
+}
+
+void pmpd3d_linksLengthXL(t_pmpd3d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),x->link[i].mass2->posX - x->link[i].mass1->posX);
+ }
+ outlet_anything(x->main_outlet, gensym("linksLengthXL"),x->nb_link , pos_list);
+}
+
+void pmpd3d_linksPosSpeedXL(t_pmpd3d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),(x->link[i].mass1->speedX + x->link[i].mass2->speedX)/2);
+ }
+ outlet_anything(x->main_outlet, gensym("linksPosSpeedXL"),x->nb_link , pos_list);
+}
+
+void pmpd3d_linksLengthSpeedXL(t_pmpd3d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),x->link[i].mass2->speedX - x->link[i].mass1->speedX);
+ }
+ outlet_anything(x->main_outlet, gensym("linksLengthSpeedXL"),x->nb_link , pos_list);
+}
+
+void pmpd3d_linksPosXT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = (x->link[i].mass1->posX + x->link[i].mass2->posX)/2;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = (x->link[j].mass1->posX + x->link[j].mass2->posX)/2;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd3d_linksLengthXT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = x->link[i].mass2->posX - x->link[i].mass1->posX;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = x->link[j].mass2->posX - x->link[j].mass1->posX;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd3d_linksPosSpeedXT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = (x->link[i].mass1->speedX + x->link[i].mass2->speedX)/2;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = (x->link[j].mass1->speedX + x->link[j].mass2->speedX)/2;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd3d_linksLengthSpeedXT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = x->link[i].mass2->speedX - x->link[i].mass1->speedX;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = x->link[j].mass2->speedX - x->link[j].mass1->speedX;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd3d_linksPosYL(t_pmpd3d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),(x->link[i].mass1->posY + x->link[i].mass2->posY)/2);
+ }
+ outlet_anything(x->main_outlet, gensym("linksPosYL"),x->nb_link , pos_list);
+}
+
+void pmpd3d_linksLengthYL(t_pmpd3d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),x->link[i].mass2->posY - x->link[i].mass1->posY);
+ }
+ outlet_anything(x->main_outlet, gensym("linksLengthYL"),x->nb_link , pos_list);
+}
+
+void pmpd3d_linksPosSpeedYL(t_pmpd3d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),(x->link[i].mass1->speedY + x->link[i].mass2->speedY)/2);
+ }
+ outlet_anything(x->main_outlet, gensym("linksPosSpeedYL"),x->nb_link , pos_list);
+}
+
+void pmpd3d_linksLengthSpeedYL(t_pmpd3d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),x->link[i].mass2->speedY - x->link[i].mass1->speedY);
+ }
+ outlet_anything(x->main_outlet, gensym("linksLengthSpeedYL"),x->nb_link , pos_list);
+}
+
+void pmpd3d_linksPosYT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = (x->link[i].mass1->posY + x->link[i].mass2->posY)/2;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = (x->link[j].mass1->posY + x->link[j].mass2->posY)/2;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd3d_linksLengthYT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = x->link[i].mass2->posY - x->link[i].mass1->posY;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = x->link[j].mass2->posY - x->link[j].mass1->posY;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd3d_linksPosSpeedYT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = (x->link[i].mass1->speedY + x->link[i].mass2->speedY)/2;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = (x->link[j].mass1->speedY + x->link[j].mass2->speedY)/2;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd3d_linksLengthSpeedYT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = x->link[i].mass2->speedY - x->link[i].mass1->speedY;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = x->link[j].mass2->speedY - x->link[j].mass1->speedY;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd3d_linksPosZL(t_pmpd3d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),(x->link[i].mass1->posZ + x->link[i].mass2->posZ)/2);
+ }
+ outlet_anything(x->main_outlet, gensym("linksPosZL"),x->nb_link , pos_list);
+}
+
+void pmpd3d_linksLengthZL(t_pmpd3d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),x->link[i].mass2->posZ - x->link[i].mass1->posZ);
+ }
+ outlet_anything(x->main_outlet, gensym("linksLengthZL"),x->nb_link , pos_list);
+}
+
+void pmpd3d_linksPosSpeedZL(t_pmpd3d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),(x->link[i].mass1->speedZ + x->link[i].mass2->speedZ)/2);
+ }
+ outlet_anything(x->main_outlet, gensym("linksPosSpeedZL"),x->nb_link , pos_list);
+}
+
+void pmpd3d_linksLengthSpeedZL(t_pmpd3d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),x->link[i].mass2->speedZ - x->link[i].mass1->speedZ);
+ }
+ outlet_anything(x->main_outlet, gensym("linksLengthSpeedZL"),x->nb_link , pos_list);
+}
+
+void pmpd3d_linksPosZT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = (x->link[i].mass1->posZ + x->link[i].mass2->posZ)/2;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = (x->link[j].mass1->posZ + x->link[j].mass2->posZ)/2;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd3d_linksLengthZT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = x->link[i].mass2->posZ - x->link[i].mass1->posZ;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = x->link[j].mass2->posZ - x->link[j].mass1->posZ;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd3d_linksPosSpeedZT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = (x->link[i].mass1->speedZ + x->link[i].mass2->speedZ)/2;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = (x->link[j].mass1->speedZ + x->link[j].mass2->speedZ)/2;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd3d_linksLengthSpeedZT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = x->link[i].mass2->speedZ - x->link[i].mass1->speedZ;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = x->link[j].mass2->speedZ - x->link[j].mass1->speedZ;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd3d_linksPosL(t_pmpd3d *x)
+{
+ int i;
+ t_atom pos_list[3*x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[3*i] ),(x->link[i].mass2->posX + x->link[i].mass1->posX)/2);
+ SETFLOAT(&(pos_list[3*i+1]),(x->link[i].mass2->posY + x->link[i].mass1->posY)/2);
+ SETFLOAT(&(pos_list[3*i+2]),(x->link[i].mass2->posZ + x->link[i].mass1->posZ)/2);
+ }
+ outlet_anything(x->main_outlet, gensym("linksPosL"),3*x->nb_link , pos_list);
+}
+
+void pmpd3d_linksLengthL(t_pmpd3d *x)
+{
+ int i;
+ t_atom pos_list[3*x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[3*i] ),x->link[i].mass2->posX - x->link[i].mass1->posX);
+ SETFLOAT(&(pos_list[3*i+1]),x->link[i].mass2->posY - x->link[i].mass1->posY);
+ SETFLOAT(&(pos_list[3*i+2]),x->link[i].mass2->posZ - x->link[i].mass1->posZ);
+ }
+ outlet_anything(x->main_outlet, gensym("linksLengthL"),3*x->nb_link , pos_list);
+}
+
+void pmpd3d_linksPosSpeedL(t_pmpd3d *x)
+{
+ int i;
+ t_atom pos_list[3*x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[3*i] ),(x->link[i].mass2->speedX + x->link[i].mass1->speedX)/2);
+ SETFLOAT(&(pos_list[3*i+1]),(x->link[i].mass2->speedY + x->link[i].mass1->speedY)/2);
+ SETFLOAT(&(pos_list[3*i+2]),(x->link[i].mass2->speedZ + x->link[i].mass1->speedZ)/2);
+ }
+ outlet_anything(x->main_outlet, gensym("linksPosSpeedL"),3*x->nb_link , pos_list);
+}
+
+void pmpd3d_linksLengthSpeedL(t_pmpd3d *x)
+{
+ int i;
+ t_atom pos_list[3*x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[3*i] ),x->link[i].mass2->speedX - x->link[i].mass1->speedX);
+ SETFLOAT(&(pos_list[3*i+1]),x->link[i].mass2->speedY - x->link[i].mass1->speedY);
+ SETFLOAT(&(pos_list[3*i+2]),x->link[i].mass2->speedZ - x->link[i].mass1->speedZ);
+ }
+ outlet_anything(x->main_outlet, gensym("linksLengthSpeedL"),3*x->nb_link , pos_list);
+}
+
+void pmpd3d_linksPosT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, (vecsize-2)/3);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[3*i ].w_float = (x->link[i].mass2->posX + x->link[i].mass1->posX)/2;
+ vec[3*i+1].w_float = (x->link[i].mass2->posY + x->link[i].mass1->posY)/2;
+ vec[3*i+2].w_float = (x->link[i].mass2->posZ + x->link[i].mass1->posZ)/2;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize-2) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->mass[j].Id)
+ {
+ vec[i].w_float = (x->link[j].mass2->posX + x->link[j].mass1->posX)/2;
+ i++;
+ vec[i].w_float = (x->link[j].mass2->posY + x->link[j].mass1->posY)/2;
+ i++;
+ vec[i].w_float = (x->link[j].mass2->posZ + x->link[j].mass1->posZ)/2;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd3d_linksLengthT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, (vecsize-2)/3);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[3*i ].w_float = x->link[i].mass2->posX - x->link[i].mass1->posX;
+ vec[3*i+1].w_float = x->link[i].mass2->posY - x->link[i].mass1->posY;
+ vec[3*i+2].w_float = x->link[i].mass2->posZ - x->link[i].mass1->posZ;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize-2) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->mass[j].Id)
+ {
+ vec[i].w_float = x->link[j].mass2->posX + x->link[j].mass1->posX;
+ i++;
+ vec[i].w_float = x->link[j].mass2->posY + x->link[j].mass1->posY;
+ i++;
+ vec[i].w_float = x->link[j].mass2->posZ + x->link[j].mass1->posZ;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd3d_linksPosSpeedT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, (vecsize-2)/3);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[3*i ].w_float = (x->link[i].mass2->speedX + x->link[i].mass1->speedX)/2;
+ vec[3*i+1].w_float = (x->link[i].mass2->speedY + x->link[i].mass1->speedY)/2;
+ vec[3*i+2].w_float = (x->link[i].mass2->speedZ + x->link[i].mass1->speedZ)/2;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize-2) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->mass[j].Id)
+ {
+ vec[i].w_float = (x->link[j].mass2->speedX + x->link[j].mass1->speedX)/2;
+ i++;
+ vec[i].w_float = (x->link[j].mass2->speedY + x->link[j].mass1->speedY)/2;
+ i++;
+ vec[i].w_float = (x->link[j].mass2->speedZ + x->link[j].mass1->speedZ)/2;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd3d_linksLengthSpeedT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, (vecsize-2)/3);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[3*i ].w_float = x->link[i].mass2->speedX - x->link[i].mass1->speedX;
+ vec[3*i+1].w_float = x->link[i].mass2->speedY - x->link[i].mass1->speedY;
+ vec[3*i+2].w_float = x->link[i].mass2->speedZ - x->link[i].mass1->speedZ;
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize-2) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->mass[j].Id)
+ {
+ vec[i].w_float = x->link[j].mass2->speedX + x->link[j].mass1->speedX;
+ i++;
+ vec[i].w_float = x->link[j].mass2->speedY + x->link[j].mass1->speedY;
+ i++;
+ vec[i].w_float = x->link[j].mass2->speedZ + x->link[j].mass1->speedZ;
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd3d_linksPosNormL(t_pmpd3d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),sqrt( \
+ sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + \
+ sqr((x->link[i].mass1->posY + x->link[i].mass2->posY)/2) + \
+ sqr((x->link[i].mass1->posZ + x->link[i].mass2->posZ)/2) ));
+ }
+ outlet_anything(x->main_outlet, gensym("linksPosNormL"),x->nb_link , pos_list);
+}
+
+void pmpd3d_linksLengthNormL(t_pmpd3d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),sqrt( \
+ sqr(x->link[i].mass2->posX - x->link[i].mass1->posX) + \
+ sqr(x->link[i].mass2->posY - x->link[i].mass1->posY) + \
+ sqr(x->link[i].mass2->posZ - x->link[i].mass1->posZ) ));
+ }
+ outlet_anything(x->main_outlet, gensym("linksLengthNormL"),x->nb_link , pos_list);
+}
+
+void pmpd3d_linksPosSpeedNormL(t_pmpd3d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),sqrt( \
+ sqr((x->link[i].mass1->speedX + x->link[i].mass2->speedX)/2) + \
+ sqr((x->link[i].mass1->speedY + x->link[i].mass2->speedY)/2) + \
+ sqr((x->link[i].mass1->speedZ + x->link[i].mass2->speedZ)/2) ));
+ }
+ outlet_anything(x->main_outlet, gensym("linksPosSpeedNormL"),x->nb_link , pos_list);
+}
+
+void pmpd3d_linksLengthSpeedNormL(t_pmpd3d *x)
+{
+ int i;
+ t_atom pos_list[x->nb_link];
+
+ for (i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(pos_list[i]),sqrt( \
+ sqr(x->link[i].mass2->speedX - x->link[i].mass1->speedX) + \
+ sqr(x->link[i].mass2->speedY - x->link[i].mass1->speedY) + \
+ sqr(x->link[i].mass2->speedZ - x->link[i].mass1->speedZ) ));
+ }
+ outlet_anything(x->main_outlet, gensym("linksLengthSpeedNormL"),x->nb_link , pos_list);
+}
+
+void pmpd3d_linksPosNormT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = sqrt( \
+ sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + \
+ sqr((x->link[i].mass1->posY + x->link[i].mass2->posY)/2) + \
+ sqr((x->link[i].mass1->posZ + x->link[i].mass2->posZ)/2) );
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[j].w_float = sqrt( \
+ sqr((x->link[j].mass1->posX + x->link[j].mass2->posX)/2) + \
+ sqr((x->link[j].mass1->posY + x->link[j].mass2->posY)/2) + \
+ sqr((x->link[j].mass1->posZ + x->link[j].mass2->posZ)/2) );
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd3d_linksLengthNormT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = sqrt( \
+ sqr(x->link[i].mass2->posX - x->link[i].mass1->posX) + \
+ sqr(x->link[i].mass2->posY - x->link[i].mass1->posY) + \
+ sqr(x->link[i].mass2->posZ - x->link[i].mass1->posZ) );
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = sqrt( \
+ sqr(x->link[j].mass2->posX - x->link[j].mass1->posX) + \
+ sqr(x->link[j].mass2->posY - x->link[j].mass1->posY) + \
+ sqr(x->link[j].mass2->posZ - x->link[j].mass1->posZ) );
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd3d_linksPosSpeedNormT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = sqrt( \
+ sqr((x->link[i].mass1->speedX + x->link[i].mass2->speedX)/2) + \
+ sqr((x->link[i].mass1->speedY + x->link[i].mass2->speedY)/2) + \
+ sqr((x->link[i].mass1->speedZ + x->link[i].mass2->speedZ)/2) );
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = sqrt( \
+ sqr((x->link[j].mass1->speedX + x->link[j].mass2->speedX)/2) + \
+ sqr((x->link[j].mass1->speedY + x->link[j].mass2->speedY)/2) + \
+ sqr((x->link[j].mass1->speedZ + x->link[j].mass2->speedZ)/2) );
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+void pmpd3d_linksLengthSpeedNormT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, vecsize;
+ t_garray *a;
+ t_word *vec;
+
+ if ( (argc==1) && (argv[0].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ int taille_max = x->nb_link;
+ taille_max = min(taille_max, vecsize);
+ for (i=0; i < taille_max ; i++)
+ {
+ vec[i].w_float = sqrt( \
+ sqr(x->link[i].mass2->speedX - x->link[i].mass1->speedX) + \
+ sqr(x->link[i].mass2->speedY - x->link[i].mass1->speedY) + \
+ sqr(x->link[i].mass2->speedZ - x->link[i].mass1->speedZ) );
+ }
+ garray_redraw(a);
+ }
+ }
+ else
+ if ( (argc==2) && (argv[0].a_type == A_SYMBOL) && (argv[1].a_type == A_SYMBOL) )
+ {
+ t_symbol *tab_name = atom_getsymbolarg(0, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(tab_name, garray_class)))
+ pd_error(x, "%s: no such array", tab_name->s_name);
+ else if (!garray_getfloatwords(a, &vecsize, &vec))
+ pd_error(x, "%s: bad template for tabwrite", tab_name->s_name);
+ else
+ {
+ i = 0;
+ j = 0;
+ while ((i < vecsize) && (j < x->nb_link))
+ {
+ if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id)
+ {
+ vec[i].w_float = sqrt( \
+ sqr(x->link[j].mass2->speedX - x->link[j].mass1->speedX) + \
+ sqr(x->link[j].mass2->speedY - x->link[j].mass1->speedY) + \
+ sqr(x->link[j].mass2->speedZ - x->link[j].mass1->speedZ) );
+ i++;
+ }
+ j++;
+ }
+ garray_redraw(a);
+ }
+ }
+}
+
+//----------------------------------------------
+
void pmpd3d_grabMass(t_pmpd3d *x, t_float posX, t_float posY, t_float posZ, t_float grab)
{
t_float dist, tmp;
@@ -3045,7 +4412,6 @@ void pmpd3d_setup(void) class_addmethod(pmpd3d_class, (t_method)pmpd3d_reset, gensym("reset"), 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_infosL, gensym("infosL"), 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_infosL, gensym("print"), 0);
-// class_addmethod(pmpd3d_class, (t_method)pmpd3d_mass, gensym("mass"), A_DEFSYMBOL, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_mass, gensym("mass"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_link, gensym("link"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_tabLink, gensym("tabLink"), A_GIMME, 0);
@@ -3077,6 +4443,7 @@ void pmpd3d_setup(void) class_addmethod(pmpd3d_class, (t_method)pmpd3d_setFixed, gensym("setFixed"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_setMobile, gensym("setMobile"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_setD2, gensym("setDEnv"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_setD2offset, gensym("setDEnvOffset"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_setSpeed, gensym("setSpeed"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_setSpeedX, gensym("setSpeedX"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_setSpeedY, gensym("setSpeedY"), A_GIMME, 0);
@@ -3127,15 +4494,68 @@ void pmpd3d_setup(void) class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsNormT, gensym("massesSpeedsNormT"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesNormT, gensym("massesForcesNormT"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosMean, gensym("massesPosMean"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosStd, gensym("massesPosStd"),A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesMean,gensym("massesForecesMean"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesStd, gensym("massesForcesStd"),A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsMean,gensym("massesSpeedsMean"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsStd, gensym("massesSpeedsStd"),A_GIMME, 0);
- // class_addmethod(pmpd3d_class, (t_method)pmpd3d_linkLMean, gensym("linkLMean"),A_GIMME, 0);
- // class_addmethod(pmpd3d_class, (t_method)pmpd3d_linkLStd, gensym("linkLStd"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosMean, gensym("massesPosMean"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosStd, gensym("massesPosStd"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesMean, gensym("massesForecesMean"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesStd, gensym("massesForcesStd"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsMean, gensym("massesSpeedsMean"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsStd, gensym("massesSpeedsStd"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosXL, gensym("linksPosXL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthXL, gensym("linksLengthXL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosSpeedXL, gensym("linksPosSpeedXL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthSpeedXL, gensym("linksLengthXL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosXT, gensym("linksPosXT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthXT, gensym("linksLengthXT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosSpeedXT, gensym("linksPosSpeedXT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthSpeedXT, gensym("linksLengthSpeedXT"), A_GIMME, 0);
+
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosYL, gensym("linksPosYL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthYL, gensym("linksLengthYL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosSpeedYL, gensym("linksPosSpeedYL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthSpeedYL, gensym("linksLengthYL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosYT, gensym("linksPosYT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthYT, gensym("linksLengthYT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosSpeedYT, gensym("linksPosSpeedYT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthSpeedYT, gensym("linksLengthSpeedYT"), A_GIMME, 0);
+
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosZL, gensym("linksPosZL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthZL, gensym("linksLengthZL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosSpeedZL, gensym("linksPosSpeedZL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthSpeedZL, gensym("linksLengthZL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosZT, gensym("linksPosZT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthZT, gensym("linksLengthZT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosSpeedZT, gensym("linksPosSpeedZT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthSpeedZT, gensym("linksLengthSpeedZT"), A_GIMME, 0);
+
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosL, gensym("linksPosL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthL, gensym("linksLengthL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosSpeedL, gensym("linksPosSpeedL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthSpeedL, gensym("linksLengthL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosT, gensym("linksPosT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthT, gensym("linksLengthT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosSpeedT, gensym("linksPosSpeedT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthSpeedT, gensym("linksLengthSpeedT"), A_GIMME, 0);
+
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosNormL, gensym("linksPosNormL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthNormL, gensym("linksLengthNormL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosSpeedNormL, gensym("linksPosSpeedNormL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthSpeedNormL, gensym("linksLengthNormL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosNormT, gensym("linksPosNormT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthNormT, gensym("linksLengthNormT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosSpeedNormT, gensym("linksPosSpeedNormT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthSpeedNormT, gensym("linksLengthSpeedNormT"), A_GIMME, 0);
+
+/* class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosMean, gensym("linksPosMean"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthMean, gensym("linksLengthMean"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosSpeedMean, gensym("linksPosSpeedMean"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthSpeedMean, gensym("linksLengthSpeedMean"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosStd, gensym("linksPosStd"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthStd, gensym("linksLengthStd"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosSpeedStd, gensym("linksPosSpeedStd"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthSpeedStd0, gensym("linksLengthSpeedStd"), A_GIMME, 0);
+*/
+
class_addmethod(pmpd3d_class, (t_method)pmpd3d_grabMass, gensym("grabMass"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
}
|