aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Henry <nusmuk@users.sourceforge.net>2014-05-25 15:50:54 +0000
committerCyrille Henry <nusmuk@users.sourceforge.net>2014-05-25 15:50:54 +0000
commit6395184c7d0180c4defbe3f8efae8ee0e67b57da (patch)
treee9c6746e46e394499dbf8a7d5d8b202bccfb507c
parentd061c2c746c0ecb5f5c6d19b8794edbd4c1bd00c (diff)
add massInfo and linkInfo messages
svn path=/trunk/externals/pmpd/; revision=17315
-rw-r--r--pmpd.c2
-rw-r--r--pmpd2d-help.pd8
-rw-r--r--pmpd2d.c3
-rw-r--r--pmpd2d_stat.c213
-rw-r--r--pmpd3d.c2
-rw-r--r--pmpd3d_stat.c224
-rw-r--r--pmpd_stat.c176
7 files changed, 625 insertions, 3 deletions
diff --git a/pmpd.c b/pmpd.c
index d22fc05..2d3e013 100644
--- a/pmpd.c
+++ b/pmpd.c
@@ -204,6 +204,8 @@ void pmpd_setup(void)
class_addmethod(pmpd_class, (t_method)pmpd_linkPosSpeedStd, gensym("linkPosSpeedStd"), A_GIMME, 0);
class_addmethod(pmpd_class, (t_method)pmpd_linkLengthSpeedStd, gensym("linkLengthSpeedStd"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_massInfo, gensym("massInfo"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linkInfo, gensym("linkInfo"), A_GIMME, 0);
/*
pmpd_various
diff --git a/pmpd2d-help.pd b/pmpd2d-help.pd
index 434c9dc..7458659 100644
--- a/pmpd2d-help.pd
+++ b/pmpd2d-help.pd
@@ -1,4 +1,4 @@
-#N canvas 287 174 572 750 10;
+#N canvas 285 179 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;
@@ -809,7 +809,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 435 485 725 566 tests 0;
+#N canvas 433 489 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;
@@ -900,7 +900,7 @@ the pm world (Xmin \, Xmax \, Ymin \, Ymax);
;
#X text 307 171 create a one time spacial interaction on masses;
#X restore 12 505 pd interactors ________;
-#N canvas 1058 327 589 534 statistics 0;
+#N canvas 892 284 589 534 statistics 0;
#X obj -126 50 cnv 15 150 170 empty empty empty 20 12 0 14 -233017
-66577 0;
#X obj -125 30 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577
@@ -954,6 +954,8 @@ Norm);
#X obj -125 6 cnv 15 550 15 empty empty empty 20 12 0 14 -233017 -66577
0;
#X text -113 5 STATISTICS Messages;
+#X msg -120 213 massInfo \$1;
+#X msg -118 508 linkInfo \$1;
#X restore 12 525 pd statistics _________;
#X text 164 507 To send complex forces;
#X text 163 526 To get statistical data of the simulation;
diff --git a/pmpd2d.c b/pmpd2d.c
index 4d71b19..013c29b 100644
--- a/pmpd2d.c
+++ b/pmpd2d.c
@@ -269,6 +269,9 @@ void pmpd2d_setup(void)
class_addmethod(pmpd2d_class, (t_method)pmpd2d_linkPosSpeedStd, gensym("linkPosSpeedStd"), A_GIMME, 0);
class_addmethod(pmpd2d_class, (t_method)pmpd2d_linkLengthSpeedStd, gensym("linkLengthSpeedStd"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_massInfo, gensym("massInfo"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linkInfo, gensym("linkInfo"), A_GIMME, 0);
+
/*
pmpd2d_interactor
--
diff --git a/pmpd2d_stat.c b/pmpd2d_stat.c
index da4df05..260b14d 100644
--- a/pmpd2d_stat.c
+++ b/pmpd2d_stat.c
@@ -889,3 +889,216 @@ void pmpd2d_linkLengthSpeedStd(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
outlet_anything(x->main_outlet, gensym("linkLengthSpeedStd"),3 , std_out);
}
+void pmpd2d_massInfo(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_atom info[11];
+ int i, j;
+
+ if (argc==0)
+ {
+ for(i=0; i < x->nb_mass; i++)
+ {
+ SETFLOAT(&(info[0]), i);
+ SETSYMBOL(&(info[1]), x->mass[i].Id);
+ SETFLOAT(&(info[2]), x->mass[i].mobile);
+ SETFLOAT(&(info[3]), 1/x->mass[i].invM);
+ SETFLOAT(&(info[4]), x->mass[i].D2);
+ SETFLOAT(&(info[5]), x->mass[i].posX);
+ SETFLOAT(&(info[6]), x->mass[i].posY);
+ SETFLOAT(&(info[7]), x->mass[i].speedX);
+ SETFLOAT(&(info[8]), x->mass[i].speedY);
+ SETFLOAT(&(info[9]), x->mass[i].forceX);
+ SETFLOAT(&(info[10]), x->mass[i].forceY);
+ outlet_anything(x->main_outlet, gensym("massInfo"), 11, info);
+ }
+ SETFLOAT(&(info[0]), x->nb_mass);
+ outlet_anything(x->main_outlet, gensym("massNumber"), 1, info);
+ }
+ else if ((argc==1) && (argv[0].a_type == A_SYMBOL))
+ {
+ j=0;
+ for(i=0; i < x->nb_mass; i++)
+ {
+ if (atom_getsymbolarg(0,argc,argv) == x->mass[j].Id)
+ {
+ SETFLOAT(&(info[0]), i);
+ SETSYMBOL(&(info[1]), x->mass[i].Id);
+ SETFLOAT(&(info[2]), x->mass[i].mobile);
+ SETFLOAT(&(info[3]), 1/(x->mass[i].invM));
+ SETFLOAT(&(info[4]), x->mass[i].D2);
+ SETFLOAT(&(info[5]), x->mass[i].posX);
+ SETFLOAT(&(info[6]), x->mass[i].posY);
+ SETFLOAT(&(info[7]), x->mass[i].speedX);
+ SETFLOAT(&(info[8]), x->mass[i].speedY);
+ SETFLOAT(&(info[9]), x->mass[i].forceX);
+ SETFLOAT(&(info[10]), x->mass[i].forceY);
+ outlet_anything(x->main_outlet, gensym("massInfo"), 11, info);
+ j++;
+ }
+ }
+ SETFLOAT(&(info[0]), j);
+ outlet_anything(x->main_outlet, gensym("massNumber"), 1, info);
+ }
+ else if ((argc==1) && (argv[0].a_type == A_FLOAT))
+ {
+ i=(int)atom_getfloatarg(0, argc, argv);
+ i=max(i,0);
+ i=min(i,x->nb_mass-1);
+
+ SETFLOAT(&(info[0]), i);
+ SETSYMBOL(&(info[1]), x->mass[i].Id);
+ SETFLOAT(&(info[2]), x->mass[i].mobile);
+ SETFLOAT(&(info[3]), 1/x->mass[i].invM);
+ SETFLOAT(&(info[4]), x->mass[i].D2);
+ SETFLOAT(&(info[5]), x->mass[i].posX);
+ SETFLOAT(&(info[6]), x->mass[i].posY);
+ SETFLOAT(&(info[7]), x->mass[i].speedX);
+ SETFLOAT(&(info[8]), x->mass[i].speedY);
+ SETFLOAT(&(info[9]), x->mass[i].forceX);
+ SETFLOAT(&(info[10]), x->mass[i].forceY);
+ outlet_anything(x->main_outlet, gensym("massInfo"), 11, info);
+ }
+}
+
+void pmpd2d_linkInfo(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_atom info[14];
+ int i, j, k;
+
+ if (argc==0)
+ {
+ for(i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(info[1]), i);
+ SETSYMBOL(&(info[2]), x->link[i].Id);
+ SETFLOAT(&(info[3]), x->link[i].active);
+ SETFLOAT(&(info[4]), x->link[i].mass1->num);
+ SETFLOAT(&(info[5]), x->link[i].mass2->num);
+ SETFLOAT(&(info[6]), x->link[i].K);
+ SETFLOAT(&(info[7]), x->link[i].D);
+
+ switch(x->link[i].lType)
+ {
+ case 0 :
+ SETSYMBOL(&(info[0]), gensym("link"));
+ SETFLOAT(&(info[8]), x->link[i].Pow);
+ SETFLOAT(&(info[9]), x->link[i].L);
+ SETFLOAT(&(info[10]), x->link[i].Lmin);
+ SETFLOAT(&(info[11]), x->link[i].Lmax);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
+ break;
+ case 1 :
+ SETSYMBOL(&(info[0]), gensym("tLink"));
+ SETFLOAT(&(info[8]), x->link[i].Pow);
+ SETFLOAT(&(info[9]), x->link[i].L);
+ SETFLOAT(&(info[10]), x->link[i].Lmin);
+ SETFLOAT(&(info[11]), x->link[i].Lmax);
+ SETFLOAT(&(info[12]), x->link[i].VX);
+ SETFLOAT(&(info[13]), x->link[i].VY);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 14, info);
+ break;
+ case 2 :
+ SETSYMBOL(&(info[0]), gensym("tabLink"));
+ SETSYMBOL(&(info[8]), x->link[i].arrayK);
+ SETFLOAT(&(info[9]), x->link[i].K_L);
+ SETSYMBOL(&(info[10]), x->link[i].arrayD);
+ SETFLOAT(&(info[11]), x->link[i].D_L);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
+ }
+ }
+ SETFLOAT(&(info[0]), x->nb_link);
+ outlet_anything(x->main_outlet, gensym("linkNumber"), 1, info);
+ }
+ else if ((argc==1) && (argv[0].a_type == A_SYMBOL))
+ {
+ j=0;
+ for(i=0; i < x->nb_link; i++)
+ {
+ if (atom_getsymbolarg(0,argc,argv) == x->link[j].Id)
+ {
+ SETFLOAT(&(info[1]), i);
+ SETSYMBOL(&(info[2]), x->link[i].Id);
+ SETFLOAT(&(info[3]), x->link[i].active);
+ SETFLOAT(&(info[4]), x->link[i].mass1->num);
+ SETFLOAT(&(info[5]), x->link[i].mass2->num);
+ SETFLOAT(&(info[6]), x->link[i].K);
+ SETFLOAT(&(info[7]), x->link[i].D);
+
+ switch(x->link[i].lType)
+ {
+ case 0 :
+ SETSYMBOL(&(info[0]), gensym("link"));
+ SETFLOAT(&(info[8]), x->link[i].Pow);
+ SETFLOAT(&(info[9]), x->link[i].L);
+ SETFLOAT(&(info[10]), x->link[i].Lmin);
+ SETFLOAT(&(info[11]), x->link[i].Lmax);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
+ break;
+ case 1 :
+ SETSYMBOL(&(info[0]), gensym("tLink"));
+ SETFLOAT(&(info[8]), x->link[i].Pow);
+ SETFLOAT(&(info[9]), x->link[i].L);
+ SETFLOAT(&(info[10]), x->link[i].Lmin);
+ SETFLOAT(&(info[11]), x->link[i].Lmax);
+ SETFLOAT(&(info[12]), x->link[i].VX);
+ SETFLOAT(&(info[13]), x->link[i].VY);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 14, info);
+ break;
+ case 2 :
+ SETSYMBOL(&(info[0]), gensym("tabLink"));
+ SETSYMBOL(&(info[8]), x->link[i].arrayK);
+ SETFLOAT(&(info[9]), x->link[i].K_L);
+ SETSYMBOL(&(info[10]), x->link[i].arrayD);
+ SETFLOAT(&(info[11]), x->link[i].D_L);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
+ }
+ }
+ j++;
+ }
+ SETFLOAT(&(info[0]), j);
+ outlet_anything(x->main_outlet, gensym("linkNumber"), 1, info);
+ }
+ else if ((argc==1) && (argv[0].a_type == A_FLOAT))
+ {
+ i=(int)atom_getfloatarg(0, argc, argv);
+ i=max(i,0);
+ i=min(i,x->nb_link-1);
+
+ SETFLOAT(&(info[1]), i);
+ SETSYMBOL(&(info[2]), x->link[i].Id);
+ SETFLOAT(&(info[3]), x->link[i].active);
+ SETFLOAT(&(info[4]), x->link[i].mass1->num);
+ SETFLOAT(&(info[5]), x->link[i].mass2->num);
+ SETFLOAT(&(info[6]), x->link[i].K);
+ SETFLOAT(&(info[7]), x->link[i].D);
+
+ switch(x->link[i].lType)
+ {
+ case 0 :
+ SETSYMBOL(&(info[0]), gensym("link"));
+ SETFLOAT(&(info[8]), x->link[i].Pow);
+ SETFLOAT(&(info[9]), x->link[i].L);
+ SETFLOAT(&(info[10]), x->link[i].Lmin);
+ SETFLOAT(&(info[11]), x->link[i].Lmax);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
+ break;
+ case 1 :
+ SETSYMBOL(&(info[0]), gensym("tLink"));
+ SETFLOAT(&(info[8]), x->link[i].Pow);
+ SETFLOAT(&(info[9]), x->link[i].L);
+ SETFLOAT(&(info[10]), x->link[i].Lmin);
+ SETFLOAT(&(info[11]), x->link[i].Lmax);
+ SETFLOAT(&(info[12]), x->link[i].VX);
+ SETFLOAT(&(info[13]), x->link[i].VY);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 14, info);
+ break;
+ case 2 :
+ SETSYMBOL(&(info[0]), gensym("tabLink"));
+ SETSYMBOL(&(info[8]), x->link[i].arrayK);
+ SETFLOAT(&(info[9]), x->link[i].K_L);
+ SETSYMBOL(&(info[10]), x->link[i].arrayD);
+ SETFLOAT(&(info[11]), x->link[i].D_L);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
+ }
+ }
+}
diff --git a/pmpd3d.c b/pmpd3d.c
index bbd5ccc..38fefb1 100644
--- a/pmpd3d.c
+++ b/pmpd3d.c
@@ -298,6 +298,8 @@ void pmpd3d_setup(void)
class_addmethod(pmpd3d_class, (t_method)pmpd3d_linkPosSpeedStd, gensym("linkPosSpeedStd"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_linkLengthSpeedStd, gensym("linkLengthSpeedStd"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massInfo, gensym("massInfo"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linkInfo, gensym("linkInfo"), A_GIMME, 0);
/*
pmpd3d_interactor
--
diff --git a/pmpd3d_stat.c b/pmpd3d_stat.c
index 6f25cbe..3e03c05 100644
--- a/pmpd3d_stat.c
+++ b/pmpd3d_stat.c
@@ -1023,3 +1023,227 @@ void pmpd3d_linkLengthSpeedStd(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
outlet_anything(x->main_outlet, gensym("linkLengthSpeedStd"),4 , std_out);
}
+
+
+void pmpd3d_massInfo(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_atom info[14];
+ int i, j;
+
+ if (argc==0)
+ {
+ for(i=0; i < x->nb_mass; i++)
+ {
+ SETFLOAT(&(info[0]), i);
+ SETSYMBOL(&(info[1]), x->mass[i].Id);
+ SETFLOAT(&(info[2]), x->mass[i].mobile);
+ SETFLOAT(&(info[3]), 1/x->mass[i].invM);
+ SETFLOAT(&(info[4]), x->mass[i].D2);
+ SETFLOAT(&(info[5]), x->mass[i].posX);
+ SETFLOAT(&(info[6]), x->mass[i].posY);
+ SETFLOAT(&(info[7]), x->mass[i].posZ);
+ SETFLOAT(&(info[8]), x->mass[i].speedX);
+ SETFLOAT(&(info[9]), x->mass[i].speedY);
+ SETFLOAT(&(info[10]), x->mass[i].speedZ);
+ SETFLOAT(&(info[11]), x->mass[i].forceX);
+ SETFLOAT(&(info[12]), x->mass[i].forceY);
+ SETFLOAT(&(info[13]), x->mass[i].forceZ);
+ outlet_anything(x->main_outlet, gensym("massInfo"), 14, info);
+ }
+ SETFLOAT(&(info[0]), x->nb_mass);
+ outlet_anything(x->main_outlet, gensym("massNumber"), 1, info);
+ }
+ else if ((argc==1) && (argv[0].a_type == A_SYMBOL))
+ {
+ j=0;
+ for(i=0; i < x->nb_mass; i++)
+ {
+ if (atom_getsymbolarg(0,argc,argv) == x->mass[j].Id)
+ {
+ SETFLOAT(&(info[0]), i);
+ SETSYMBOL(&(info[1]), x->mass[i].Id);
+ SETFLOAT(&(info[2]), x->mass[i].mobile);
+ SETFLOAT(&(info[3]), 1/x->mass[i].invM);
+ SETFLOAT(&(info[4]), x->mass[i].D2);
+ SETFLOAT(&(info[5]), x->mass[i].posX);
+ SETFLOAT(&(info[6]), x->mass[i].posY);
+ SETFLOAT(&(info[7]), x->mass[i].posZ);
+ SETFLOAT(&(info[8]), x->mass[i].speedX);
+ SETFLOAT(&(info[9]), x->mass[i].speedY);
+ SETFLOAT(&(info[10]), x->mass[i].speedZ);
+ SETFLOAT(&(info[11]), x->mass[i].forceX);
+ SETFLOAT(&(info[12]), x->mass[i].forceY);
+ SETFLOAT(&(info[13]), x->mass[i].forceZ);
+ outlet_anything(x->main_outlet, gensym("massInfo"), 14, info);
+ j++;
+ }
+ }
+ SETFLOAT(&(info[0]), j);
+ outlet_anything(x->main_outlet, gensym("massNumber"), 1, info);
+ }
+ else if ((argc==1) && (argv[0].a_type == A_FLOAT))
+ {
+ i=(int)atom_getfloatarg(0, argc, argv);
+ i=max(i,0);
+ i=min(i,x->nb_mass-1);
+
+ SETFLOAT(&(info[0]), i);
+ SETSYMBOL(&(info[1]), x->mass[i].Id);
+ SETFLOAT(&(info[2]), x->mass[i].mobile);
+ SETFLOAT(&(info[3]), 1/x->mass[i].invM);
+ SETFLOAT(&(info[4]), x->mass[i].D2);
+ SETFLOAT(&(info[5]), x->mass[i].posX);
+ SETFLOAT(&(info[6]), x->mass[i].posY);
+ SETFLOAT(&(info[7]), x->mass[i].posZ);
+ SETFLOAT(&(info[8]), x->mass[i].speedX);
+ SETFLOAT(&(info[9]), x->mass[i].speedY);
+ SETFLOAT(&(info[10]), x->mass[i].speedZ);
+ SETFLOAT(&(info[11]), x->mass[i].forceX);
+ SETFLOAT(&(info[12]), x->mass[i].forceY);
+ SETFLOAT(&(info[13]), x->mass[i].forceZ);
+ outlet_anything(x->main_outlet, gensym("massInfo"), 14, info);
+ }
+}
+
+void pmpd3d_linkInfo(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_atom info[14];
+ int i, j, k;
+
+ if (argc==0)
+ {
+ for(i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(info[1]), i);
+ SETSYMBOL(&(info[2]), x->link[i].Id);
+ SETFLOAT(&(info[3]), x->link[i].active);
+ SETFLOAT(&(info[4]), x->link[i].mass1->num);
+ SETFLOAT(&(info[5]), x->link[i].mass2->num);
+ SETFLOAT(&(info[6]), x->link[i].K);
+ SETFLOAT(&(info[7]), x->link[i].D);
+
+ switch(x->link[i].lType)
+ {
+ case 0 :
+ SETSYMBOL(&(info[0]), gensym("link"));
+ SETFLOAT(&(info[8]), x->link[i].Pow);
+ SETFLOAT(&(info[9]), x->link[i].L);
+ SETFLOAT(&(info[10]), x->link[i].Lmin);
+ SETFLOAT(&(info[11]), x->link[i].Lmax);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
+ break;
+ case 1 :
+ SETSYMBOL(&(info[0]), gensym("tLink"));
+ SETFLOAT(&(info[8]), x->link[i].Pow);
+ SETFLOAT(&(info[9]), x->link[i].L);
+ SETFLOAT(&(info[10]), x->link[i].Lmin);
+ SETFLOAT(&(info[11]), x->link[i].Lmax);
+ SETFLOAT(&(info[12]), x->link[i].VX);
+ SETFLOAT(&(info[13]), x->link[i].VY);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 14, info);
+ break;
+ case 2 :
+ SETSYMBOL(&(info[0]), gensym("tabLink"));
+ SETSYMBOL(&(info[8]), x->link[i].arrayK);
+ SETFLOAT(&(info[9]), x->link[i].K_L);
+ SETSYMBOL(&(info[10]), x->link[i].arrayD);
+ SETFLOAT(&(info[11]), x->link[i].D_L);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
+ }
+ }
+ SETFLOAT(&(info[0]), x->nb_link);
+ outlet_anything(x->main_outlet, gensym("linkNumber"), 1, info);
+ }
+ else if ((argc==1) && (argv[0].a_type == A_SYMBOL))
+ {
+ j=0;
+ for(i=0; i < x->nb_link; i++)
+ {
+ if (atom_getsymbolarg(0,argc,argv) == x->link[j].Id)
+ {
+ SETFLOAT(&(info[1]), i);
+ SETSYMBOL(&(info[2]), x->link[i].Id);
+ SETFLOAT(&(info[3]), x->link[i].active);
+ SETFLOAT(&(info[4]), x->link[i].mass1->num);
+ SETFLOAT(&(info[5]), x->link[i].mass2->num);
+ SETFLOAT(&(info[6]), x->link[i].K);
+ SETFLOAT(&(info[7]), x->link[i].D);
+
+ switch(x->link[i].lType)
+ {
+ case 0 :
+ SETSYMBOL(&(info[0]), gensym("link"));
+ SETFLOAT(&(info[8]), x->link[i].Pow);
+ SETFLOAT(&(info[9]), x->link[i].L);
+ SETFLOAT(&(info[10]), x->link[i].Lmin);
+ SETFLOAT(&(info[11]), x->link[i].Lmax);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
+ break;
+ case 1 :
+ SETSYMBOL(&(info[0]), gensym("tLink"));
+ SETFLOAT(&(info[8]), x->link[i].Pow);
+ SETFLOAT(&(info[9]), x->link[i].L);
+ SETFLOAT(&(info[10]), x->link[i].Lmin);
+ SETFLOAT(&(info[11]), x->link[i].Lmax);
+ SETFLOAT(&(info[12]), x->link[i].VX);
+ SETFLOAT(&(info[13]), x->link[i].VY);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 14, info);
+ break;
+ case 2 :
+ SETSYMBOL(&(info[0]), gensym("tabLink"));
+ SETSYMBOL(&(info[8]), x->link[i].arrayK);
+ SETFLOAT(&(info[9]), x->link[i].K_L);
+ SETSYMBOL(&(info[10]), x->link[i].arrayD);
+ SETFLOAT(&(info[11]), x->link[i].D_L);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
+ }
+ }
+ j++;
+ }
+ SETFLOAT(&(info[0]), j);
+ outlet_anything(x->main_outlet, gensym("linkNumber"), 1, info);
+ }
+ else if ((argc==1) && (argv[0].a_type == A_FLOAT))
+ {
+ i=(int)atom_getfloatarg(0, argc, argv);
+ i=max(i,0);
+ i=min(i,x->nb_link-1);
+
+ SETFLOAT(&(info[1]), i);
+ SETSYMBOL(&(info[2]), x->link[i].Id);
+ SETFLOAT(&(info[3]), x->link[i].active);
+ SETFLOAT(&(info[4]), x->link[i].mass1->num);
+ SETFLOAT(&(info[5]), x->link[i].mass2->num);
+ SETFLOAT(&(info[6]), x->link[i].K);
+ SETFLOAT(&(info[7]), x->link[i].D);
+
+ switch(x->link[i].lType)
+ {
+ case 0 :
+ SETSYMBOL(&(info[0]), gensym("link"));
+ SETFLOAT(&(info[8]), x->link[i].Pow);
+ SETFLOAT(&(info[9]), x->link[i].L);
+ SETFLOAT(&(info[10]), x->link[i].Lmin);
+ SETFLOAT(&(info[11]), x->link[i].Lmax);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
+ break;
+ case 1 :
+ SETSYMBOL(&(info[0]), gensym("tLink"));
+ SETFLOAT(&(info[8]), x->link[i].Pow);
+ SETFLOAT(&(info[9]), x->link[i].L);
+ SETFLOAT(&(info[10]), x->link[i].Lmin);
+ SETFLOAT(&(info[11]), x->link[i].Lmax);
+ SETFLOAT(&(info[12]), x->link[i].VX);
+ SETFLOAT(&(info[13]), x->link[i].VY);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 14, info);
+ break;
+ case 2 :
+ SETSYMBOL(&(info[0]), gensym("tabLink"));
+ SETSYMBOL(&(info[8]), x->link[i].arrayK);
+ SETFLOAT(&(info[9]), x->link[i].K_L);
+ SETSYMBOL(&(info[10]), x->link[i].arrayD);
+ SETFLOAT(&(info[11]), x->link[i].D_L);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
+ }
+ }
+}
diff --git a/pmpd_stat.c b/pmpd_stat.c
index aceb5a8..f41a956 100644
--- a/pmpd_stat.c
+++ b/pmpd_stat.c
@@ -678,3 +678,179 @@ void pmpd_linkLengthSpeedStd(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
SETFLOAT(&(std_out[0]),stdX);
outlet_anything(x->main_outlet, gensym("linkLengthSpeedStd"),1 , std_out);
}
+
+
+void pmpd_massInfo(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_atom info[8];
+ int i, j;
+
+ if (argc==0)
+ {
+ for(i=0; i < x->nb_mass; i++)
+ {
+ SETFLOAT(&(info[0]), i);
+ SETSYMBOL(&(info[1]), x->mass[i].Id);
+ SETFLOAT(&(info[2]), x->mass[i].mobile);
+ SETFLOAT(&(info[3]), 1/x->mass[i].invM);
+ SETFLOAT(&(info[4]), x->mass[i].D2);
+ SETFLOAT(&(info[5]), x->mass[i].posX);
+ SETFLOAT(&(info[6]), x->mass[i].speedX);
+ SETFLOAT(&(info[7]), x->mass[i].forceX);
+ outlet_anything(x->main_outlet, gensym("massInfo"), 8, info);
+ }
+ SETFLOAT(&(info[0]), x->nb_mass);
+ outlet_anything(x->main_outlet, gensym("massNumber"), 1, info);
+ }
+ else if ((argc==1) && (argv[0].a_type == A_SYMBOL))
+ {
+ j=0;
+ for(i=0; i < x->nb_mass; i++)
+ {
+ if (atom_getsymbolarg(0,argc,argv) == x->mass[j].Id)
+ {
+ SETFLOAT(&(info[0]), i);
+ SETSYMBOL(&(info[1]), x->mass[i].Id);
+ SETFLOAT(&(info[2]), x->mass[i].mobile);
+ SETFLOAT(&(info[3]), 1/x->mass[i].invM);
+ SETFLOAT(&(info[4]), x->mass[i].D2);
+ SETFLOAT(&(info[5]), x->mass[i].posX);
+ SETFLOAT(&(info[6]), x->mass[i].speedX);
+ SETFLOAT(&(info[7]), x->mass[i].forceX);
+ outlet_anything(x->main_outlet, gensym("massInfo"), 8, info);
+ j++;
+ }
+ }
+ SETFLOAT(&(info[0]), j);
+ outlet_anything(x->main_outlet, gensym("massNumber"), 1, info);
+ }
+ else if ((argc==1) && (argv[0].a_type == A_FLOAT))
+ {
+ i=(int)atom_getfloatarg(0, argc, argv);
+ i=max(i,0);
+ i=min(i,x->nb_mass-1);
+
+ SETFLOAT(&(info[0]), i);
+ SETSYMBOL(&(info[1]), x->mass[i].Id);
+ SETFLOAT(&(info[2]), x->mass[i].mobile);
+ SETFLOAT(&(info[3]), 1/x->mass[i].invM);
+ SETFLOAT(&(info[4]), x->mass[i].D2);
+ SETFLOAT(&(info[5]), x->mass[i].posX);
+ SETFLOAT(&(info[6]), x->mass[i].speedX);
+ SETFLOAT(&(info[7]), x->mass[i].forceX);
+ outlet_anything(x->main_outlet, gensym("massInfo"), 8, info);
+ }
+}
+
+void pmpd_linkInfo(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_atom info[14];
+ int i, j, k;
+
+ if (argc==0)
+ {
+ for(i=0; i < x->nb_link; i++)
+ {
+ SETFLOAT(&(info[1]), i);
+ SETSYMBOL(&(info[2]), x->link[i].Id);
+ SETFLOAT(&(info[3]), x->link[i].active);
+ SETFLOAT(&(info[4]), x->link[i].mass1->num);
+ SETFLOAT(&(info[5]), x->link[i].mass2->num);
+ SETFLOAT(&(info[6]), x->link[i].K);
+ SETFLOAT(&(info[7]), x->link[i].D);
+
+ switch(x->link[i].lType)
+ {
+ case 0 :
+ SETSYMBOL(&(info[0]), gensym("link"));
+ SETFLOAT(&(info[8]), x->link[i].Pow);
+ SETFLOAT(&(info[9]), x->link[i].L);
+ SETFLOAT(&(info[10]), x->link[i].Lmin);
+ SETFLOAT(&(info[11]), x->link[i].Lmax);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
+ break;
+ case 2 :
+ SETSYMBOL(&(info[0]), gensym("tabLink"));
+ SETSYMBOL(&(info[8]), x->link[i].arrayK);
+ SETFLOAT(&(info[9]), x->link[i].K_L);
+ SETSYMBOL(&(info[10]), x->link[i].arrayD);
+ SETFLOAT(&(info[11]), x->link[i].D_L);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
+ }
+ }
+ SETFLOAT(&(info[0]), x->nb_link);
+ outlet_anything(x->main_outlet, gensym("linkNumber"), 1, info);
+ }
+ else if ((argc==1) && (argv[0].a_type == A_SYMBOL))
+ {
+ j=0;
+ for(i=0; i < x->nb_link; i++)
+ {
+ if (atom_getsymbolarg(0,argc,argv) == x->link[j].Id)
+ {
+ SETFLOAT(&(info[1]), i);
+ SETSYMBOL(&(info[2]), x->link[i].Id);
+ SETFLOAT(&(info[3]), x->link[i].active);
+ SETFLOAT(&(info[4]), x->link[i].mass1->num);
+ SETFLOAT(&(info[5]), x->link[i].mass2->num);
+ SETFLOAT(&(info[6]), x->link[i].K);
+ SETFLOAT(&(info[7]), x->link[i].D);
+
+ switch(x->link[i].lType)
+ {
+ case 0 :
+ SETSYMBOL(&(info[0]), gensym("link"));
+ SETFLOAT(&(info[8]), x->link[i].Pow);
+ SETFLOAT(&(info[9]), x->link[i].L);
+ SETFLOAT(&(info[10]), x->link[i].Lmin);
+ SETFLOAT(&(info[11]), x->link[i].Lmax);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
+ break;
+ case 2 :
+ SETSYMBOL(&(info[0]), gensym("tabLink"));
+ SETSYMBOL(&(info[8]), x->link[i].arrayK);
+ SETFLOAT(&(info[9]), x->link[i].K_L);
+ SETSYMBOL(&(info[10]), x->link[i].arrayD);
+ SETFLOAT(&(info[11]), x->link[i].D_L);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
+ }
+ }
+ j++;
+ }
+ SETFLOAT(&(info[0]), j);
+ outlet_anything(x->main_outlet, gensym("linkNumber"), 1, info);
+ }
+ else if ((argc==1) && (argv[0].a_type == A_FLOAT))
+ {
+ i=(int)atom_getfloatarg(0, argc, argv);
+ i=max(i,0);
+ i=min(i,x->nb_link-1);
+
+ SETFLOAT(&(info[1]), i);
+ SETSYMBOL(&(info[2]), x->link[i].Id);
+ SETFLOAT(&(info[3]), x->link[i].active);
+ SETFLOAT(&(info[4]), x->link[i].mass1->num);
+ SETFLOAT(&(info[5]), x->link[i].mass2->num);
+ SETFLOAT(&(info[6]), x->link[i].K);
+ SETFLOAT(&(info[7]), x->link[i].D);
+
+ switch(x->link[i].lType)
+ {
+ case 0 :
+ SETSYMBOL(&(info[0]), gensym("link"));
+ SETFLOAT(&(info[8]), x->link[i].Pow);
+ SETFLOAT(&(info[9]), x->link[i].L);
+ SETFLOAT(&(info[10]), x->link[i].Lmin);
+ SETFLOAT(&(info[11]), x->link[i].Lmax);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
+ break;
+ case 2 :
+ SETSYMBOL(&(info[0]), gensym("tabLink"));
+ SETSYMBOL(&(info[8]), x->link[i].arrayK);
+ SETFLOAT(&(info[9]), x->link[i].K_L);
+ SETSYMBOL(&(info[10]), x->link[i].arrayD);
+ SETFLOAT(&(info[11]), x->link[i].D_L);
+ outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
+ }
+ }
+}