aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Henry <nusmuk@users.sourceforge.net>2014-08-25 13:09:20 +0000
committerCyrille Henry <nusmuk@users.sourceforge.net>2014-08-25 13:09:20 +0000
commit1abc1e4b559fc86f1bd783a887b9da0c9b963842 (patch)
tree837630e44bb17d20b1eb5c39b990e17d78a5fba9
parentffa9af11ed7433ca6b81479a89b08d20dc287dc9 (diff)
linkLength new message
svn path=/trunk/externals/pmpd/; revision=17342
-rw-r--r--pmpd-help.pd105
-rw-r--r--pmpd.c1
-rw-r--r--pmpd2d-help.pd77
-rw-r--r--pmpd3d-help.pd24
-rw-r--r--pmpd3d.c1
-rw-r--r--pmpd3d_get.c65
-rw-r--r--pmpd_get.c45
7 files changed, 218 insertions, 100 deletions
diff --git a/pmpd-help.pd b/pmpd-help.pd
index a2da0a2..03eaeee 100644
--- a/pmpd-help.pd
+++ b/pmpd-help.pd
@@ -1,4 +1,4 @@
-#N canvas 542 172 584 778 10;
+#N canvas 540 177 584 778 10;
#X obj 4 369 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577
0;
#X obj 5 729 cnv 15 550 40 empty empty empty 20 12 0 14 -158509 -66577
@@ -108,26 +108,26 @@ msd object. They are of three types :;
#X text 266 736 - Cyrille Henry \, 2011;
#X text 283 752 based on MSD by Nicolas Montgermont;
#X obj 17 187 loadbang;
-#N canvas 179 163 607 855 links_attributes 0;
+#N canvas 175 152 617 876 links_attributes 0;
#X obj 5 3 cnv 15 590 15 empty empty empty 20 12 0 14 -233017 -66577
0;
-#X obj 9 221 cnv 15 170 190 empty empty empty 20 12 0 14 -233017 -66577
+#X obj 9 241 cnv 15 170 190 empty empty empty 20 12 0 14 -233017 -66577
0;
-#X obj 9 201 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577
+#X obj 9 221 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577
0;
#X text 7 2 ATTRIBUTES Messages;
-#X text 12 201 Lists :;
-#X obj 11 440 cnv 15 170 200 empty empty empty 20 12 0 14 -233017 -66577
+#X text 12 221 Lists :;
+#X obj 11 460 cnv 15 170 200 empty empty empty 20 12 0 14 -233017 -66577
0;
-#X obj 11 419 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577
+#X obj 11 439 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577
0;
-#X text 277 391 \$1 (optional): Masses Id;
-#X text 284 780 \$2 (optional): Masses Id;
-#X text 283 767 \$1 : table name;
-#X text 14 419 tables :;
-#X text 189 233 Output all links center positions in a list on outlet
+#X text 277 411 \$1 (optional): Masses Id;
+#X text 284 800 \$2 (optional): Masses Id;
+#X text 283 787 \$1 : table name;
+#X text 14 439 tables :;
+#X text 189 253 Output all links center positions in a list on outlet
No 1;
-#X text 183 449 Output all links center positions in a table (\$1)
+#X text 183 469 Output all links center positions in a table (\$1)
;
#X obj 8 95 cnv 15 170 100 empty empty empty 20 12 0 14 -233017 -66577
0;
@@ -137,54 +137,55 @@ No 1;
0;
#X text 11 74 generic :;
#X text 216 116 linkPos symbolId number center;
-#X text 219 154 linkEnd symbolId number posX1 posX2;
-#X obj 11 644 cnv 15 170 190 empty empty empty 20 12 0 14 -233017 -66577
-0;
-#X msg 18 652 linkEndT \$1 [\$2];
-#X msg 27 672 linkEnd1T \$1 [\$2];
-#X msg 27 691 linkEnd2T \$1 [\$2];
-#X msg 27 710 linkEndXT \$1 [\$2];
-#X msg 27 729 linkEnd1XT \$1 [\$2];
-#X msg 27 748 linkEnd2XT \$1 [\$2];
-#X msg 27 767 linkEndYT \$1 [\$2];
-#X msg 27 786 linkEnd1YT \$1 [\$2];
-#X msg 27 805 linkEnd2YT \$1 [\$2];
-#X text 216 683 table is posX1 posY1 posX2 posY2 ....;
-#X msg 18 231 linkPosL (\$1);
-#X msg 18 250 linkPosXL (\$1);
-#X msg 19 273 linkLengthL (\$1);
-#X msg 19 292 linkLengthXL (\$1);
-#X msg 18 316 linkPosSpeedL (\$1);
-#X msg 18 335 linkPosSpeedXL (\$1);
-#X msg 18 359 linkLengthSpeedL (\$1);
-#X msg 18 378 linkLengthSpeedXL (\$1);
-#X msg 15 445 linkPosT \$1 (\$2);
-#X msg 15 464 linkPosXT \$1 (\$2);
-#X msg 16 492 linkLengthT \$1 (\$2);
-#X msg 16 511 linkLengthXT \$1 (\$2);
-#X msg 16 542 linkPosSpeedT \$1 (\$2);
-#X msg 16 561 linkPosSpeedXT \$1 (\$2);
-#X msg 16 592 linkLengthSpeedT \$1 (\$2);
-#X msg 16 611 linkLengthSpeedXT \$1 (\$2);
+#X text 216 144 linkEnd symbolId number posX1 posX2;
+#X obj 11 664 cnv 15 170 190 empty empty empty 20 12 0 14 -233017 -66577
+0;
+#X msg 18 672 linkEndT \$1 [\$2];
+#X msg 27 692 linkEnd1T \$1 [\$2];
+#X msg 27 711 linkEnd2T \$1 [\$2];
+#X msg 27 730 linkEndXT \$1 [\$2];
+#X msg 27 749 linkEnd1XT \$1 [\$2];
+#X msg 27 768 linkEnd2XT \$1 [\$2];
+#X msg 27 787 linkEndYT \$1 [\$2];
+#X msg 27 806 linkEnd1YT \$1 [\$2];
+#X msg 27 825 linkEnd2YT \$1 [\$2];
+#X text 216 703 table is posX1 posY1 posX2 posY2 ....;
+#X msg 18 251 linkPosL (\$1);
+#X msg 18 270 linkPosXL (\$1);
+#X msg 19 293 linkLengthL (\$1);
+#X msg 19 312 linkLengthXL (\$1);
+#X msg 18 336 linkPosSpeedL (\$1);
+#X msg 18 355 linkPosSpeedXL (\$1);
+#X msg 18 379 linkLengthSpeedL (\$1);
+#X msg 18 398 linkLengthSpeedXL (\$1);
+#X msg 15 465 linkPosT \$1 (\$2);
+#X msg 15 484 linkPosXT \$1 (\$2);
+#X msg 16 512 linkLengthT \$1 (\$2);
+#X msg 16 531 linkLengthXT \$1 (\$2);
+#X msg 16 562 linkPosSpeedT \$1 (\$2);
+#X msg 16 581 linkPosSpeedXT \$1 (\$2);
+#X msg 16 612 linkLengthSpeedT \$1 (\$2);
+#X msg 16 631 linkLengthSpeedXT \$1 (\$2);
#X text 15 30 The attributes messages ask the object to output some
of its internal parameters. They can be output as lists for positions
and forces of links;
-#X text 220 175 \$1 : Id float or symbol of masses (nothing for all)
+#X text 79 205 \$1 : Id float or symbol of masses (nothing for all)
;
#X text 187 99 output a message for every link :;
-#X text 187 138 output a message for every link :;
-#X text 189 277 Output all links length in a list on outlet No 1;
-#X text 191 323 Output all links center speed in a list on outlet No
+#X text 189 297 Output all links length in a list on outlet No 1;
+#X text 191 343 Output all links center speed in a list on outlet No
1;
-#X text 191 359 Output all links length deformation speed in a list
+#X text 191 379 Output all links length deformation speed in a list
on outlet No 1;
-#X text 181 495 Output all links length in a list on outlet No 1;
-#X text 183 543 Output all links center speed in a list on outlet No
+#X text 181 515 Output all links length in a list on outlet No 1;
+#X text 183 563 Output all links center speed in a list on outlet No
1;
-#X text 184 592 Output all links length deformation speed in a list
+#X text 184 612 Output all links length deformation speed in a list
on outlet No 1;
-#X text 187 652 Put position of the 2 link end on a table [\$1] \,
+#X text 187 672 Put position of the 2 link end on a table [\$1] \,
filter on link Id is possible;
+#X msg 14 172 linkLength [\$1];
+#X text 216 174 linkLength symbolId number length;
#X restore 12 517 pd links_attributes ___;
#N canvas 157 131 997 789 dynamic 0;
#X obj 5 3 cnv 15 900 15 empty empty empty 20 12 0 14 -233017 -66577
@@ -566,7 +567,7 @@ or fixed \, in this case forces applied to them automatically \, by
links \, or manually \, by messages \, don't do anything.;
#X connect 1 0 2 0;
#X restore 18 735 pd More_Info;
-#N canvas 420 183 614 722 masses_attributes___ 0;
+#N canvas 418 188 614 722 masses_attributes___ 0;
#X obj 5 3 cnv 15 590 15 empty empty empty 20 12 0 14 -233017 -66577
0;
#X obj 7 307 cnv 15 150 100 empty empty empty 20 12 0 14 -233017 -66577
diff --git a/pmpd.c b/pmpd.c
index f70bdce..5fc12f8 100644
--- a/pmpd.c
+++ b/pmpd.c
@@ -104,6 +104,7 @@ void pmpd_setup(void)
class_addmethod(pmpd_class, (t_method)pmpd_massForce, gensym("massForce"), A_GIMME, 0);
class_addmethod(pmpd_class, (t_method)pmpd_linkPos, gensym("linkPos"), A_GIMME, 0);
class_addmethod(pmpd_class, (t_method)pmpd_linkEnd, gensym("linkEnd"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linkLength, gensym("linkLength"), A_GIMME, 0);
/*
pmpd_list
diff --git a/pmpd2d-help.pd b/pmpd2d-help.pd
index 22be33d..d5c3329 100644
--- a/pmpd2d-help.pd
+++ b/pmpd2d-help.pd
@@ -1,4 +1,4 @@
-#N canvas 281 189 572 750 10;
+#N canvas 277 199 572 750 10;
#X declare -lib Gem;
#X obj 4 309 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577
0;
@@ -383,15 +383,15 @@ pmpd object. They are of three types :;
#X text 11 19 DESCRIPTION: Physical modeling for Pd in 2d;
#X text 265 709 - Cyrille Henry 2011;
#X text 265 721 based on MSD by Nicolas Montgermont \, 2005;
-#N canvas 594 400 1169 655 links_attributes 0;
+#N canvas 586 356 1173 699 links_attributes 0;
#X obj 5 3 cnv 15 550 15 empty empty empty 20 12 0 14 -233017 -66577
0;
-#X obj 8 220 cnv 15 170 380 empty empty empty 20 12 0 14 -233017 -66577
+#X obj 8 250 cnv 15 170 380 empty empty empty 20 12 0 14 -233017 -66577
0;
-#X obj 2 199 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577
+#X obj 2 229 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577
0;
#X text 17 2 ATTRIBUTES Messages;
-#X text 15 199 Lists :;
+#X text 15 229 Lists :;
#X obj 565 26 cnv 15 190 600 empty empty empty 20 12 0 14 -233017 -66577
0;
#X obj 565 5 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577
@@ -399,20 +399,20 @@ pmpd object. They are of three types :;
#X text 785 519 \$2 (optional): Masses Id;
#X text 785 506 \$1 : table name;
#X text 578 5 tables :;
-#X text 188 253 Output all links x or y in a list on outlet No 1;
-#X msg 14 250 linkPosXL [\$1];
-#X msg 35 269 linkPosYL [\$1];
-#X msg 15 287 linkPosNormL [\$1];
-#X msg 16 321 linkLengthL [\$1];
-#X msg 16 340 linkLengthXL [\$1];
-#X msg 36 359 linkLengthYL [\$1];
-#X msg 19 414 linkPosSpeedL [\$1];
-#X msg 19 433 linkPosSpeedXL [\$1];
-#X msg 38 452 linkPosSpeedYL [\$1];
-#X msg 17 470 linkPosSpeedNormL [\$1];
-#X msg 17 510 linkLengthSpeedL [\$1];
-#X msg 17 529 linkLengthSpeedXL [\$1];
-#X msg 37 548 linkLengthSpeedYL [\$1];
+#X text 188 283 Output all links x or y in a list on outlet No 1;
+#X msg 14 280 linkPosXL [\$1];
+#X msg 35 299 linkPosYL [\$1];
+#X msg 15 317 linkPosNormL [\$1];
+#X msg 16 351 linkLengthL [\$1];
+#X msg 16 370 linkLengthXL [\$1];
+#X msg 36 389 linkLengthYL [\$1];
+#X msg 19 444 linkPosSpeedL [\$1];
+#X msg 19 463 linkPosSpeedXL [\$1];
+#X msg 38 482 linkPosSpeedYL [\$1];
+#X msg 17 500 linkPosSpeedNormL [\$1];
+#X msg 17 540 linkLengthSpeedL [\$1];
+#X msg 17 559 linkLengthSpeedXL [\$1];
+#X msg 37 578 linkLengthSpeedYL [\$1];
#X msg 575 38 linkPosT \$1 [\$2];
#X msg 575 57 linkPosXT \$1 [\$2];
#X msg 595 75 linkPosYT \$1 [\$2];
@@ -428,15 +428,15 @@ pmpd object. They are of three types :;
#X msg 574 326 linkLengthSpeedT \$1 [\$2];
#X msg 573 345 linkLengthSpeedXT \$1 [\$2];
#X msg 594 364 linkLengthSpeedYT \$1 [\$2];
-#X obj 8 88 cnv 15 170 100 empty empty empty 20 12 0 14 -233017 -66577
+#X obj 8 88 cnv 15 170 120 empty empty empty 20 12 0 14 -233017 -66577
0;
#X msg 20 96 linkPos [\$1];
#X msg 20 136 linkEnd [\$1];
#X obj 2 69 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577
0;
#X text 15 69 generic :;
-#X msg 15 377 linkLengthNormL [\$1];
-#X msg 18 567 linkLengthSpeedNormL [\$1];
+#X msg 15 407 linkLengthNormL [\$1];
+#X msg 18 597 linkLengthSpeedNormL [\$1];
#X msg 575 383 linkLengthSpeedNormT \$1 [\$2];
#X msg 577 429 linkEndT \$1 [\$2];
#X msg 589 449 linkEnd1T \$1 [\$2];
@@ -447,7 +447,7 @@ pmpd object. They are of three types :;
#X msg 589 548 linkEndYT \$1 [\$2];
#X msg 589 568 linkEnd1YT \$1 [\$2];
#X msg 589 588 linkEnd2YT \$1 [\$2];
-#X msg 14 231 linkPosL [\$1);
+#X msg 14 261 linkPosL [\$1);
#X text 212 105 linkPos symbolId number centerX centerY;
#X text 213 150 linkEnd symbolId number posX1 posY1 posX2 posY2;
#X text 784 456 table is posX1 posY1 posX2 posY2 ....;
@@ -466,26 +466,26 @@ on a table [\$1];
No 1;
#X text 768 189 Output all norm of link length vectors (sqrt(x*x+y*y))
in a list on outlet No 1;
-#X text 191 568 Output all norm of link lenght deformation speed vectors
+#X text 191 598 Output all norm of link lenght deformation speed vectors
(sqrt(x*x+y*y)) in a list on outlet No 1;
-#X text 190 534 Output all link lenghts deformation speed in x or y
+#X text 190 564 Output all link lenghts deformation speed in x or y
in a list on outlet No 1;
-#X text 190 510 Output all links lenghts deformation speed in a list
+#X text 190 540 Output all links lenghts deformation speed in a list
on outlet No 1;
-#X text 189 472 Output all norm of link center speed vectors (sqrt(x*x+y*y))
+#X text 189 502 Output all norm of link center speed vectors (sqrt(x*x+y*y))
in a list on outlet No 1;
-#X text 188 431 Output all link center speeds in x or y in a list on
+#X text 188 461 Output all link center speeds in x or y in a list on
outlet No 1;
-#X text 189 414 Output all link center speeds in a list on outlet No
+#X text 189 444 Output all link center speeds in a list on outlet No
1;
-#X text 189 377 Output all norm of link lenght vectors (sqrt(x*x+y*y))
+#X text 189 407 Output all norm of link lenght vectors (sqrt(x*x+y*y))
in a list on outlet No 1;
-#X text 188 342 Output all link lenghts in x or y in a list on outlet
+#X text 188 372 Output all link lenghts in x or y in a list on outlet
No 1;
-#X text 188 325 Output all link lenghts in a list on outlet No 1;
-#X text 188 292 Output all norm of position vectors (sqrt(x*x+y*y))
+#X text 188 355 Output all link lenghts in a list on outlet No 1;
+#X text 188 322 Output all norm of position vectors (sqrt(x*x+y*y))
in a list on outlet No 1;
-#X text 188 232 Output all link center positions in a list on outlet
+#X text 188 262 Output all link center positions in a list on outlet
No 1;
#X text 768 250 Output all link center speeds in x or y in a list on
outlet No 1;
@@ -501,7 +501,10 @@ in a list on outlet No 1;
(sqrt(x*x+y*y)) in a list on outlet No 1;
#X text 770 429 Put position of the 2 link ends on a table [\$1] \,
filter on link id is possible;
-#X text 213 173 \$1 (optional): Link Id;
+#X text 154 212 \$1 (optional): Link Id;
+#X msg 20 176 linkLength [\$1];
+#X text 184 174 output a message for every link :;
+#X text 213 190 linkLength symbolId number lengthX lengthY length;
#X restore 12 466 pd links_attributes ___;
#N canvas 276 155 935 531 creation____________ 0;
#X obj 5 75 cnv 15 450 15 empty empty empty 20 12 0 14 -158509 -66577
@@ -702,7 +705,7 @@ uses this argument as the value applied to all masses (or links);
#X restore 12 427 pd dynamic settings ___;
#X text 112 658 54_pmpd2dtest.pd;
#X obj 325 272 print;
-#N canvas 50 105 1153 632 masses_attributes___ 0;
+#N canvas 48 110 1153 632 masses_attributes___ 0;
#X obj 5 75 cnv 15 500 15 empty empty empty 20 12 0 14 -158509 -66577
0;
#X obj 5 3 cnv 15 500 15 empty empty empty 20 12 0 14 -233017 -66577
@@ -809,7 +812,7 @@ a table;
#X text 218 203 massSpeed symbolId number speedX speedY speedZ;
#X text 218 258 massForce symbolId number forceX forceY forceZ;
#X restore 12 447 pd masses_attributes___;
-#N canvas 433 489 725 566 tests 0;
+#N canvas 555 361 725 566 tests 0;
#X obj 5 3 cnv 15 700 15 empty empty empty 20 12 0 14 -233017 -66577
0;
#X text 17 2 TESTS Messages;
diff --git a/pmpd3d-help.pd b/pmpd3d-help.pd
index 0fe999e..3363b75 100644
--- a/pmpd3d-help.pd
+++ b/pmpd3d-help.pd
@@ -1,4 +1,4 @@
-#N canvas 332 144 570 717 10;
+#N canvas 330 149 570 717 10;
#X declare -lib Gem;
#X obj 4 289 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577
0;
@@ -449,7 +449,7 @@ No 1;
a list on outlet No 1;
#X text 725 518 output a series of messages :;
#X restore 12 417 pd masses_attributes __;
-#N canvas 164 124 1167 755 links_attributes 0;
+#N canvas 162 129 1167 755 links_attributes 0;
#X obj 5 3 cnv 15 550 15 empty empty empty 20 12 0 14 -233017 -66577
0;
#X obj 8 260 cnv 15 170 450 empty empty empty 20 12 0 14 -233017 -66577
@@ -502,16 +502,14 @@ a list on outlet No 1;
#X msg 573 395 linkLengthSpeedXT \$1 [\$2];
#X msg 594 414 linkLengthSpeedYT \$1 [\$2];
#X msg 595 433 linkLengthSpeedZT \$1 [\$2];
-#X obj 8 88 cnv 15 170 100 empty empty empty 20 12 0 14 -233017 -66577
+#X obj 8 88 cnv 15 170 120 empty empty empty 20 12 0 14 -233017 -66577
0;
-#X text 192 93 \$1 : id float or symbol of masses (nothing for all)
-;
-#X text 192 153 \$1 : id float or symbol of masses (nothing for all)
+#X text 121 222 \$1 : id float or symbol of masses (nothing for all)
;
#X msg 12 96 linkPos [\$1];
-#X msg 12 156 linkEnd [\$1];
-#X text 222 130 linkPos symbolId number centerX centerY centerZ;
-#X text 192 189 linkEnd symbolId number posX1 posY1 posZ1 posX2 posY2
+#X msg 12 146 linkEnd [\$1];
+#X text 217 112 linkPos symbolId number centerX centerY centerZ;
+#X text 189 160 linkEnd symbolId number posX1 posY1 posZ1 posX2 posY2
posZ2;
#X obj 2 69 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577
0;
@@ -536,8 +534,8 @@ posZ2;
#X text 15 25 The attributes messages ask the object to output some
of its internal parameters. They can be output as lists for positions
and forces of links;
-#X text 193 113 output a message for every link :;
-#X text 193 173 output a message for every link :;
+#X text 188 95 output a message for every link :;
+#X text 188 145 output a message for every link :;
#X text 188 272 Output all link center positions in a list on outlet
No 1;
#X text 184 348 Output all norm of position vectors (sqrt(x*x+y*y+z*z))
@@ -583,6 +581,10 @@ in a list on outlet No 1;
(sqrt(x*x+y*y+z*z)) in a list on outlet No 1;
#X text 770 521 Put position of the 2 link ends on a table [\$1] \,
filter on link id is possible;
+#X msg 12 186 linkLength [\$1];
+#X text 188 185 output a message for every link :;
+#X text 188 200 linkLength symbolId number lengthX lengthY lengthZ
+length;
#X restore 12 437 pd links_attributes ___;
#N canvas 26 50 901 640 More_Info 0;
#X text 96 12 pmpd : mass - spring - damper model;
diff --git a/pmpd3d.c b/pmpd3d.c
index f94ea93..fd99af2 100644
--- a/pmpd3d.c
+++ b/pmpd3d.c
@@ -119,6 +119,7 @@ void pmpd3d_setup(void)
class_addmethod(pmpd3d_class, (t_method)pmpd3d_massForce, gensym("massForce"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_linkPos, gensym("linkPos"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_linkEnd, gensym("linkEnd"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linkLength, gensym("linkLength"), A_GIMME, 0);
/*
pmpd3d_list
diff --git a/pmpd3d_get.c b/pmpd3d_get.c
index c23b594..c832aba 100644
--- a/pmpd3d_get.c
+++ b/pmpd3d_get.c
@@ -599,3 +599,68 @@ void pmpd3d_linkPos(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
+void pmpd3d_linkLength(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i;
+ t_atom toout[6];
+ t_float tmp1, tmp2, tmp3;
+
+ if ((argc>0)&&(argv[0].a_type == A_FLOAT))
+ {
+ i = atom_getfloatarg(0, argc, argv);
+ if ( (i>=0) && (i<x->nb_link) )
+ {
+ tmp1=x->link[i].mass1->posX-x->link[i].mass2->posX;
+ tmp2=x->link[i].mass1->posY-x->link[i].mass2->posY;
+ tmp3=x->link[i].mass1->posZ-x->link[i].mass3->posZ;
+
+ SETSYMBOL(&(toout[0]), x->link[i].Id);
+ SETFLOAT(&(toout[1]), i);
+ SETFLOAT(&(toout[2]), tmp1);
+ SETFLOAT(&(toout[3]), tmp2);
+ SETFLOAT(&(toout[4]), tmp3);
+ SETFLOAT(&(toout[5]), sqrt(tmp1*tmp1 + tmp2*tmp2 + tmp3*tmp3));
+ outlet_anything(x->main_outlet, gensym("linkLength"), 6, toout);
+ }
+ }
+ else
+ if ((argc>0)&&(argv[0].a_type == A_SYMBOL))
+ {
+ SETSYMBOL(&(toout[0]), atom_getsymbolarg(0,argc,argv));
+ for (i=0; i< x->nb_link; i++)
+ {
+ if ( atom_getsymbolarg(0,argc,argv) == x->link[i].Id)
+ {
+ tmp1=x->link[i].mass1->posX-x->link[i].mass2->posX;
+ tmp2=x->link[i].mass1->posY-x->link[i].mass2->posY;
+ tmp3=x->link[i].mass1->posZ-x->link[i].mass3->posZ;
+
+ SETSYMBOL(&(toout[0]), x->link[i].Id);
+ SETFLOAT(&(toout[1]), i);
+ SETFLOAT(&(toout[2]), tmp1);
+ SETFLOAT(&(toout[3]), tmp2);
+ SETFLOAT(&(toout[4]), tmp3);
+ SETFLOAT(&(toout[5]), sqrt(tmp1*tmp1 + tmp2*tmp2 + tmp3*tmp3));
+ outlet_anything(x->main_outlet, gensym("linkLength"), 6, toout);
+ }
+ }
+ }
+ else
+ if (argc == 0)
+ {
+ for (i=0; i< x->nb_link; i++)
+ {
+ tmp1=x->link[i].mass1->posX-x->link[i].mass2->posX;
+ tmp2=x->link[i].mass1->posY-x->link[i].mass2->posY;
+ tmp3=x->link[i].mass1->posZ-x->link[i].mass3->posZ;
+
+ SETSYMBOL(&(toout[0]), x->link[i].Id);
+ SETFLOAT(&(toout[1]), i);
+ SETFLOAT(&(toout[2]), tmp1);
+ SETFLOAT(&(toout[3]), tmp2);
+ SETFLOAT(&(toout[4]), tmp3);
+ SETFLOAT(&(toout[5]), sqrt(tmp1*tmp1 + tmp2*tmp2 + tmp3*tmp3));
+ outlet_anything(x->main_outlet, gensym("linkLength"), 6, toout);
+ }
+ }
+}
diff --git a/pmpd_get.c b/pmpd_get.c
index 51759d6..361cd89 100644
--- a/pmpd_get.c
+++ b/pmpd_get.c
@@ -503,3 +503,48 @@ void pmpd_linkPos(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
+
+void pmpd_linkLength(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i;
+ t_atom toout[3];
+
+ if ((argc>0)&&(argv[0].a_type == A_FLOAT))
+ {
+ i = atom_getfloatarg(0, argc, argv);
+ if ( (i>=0) && (i<x->nb_link) )
+ {
+ SETSYMBOL(&(toout[0]), x->link[i].Id);
+ SETFLOAT(&(toout[1]), i);
+ SETFLOAT(&(toout[2]), x->link[i].mass1->posX-x->link[i].mass2->posX);
+ outlet_anything(x->main_outlet, gensym("linkLength"), 3, toout);
+ }
+ }
+ else
+ if ((argc>0)&&(argv[0].a_type == A_SYMBOL))
+ {
+ SETSYMBOL(&(toout[0]), atom_getsymbolarg(0,argc,argv));
+ for (i=0; i< x->nb_link; i++)
+ {
+ if ( atom_getsymbolarg(0,argc,argv) == x->link[i].Id)
+ {
+ SETSYMBOL(&(toout[0]), x->link[i].Id);
+ SETFLOAT(&(toout[1]), i);
+ SETFLOAT(&(toout[2]), x->link[i].mass1->posX-x->link[i].mass2->posX);
+ outlet_anything(x->main_outlet, gensym("linkLength"), 3, toout);
+ }
+ }
+ }
+ else
+ if (argc == 0)
+ {
+ for (i=0; i< x->nb_link; i++)
+ {
+ SETSYMBOL(&(toout[0]), x->link[i].Id);
+ SETFLOAT(&(toout[1]), i);
+ SETFLOAT(&(toout[2]), x->link[i].mass1->posX-x->link[i].mass2->posX);
+ outlet_anything(x->main_outlet, gensym("linkLength"), 3, toout);
+ }
+ }
+}
+