diff options
author | Cyrille Henry <nusmuk@users.sourceforge.net> | 2013-02-11 16:57:35 +0000 |
---|---|---|
committer | Cyrille Henry <nusmuk@users.sourceforge.net> | 2013-02-11 16:57:35 +0000 |
commit | 7f927c2f4a64c883eaab73472291c8aed2d769a8 (patch) | |
tree | a3ee0828e3d3f9fe7bb6b7fd013351cff0644363 | |
parent | c6e20af88d58602d44e5eefcf72a690265c4f616 (diff) |
lot's of new features...
svn path=/trunk/externals/pmpd/; revision=17031
-rw-r--r-- | pmpd3d.c | 348 | ||||
-rw-r--r-- | pmpd3d_get.c | 162 | ||||
-rw-r--r-- | pmpd3d_interactor.c | 203 | ||||
-rw-r--r-- | pmpd3d_set.c | 27 | ||||
-rw-r--r-- | pmpd3d_stat.c | 564 | ||||
-rw-r--r-- | pmpd3d_tab.c | 572 | ||||
-rw-r--r-- | pmpd3d_test.c | 446 | ||||
-rw-r--r-- | pmpd3d_various.c | 257 |
8 files changed, 2073 insertions, 506 deletions
@@ -26,6 +26,8 @@ ----------------------------------------------------------------------------
*/
+
+
#include "m_pd.h"
#include "stdio.h"
#include "math.h"
@@ -36,8 +38,10 @@ #include "pmpd3d_get.c"
#include "pmpd3d_list.c"
#include "pmpd3d_tab.c"
-#include "pmpd3d_various.c"
+#include "pmpd3d_test.c"
#include "pmpd3d_stat.c"
+#include "pmpd3d_interactor.c"
+#include "pmpd3d_various.c"
void pmpd3d_setup(void)
{
@@ -47,92 +51,87 @@ void pmpd3d_setup(void) // pmpd3d_core
class_addbang(pmpd3d_class, pmpd3d_bang);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_reset, gensym("reset"), 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_tLink, gensym("tLink"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_tabLink, gensym("tabLink"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_reset, gensym("reset"), 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_tLink, gensym("tLink"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_tabLink, gensym("tabLink"), A_GIMME, 0);
// pmpd3d_set
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_setK, gensym("setK"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_setD, gensym("setD"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_setDEnv, gensym("setDEnv"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_setDEnvOffset, gensym("setDEnvOffset"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_setL, gensym("setL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_setLKTab, gensym("setLKTab"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_setLDTab, gensym("setLDTab"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_setLinkId, gensym("setLinkId"), A_GIMME, 0);
-// class_addmethod(pmpd3d_class, (t_method)pmpd3d_setLinkId, gensym("setLinksId"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_setMassId, gensym("setMassId"), A_GIMME, 0);
-// class_addmethod(pmpd3d_class, (t_method)pmpd3d_setMassId, gensym("setMassesId"), A_GIMME, 0);
- 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_setSpeedX, gensym("setSpeedX"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_setSpeedY, gensym("setSpeedY"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_setSpeedZ, gensym("setSpeedZ"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_setSpeed, gensym("setSpeed"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_setForceX, gensym("setForceX"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_setForceY, gensym("setForceY"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_setForceZ, gensym("setForceZ"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_setForce, gensym("setForce"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_setFixed, gensym("setActive"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_setMobile, gensym("setInactive"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_pos, gensym("pos"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_posX, gensym("posX"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_posY, gensym("posY"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_posZ, gensym("posZ"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_pos, gensym("setpos"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_posX, gensym("setposX"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_posY, gensym("setposY"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_posZ, gensym("setposZ"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_setK, gensym("setK"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_setD, gensym("setD"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_setDEnv, gensym("setDEnv"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_setDEnvOffset, gensym("setDEnvOffset"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_setL, gensym("setL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_setLCurrent, gensym("setLCurrent"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_setLKTab, gensym("setLKTab"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_setLDTab, gensym("setLDTab"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_setLinkId, gensym("setLinkId"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_setMassId, gensym("setMassId"), A_GIMME, 0);
+ 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_setSpeedX, gensym("setSpeedX"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_setSpeedY, gensym("setSpeedY"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_setSpeedZ, gensym("setSpeedZ"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_setSpeed, gensym("setSpeed"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_setForceX, gensym("setForceX"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_setForceY, gensym("setForceY"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_setForceZ, gensym("setForceZ"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_setForce, gensym("setForce"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_setActive, gensym("setActive"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_setInactive, gensym("setInactive"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_pos, gensym("pos"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_posX, gensym("posX"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_posY, gensym("posY"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_posZ, gensym("posZ"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_pos, gensym("setpos"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_posX, gensym("setposX"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_posY, gensym("setposY"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_posZ, gensym("setposZ"), A_GIMME, 0);
+
// pmpd3d_get
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_get, gensym("get"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPos, gensym("massesPos"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPos, gensym("massPos"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeeds, gensym("massesSpeeds"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeeds, gensym("massSpeed"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForces, gensym("massesForces"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForces, gensym("massForce"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPos, gensym("linksPos"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPos, gensym("linkPos"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksEnds, gensym("linksEnds"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksEnds, gensym("linkEnd"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_get, gensym("get"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPos, gensym("massPos"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeeds, gensym("massSpeed"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForces, gensym("massForce"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPos, gensym("linkPos"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksEnds, gensym("linkEnd"), A_GIMME, 0);
//pmpd3d_list
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosL, gensym("massesPosL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsL, gensym("massesSpeedsL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesL, gensym("massesForcesL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosXL, gensym("massesPosXL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsXL, gensym("massesSpeedsXL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesXL, gensym("massesForcesXL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosYL, gensym("massesPosYL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsYL, gensym("massesSpeedsYL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesYL, gensym("massesForcesYL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosZL, gensym("massesPosZL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsZL, gensym("massesSpeedsZL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesZL, gensym("massesForcesZL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosL, gensym("massesPosL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsL, gensym("massesSpeedsL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesL, gensym("massesForcesL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosXL, gensym("massesPosXL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsXL, gensym("massesSpeedsXL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesXL, gensym("massesForcesXL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosYL, gensym("massesPosYL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsYL, gensym("massesSpeedsYL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesYL, gensym("massesForcesYL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosZL, gensym("massesPosZL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsZL, gensym("massesSpeedsZL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesZL, gensym("massesForcesZL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosL, gensym("massPosL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsL, gensym("massSpeedL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesL, gensym("massForceL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosXL, gensym("massPosXL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsXL, gensym("massSpeedXL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesXL, gensym("massForceXL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosYL, gensym("massPosYL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsYL, gensym("massSpeedYL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesYL, gensym("massForceYL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosZL, gensym("massPosZL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsZL, gensym("massSpeedZL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesZL, gensym("massForceZL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosL, gensym("massPosL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsL, gensym("massSpeedL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesL, gensym("massForceL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosXL, gensym("massPosXL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsXL, gensym("massSpeedXL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesXL, gensym("massForceXL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosYL, gensym("massPosYL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsYL, gensym("massSpeedYL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesYL, gensym("massForceYL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosZL, gensym("massPosZL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsZL, gensym("massSpeedZL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesZL, gensym("massForceZL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosNormL, gensym("massesPosNormL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsNormL, gensym("massesSpeedsNormL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesNormL, gensym("massesForcesNormL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosNormL, gensym("massesPosNormL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsNormL, gensym("massesSpeedsNormL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesNormL, gensym("massesForcesNormL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosNormL, gensym("massPosNormL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsNormL, gensym("massSpeedNormL"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesNormL, gensym("massForceNormL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosNormL, gensym("massPosNormL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsNormL, gensym("massSpeedNormL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesNormL, gensym("massForceNormL"), 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);
@@ -179,39 +178,39 @@ void pmpd3d_setup(void) class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthSpeedNormL, gensym("linkLengthSpeedNormL"), A_GIMME, 0);
// pmpd3d_tab
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosT, gensym("massesPosT"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsT, gensym("massesSpeedsT"),A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesT, gensym("massesForcesT"),A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosXT, gensym("massesPosXT"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsXT, gensym("massesSpeedsXT"),A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesXT, gensym("massesForcesXT"),A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosYT, gensym("massesPosYT"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsYT, gensym("massesSpeedsYT"),A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesYT, gensym("massesForcesYT"),A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosZT, gensym("massesPosZT"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsZT, gensym("massesSpeedsZT"),A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesZT, gensym("massesForcesZT"),A_GIMME, 0);
-
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosT, gensym("massPosT"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsT, gensym("massSpeedT"),A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesT, gensym("massForceT"),A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosXT, gensym("massPosXT"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsXT, gensym("massSpeedXT"),A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesXT, gensym("massForceXT"),A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosYT, gensym("massPosYT"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsYT, gensym("massSpeedYT"),A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesYT, gensym("massForceYT"),A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosZT, gensym("massPosZT"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsZT, gensym("massSpeedZT"),A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesZT, gensym("massForceZT"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosT, gensym("massesPosT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsT, gensym("massesSpeedsT"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesT, gensym("massesForcesT"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosXT, gensym("massesPosXT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsXT, gensym("massesSpeedsXT"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesXT, gensym("massesForcesXT"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosYT, gensym("massesPosYT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsYT, gensym("massesSpeedsYT"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesYT, gensym("massesForcesYT"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosZT, gensym("massesPosZT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsZT, gensym("massesSpeedsZT"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesZT, gensym("massesForcesZT"),A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosNormT, gensym("massesPosNormT"), A_GIMME, 0);
- 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_massesPosT, gensym("massPosT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsT, gensym("massSpeedT"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesT, gensym("massForceT"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosXT, gensym("massPosXT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsXT, gensym("massSpeedXT"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesXT, gensym("massForceXT"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosYT, gensym("massPosYT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsYT, gensym("massSpeedYT"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesYT, gensym("massForceYT"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosZT, gensym("massPosZT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsZT, gensym("massSpeedZT"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesZT, gensym("massForceZT"),A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosNormT, gensym("massPosNormT"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsNormT, gensym("massSpeedNormT"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesNormT, gensym("massForceNormT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosNormT, gensym("massesPosNormT"), A_GIMME, 0);
+ 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_massesPosNormT, gensym("massPosNormT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsNormT, gensym("massSpeedNormT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesNormT, gensym("massForceNormT"), 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);
@@ -247,18 +246,18 @@ void pmpd3d_setup(void) class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosSpeedZT, gensym("linkPosSpeedZT"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthSpeedZT, gensym("linkLengthSpeedZT"), 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_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_linksPosNormT, gensym("linkPosNormT"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthNormT, gensym("linkLengthNormT"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosSpeedNormT, gensym("linkPosSpeedNormT"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthSpeedNormT, gensym("linkLengthSpeedNormT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosNormT, gensym("linkPosNormT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthNormT, gensym("linkLengthNormT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosSpeedNormT, gensym("linkPosSpeedNormT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthSpeedNormT, gensym("linkLengthSpeedNormT"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksEndT, gensym("linkEndT"), A_GIMME, 0);
-/* class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksEnd1T, gensym("linkEnd1T"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksEnd1T, gensym("linkEnd1T"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksEnd2T, gensym("linkEnd2T"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksEndXT, gensym("linkEndXT"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksEnd1XT, gensym("linkEnd1XT"), A_GIMME, 0);
@@ -269,62 +268,69 @@ void pmpd3d_setup(void) class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksEndZT, gensym("linkEndZT"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksEnd1ZT, gensym("linkEnd1ZT"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksEnd2ZT, gensym("linkEnd2ZT"), A_GIMME, 0);
-*/
-
-// pmpd3d_various
- 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_force, gensym("force"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_forceX, gensym("forceX"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_forceY, gensym("forceY"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_forceZ, gensym("forceZ"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_min, gensym("min"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_max, gensym("max"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_minX, gensym("Xmin"), A_DEFFLOAT, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_maxX, gensym("Xmax"), A_DEFFLOAT, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_minY, gensym("Ymin"), A_DEFFLOAT, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_maxY, gensym("Ymax"), A_DEFFLOAT, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_minZ, gensym("Zmin"), A_DEFFLOAT, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_maxZ, gensym("Zmax"), A_DEFFLOAT, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_addPos, gensym("addPos"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_addPosX, gensym("addPosX"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_addPosY, gensym("addPosY"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_addPosZ, gensym("addPosZ"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_grabMass, gensym("grabMass"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_closestMass, gensym("closestMass"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesDistances, gensym("massDistance"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_enumMasses, gensym("enumMass"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_enumLinks, gensym("enumLink"), A_GIMME, 0);
-
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_forcesXT, gensym("forceXT"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_forcesYT, gensym("forceYT"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_forcesZT, gensym("forceZT"), A_GIMME, 0);
-
+// pmpd3d_test
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_testMass, gensym("testMass"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_testLink, gensym("testLink"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_testMassT, gensym("testMassT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_testLinkT, gensym("testLinkT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_testMassT, gensym("testMassL"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_testLinkT, gensym("testLinkL"), A_GIMME, 0);
+
// pmpd3d_stat
- 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_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_massesPosMean, gensym("massPosMean"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosStd, gensym("massPosStd"),A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesMean, gensym("massForecesMean"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesStd, gensym("massForcesStd"),A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsMean, gensym("massSpeedsMean"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsStd, gensym("massSpeedsStd"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosMean, gensym("massPosMean"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosStd, gensym("massPosStd"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesMean, gensym("massForecesMean"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesForcesStd, gensym("massForcesStd"),A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsMean, gensym("massSpeedsMean"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesSpeedsStd, gensym("massSpeedsStd"),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_linkPosMean, gensym("linkPosMean"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linkLengthMean, gensym("linkLengthMean"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linkPosSpeedMean, gensym("linkPosSpeedMean"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linkLengthSpeedMean, gensym("linkLengthSpeedMean"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linkPosStd, gensym("linkPosStd"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linkLengthStd, gensym("linkLengthStd"), A_GIMME, 0);
+ 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);
+
+// pmpd3d_interactor
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_iCylinder, gensym("iCylinder"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_iCylinder, gensym("iPlane"), A_GIMME, 0);
+
+// pmpd3d_various
+ 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_force, gensym("force"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_forceX, gensym("forceX"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_forceY, gensym("forceY"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_forceZ, gensym("forceZ"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_min, gensym("min"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_max, gensym("max"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_minX, gensym("Xmin"), A_DEFFLOAT, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_maxX, gensym("Xmax"), A_DEFFLOAT, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_minY, gensym("Ymin"), A_DEFFLOAT, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_maxY, gensym("Ymax"), A_DEFFLOAT, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_minZ, gensym("Zmin"), A_DEFFLOAT, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_maxZ, gensym("Zmax"), A_DEFFLOAT, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_addPos, gensym("addPos"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_addPosX, gensym("addPosX"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_addPosY, gensym("addPosY"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_addPosZ, gensym("addPosZ"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_grabMass, gensym("grabMass"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_closestMass, gensym("closestMass"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesDistances, gensym("massDistance"), A_GIMME, 0);
+
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_forcesXT, gensym("forceXT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_forcesYT, gensym("forceYT"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_forcesZT, gensym("forceZT"), A_GIMME, 0);
+
}
diff --git a/pmpd3d_get.c b/pmpd3d_get.c index ba6fdb7..dba3915 100644 --- a/pmpd3d_get.c +++ b/pmpd3d_get.c @@ -351,30 +351,32 @@ void pmpd3d_massesPos(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) int i; t_atom toout[5]; - if (argv[0].a_type == A_FLOAT) + if ((argc>0)&&(argv[0].a_type == A_FLOAT)) { i = atom_getfloatarg(0, argc, argv); if ( (i>=0) && (i<x->nb_mass) ) { - SETFLOAT(&(toout[0]), i); - SETFLOAT(&(toout[1]), x->mass[i].posX); - SETFLOAT(&(toout[2]), x->mass[i].posY); - SETFLOAT(&(toout[3]), x->mass[i].posZ); - outlet_anything(x->main_outlet, gensym("massesPosNo"), 4, toout); + SETSYMBOL(&(toout[0]), x->mass[i].Id); + SETFLOAT(&(toout[1]), i); + SETFLOAT(&(toout[2]), x->mass[i].posX); + SETFLOAT(&(toout[3]), x->mass[i].posY); + SETFLOAT(&(toout[4]), x->mass[i].posZ); + outlet_anything(x->main_outlet, gensym("massPos"), 5, toout); } } else - if (argv[0].a_type == A_SYMBOL) + if ((argc>0)&&(argv[0].a_type == A_SYMBOL)) { for (i=0; i< x->nb_mass; i++) { SETSYMBOL(&(toout[0]), atom_getsymbolarg(0,argc,argv)); if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id) { - SETFLOAT(&(toout[1]), x->mass[i].posX); - SETFLOAT(&(toout[2]), x->mass[i].posY); - SETFLOAT(&(toout[3]), x->mass[i].posZ); - outlet_anything(x->main_outlet, gensym("massesPosId"), 4, toout); + SETFLOAT(&(toout[1]), i); + SETFLOAT(&(toout[2]), x->mass[i].posX); + SETFLOAT(&(toout[3]), x->mass[i].posY); + SETFLOAT(&(toout[4]), x->mass[i].posZ); + outlet_anything(x->main_outlet, gensym("massPos"), 5, toout); } } } @@ -383,12 +385,12 @@ void pmpd3d_massesPos(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) { for (i=0; i< x->nb_mass; i++) { - SETFLOAT(&(toout[0]), i); - SETSYMBOL(&(toout[1]), x->mass[i].Id); + SETSYMBOL(&(toout[0]), x->mass[i].Id); + SETFLOAT(&(toout[1]), i); SETFLOAT(&(toout[2]), x->mass[i].posX); SETFLOAT(&(toout[3]), x->mass[i].posY); SETFLOAT(&(toout[4]), x->mass[i].posZ); - outlet_anything(x->main_outlet, gensym("massesPos"), 5, toout); + outlet_anything(x->main_outlet, gensym("massPos"), 5, toout); } } } @@ -398,30 +400,32 @@ void pmpd3d_massesSpeeds(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) int i; t_atom toout[5]; - if (argv[0].a_type == A_FLOAT) + if ((argc>0)&&(argv[0].a_type == A_FLOAT)) { i = atom_getfloatarg(0, argc, argv); if ( (i>=0) && (i<x->nb_mass) ) { - SETFLOAT(&(toout[0]), i); - SETFLOAT(&(toout[1]), x->mass[i].speedX); - SETFLOAT(&(toout[2]), x->mass[i].speedY); - SETFLOAT(&(toout[3]), x->mass[i].speedZ); - outlet_anything(x->main_outlet, gensym("massesSpeedsNo"), 4, toout); + SETSYMBOL(&(toout[0]), x->mass[i].Id); + SETFLOAT(&(toout[1]), i); + SETFLOAT(&(toout[2]), x->mass[i].speedX); + SETFLOAT(&(toout[3]), x->mass[i].speedY); + SETFLOAT(&(toout[4]), x->mass[i].speedZ); + outlet_anything(x->main_outlet, gensym("massSpeed"), 5, toout); } } else - if (argv[0].a_type == A_SYMBOL) + if ((argc>0)&&(argv[0].a_type == A_SYMBOL)) { for (i=0; i< x->nb_mass; i++) { SETSYMBOL(&(toout[0]), atom_getsymbolarg(0,argc,argv)); if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id) { - SETFLOAT(&(toout[1]), x->mass[i].speedX); - SETFLOAT(&(toout[2]), x->mass[i].speedY); - SETFLOAT(&(toout[3]), x->mass[i].speedZ); - outlet_anything(x->main_outlet, gensym("massesSpeedsId"), 4, toout); + SETFLOAT(&(toout[1]), i); + SETFLOAT(&(toout[2]), x->mass[i].speedX); + SETFLOAT(&(toout[3]), x->mass[i].speedY); + SETFLOAT(&(toout[4]), x->mass[i].speedZ); + outlet_anything(x->main_outlet, gensym("massSpeed"), 5, toout); } } } @@ -430,12 +434,12 @@ void pmpd3d_massesSpeeds(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) { for (i=0; i< x->nb_mass; i++) { - SETFLOAT(&(toout[0]), i); - SETSYMBOL(&(toout[1]), x->mass[i].Id); + SETSYMBOL(&(toout[0]), x->mass[i].Id); + SETFLOAT(&(toout[1]), i); SETFLOAT(&(toout[2]), x->mass[i].speedX); SETFLOAT(&(toout[3]), x->mass[i].speedY); SETFLOAT(&(toout[4]), x->mass[i].speedZ); - outlet_anything(x->main_outlet, gensym("massesSpeeds"), 5, toout); + outlet_anything(x->main_outlet, gensym("massSpeed"), 5, toout); } } } @@ -445,30 +449,32 @@ void pmpd3d_massesForces(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) int i; t_atom toout[5]; - if (argv[0].a_type == A_FLOAT) + if ((argc>0)&&(argv[0].a_type == A_FLOAT)) { i = atom_getfloatarg(0, argc, argv); if ( (i>=0) && (i<x->nb_mass) ) { - SETFLOAT(&(toout[0]), i); - SETFLOAT(&(toout[1]), x->mass[i].forceX); - SETFLOAT(&(toout[2]), x->mass[i].forceY); - SETFLOAT(&(toout[3]), x->mass[i].forceZ); - outlet_anything(x->main_outlet, gensym("massesForcesNo"), 4, toout); + SETSYMBOL(&(toout[0]), x->mass[i].Id); + SETFLOAT(&(toout[1]), i); + SETFLOAT(&(toout[2]), x->mass[i].forceX); + SETFLOAT(&(toout[3]), x->mass[i].forceY); + SETFLOAT(&(toout[4]), x->mass[i].forceZ); + outlet_anything(x->main_outlet, gensym("massForce"), 5, toout); } } else - if (argv[0].a_type == A_SYMBOL) + if ((argc>0)&&(argv[0].a_type == A_SYMBOL)) { for (i=0; i< x->nb_mass; i++) { SETSYMBOL(&(toout[0]), atom_getsymbolarg(0,argc,argv)); if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id) { - SETFLOAT(&(toout[1]), x->mass[i].forceX); - SETFLOAT(&(toout[2]), x->mass[i].forceY); - SETFLOAT(&(toout[3]), x->mass[i].forceZ); - outlet_anything(x->main_outlet, gensym("massesForcesId"), 4, toout); + SETFLOAT(&(toout[1]), i); + SETFLOAT(&(toout[2]), x->mass[i].forceX); + SETFLOAT(&(toout[3]), x->mass[i].forceY); + SETFLOAT(&(toout[4]), x->mass[i].forceZ); + outlet_anything(x->main_outlet, gensym("massForce"), 5, toout); } } } @@ -477,12 +483,12 @@ void pmpd3d_massesForces(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) { for (i=0; i< x->nb_mass; i++) { - SETFLOAT(&(toout[0]), i); - SETSYMBOL(&(toout[1]), x->mass[i].Id); + SETSYMBOL(&(toout[0]), x->mass[i].Id); + SETFLOAT(&(toout[1]), i); SETFLOAT(&(toout[2]), x->mass[i].forceX); SETFLOAT(&(toout[3]), x->mass[i].forceY); SETFLOAT(&(toout[4]), x->mass[i].forceZ); - outlet_anything(x->main_outlet, gensym("massesForces"), 5, toout); + outlet_anything(x->main_outlet, gensym("massForce"), 5, toout); } } } @@ -492,36 +498,38 @@ void pmpd3d_linksEnds(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) int i; t_atom toout[8]; - if (argv[0].a_type == A_FLOAT) + if ((argc>0)&&(argv[0].a_type == A_FLOAT)) { i = atom_getfloatarg(0, argc, argv); if ( (i>=0) && (i<x->nb_mass) ) { - SETFLOAT(&(toout[0]), i); - SETFLOAT(&(toout[1]), x->link[i].mass1->posX); - SETFLOAT(&(toout[2]), x->link[i].mass1->posY); - SETFLOAT(&(toout[3]), x->link[i].mass1->posZ); - SETFLOAT(&(toout[4]), x->link[i].mass2->posX); - SETFLOAT(&(toout[5]), x->link[i].mass2->posY); - SETFLOAT(&(toout[6]), x->link[i].mass2->posZ); - outlet_anything(x->main_outlet, gensym("linksEndsNo"), 7, toout); + SETSYMBOL(&(toout[0]), x->mass[i].Id); + SETFLOAT(&(toout[1]), i); + SETFLOAT(&(toout[2]), x->link[i].mass1->posX); + SETFLOAT(&(toout[3]), x->link[i].mass1->posY); + SETFLOAT(&(toout[4]), x->link[i].mass1->posZ); + SETFLOAT(&(toout[5]), x->link[i].mass2->posX); + SETFLOAT(&(toout[6]), x->link[i].mass2->posY); + SETFLOAT(&(toout[7]), x->link[i].mass2->posZ); + outlet_anything(x->main_outlet, gensym("linkEnd"), 8, toout); } } else - if (argv[0].a_type == A_SYMBOL) + if ((argc>0)&&(argv[0].a_type == A_SYMBOL)) { for (i=0; i< x->nb_link; i++) { SETSYMBOL(&(toout[0]), atom_getsymbolarg(0,argc,argv)); if ( atom_getsymbolarg(0,argc,argv) == x->link[i].Id) { - SETFLOAT(&(toout[1]), x->link[i].mass1->posX); - SETFLOAT(&(toout[2]), x->link[i].mass1->posY); - SETFLOAT(&(toout[3]), x->link[i].mass1->posZ); - SETFLOAT(&(toout[4]), x->link[i].mass2->posX); - SETFLOAT(&(toout[5]), x->link[i].mass2->posY); - SETFLOAT(&(toout[6]), x->link[i].mass2->posZ); - outlet_anything(x->main_outlet, gensym("linksEndsId"), 7, toout); + SETFLOAT(&(toout[1]), i); + SETFLOAT(&(toout[2]), x->link[i].mass1->posX); + SETFLOAT(&(toout[3]), x->link[i].mass1->posY); + SETFLOAT(&(toout[4]), x->link[i].mass1->posZ); + SETFLOAT(&(toout[5]), x->link[i].mass2->posX); + SETFLOAT(&(toout[6]), x->link[i].mass2->posY); + SETFLOAT(&(toout[7]), x->link[i].mass2->posZ); + outlet_anything(x->main_outlet, gensym("linkEnd"), 8, toout); } } } @@ -530,15 +538,15 @@ void pmpd3d_linksEnds(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) { for (i=0; i< x->nb_link; i++) { - SETFLOAT(&(toout[0]), i); - SETSYMBOL(&(toout[1]), x->link[i].Id); + SETSYMBOL(&(toout[0]), x->mass[i].Id); + SETFLOAT(&(toout[1]), i); SETFLOAT(&(toout[2]), x->link[i].mass1->posX); SETFLOAT(&(toout[3]), x->link[i].mass1->posY); SETFLOAT(&(toout[4]), x->link[i].mass1->posZ); SETFLOAT(&(toout[5]), x->link[i].mass2->posX); SETFLOAT(&(toout[6]), x->link[i].mass2->posY); SETFLOAT(&(toout[7]), x->link[i].mass2->posZ); - outlet_anything(x->main_outlet, gensym("linksEnds"), 8, toout); + outlet_anything(x->main_outlet, gensym("linkEnd"), 8, toout); } } } @@ -548,30 +556,32 @@ void pmpd3d_linksPos(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) int i; t_atom toout[5]; - if (argv[0].a_type == A_FLOAT) + if ((argc>0)&&(argv[0].a_type == A_FLOAT)) { i = atom_getfloatarg(0, argc, argv); if ( (i>=0) && (i<x->nb_mass) ) { - SETFLOAT(&(toout[0]), i); - SETFLOAT(&(toout[1]), (x->link[i].mass1->posX+x->link[i].mass2->posX)/2); - SETFLOAT(&(toout[2]), (x->link[i].mass1->posY+x->link[i].mass2->posY)/2); - SETFLOAT(&(toout[3]), (x->link[i].mass1->posZ+x->link[i].mass2->posZ)/2); - outlet_anything(x->main_outlet, gensym("linksEndsNo"), 4, toout); + SETSYMBOL(&(toout[0]), x->mass[i].Id); + SETFLOAT(&(toout[1]), i); + SETFLOAT(&(toout[2]), (x->link[i].mass1->posX+x->link[i].mass2->posX)/2); + SETFLOAT(&(toout[3]), (x->link[i].mass1->posY+x->link[i].mass2->posY)/2); + SETFLOAT(&(toout[4]), (x->link[i].mass1->posZ+x->link[i].mass2->posZ)/2); + outlet_anything(x->main_outlet, gensym("linkEnd"), 5, toout); } } else - if (argv[0].a_type == A_SYMBOL) + if ((argc>0)&&(argv[0].a_type == A_SYMBOL)) { for (i=0; i< x->nb_link; i++) { SETSYMBOL(&(toout[0]), atom_getsymbolarg(0,argc,argv)); if ( atom_getsymbolarg(0,argc,argv) == x->link[i].Id) { - SETFLOAT(&(toout[1]), (x->link[i].mass1->posX+x->link[i].mass2->posX)/2); - SETFLOAT(&(toout[2]), (x->link[i].mass1->posY+x->link[i].mass2->posY)/2); - SETFLOAT(&(toout[3]), (x->link[i].mass1->posZ+x->link[i].mass2->posZ)/2); - outlet_anything(x->main_outlet, gensym("linksEndsId"), 4, toout); + SETFLOAT(&(toout[1]), i); + SETFLOAT(&(toout[2]), (x->link[i].mass1->posX+x->link[i].mass2->posX)/2); + SETFLOAT(&(toout[3]), (x->link[i].mass1->posY+x->link[i].mass2->posY)/2); + SETFLOAT(&(toout[4]), (x->link[i].mass1->posZ+x->link[i].mass2->posZ)/2); + outlet_anything(x->main_outlet, gensym("linkEnd"), 5, toout); } } } @@ -580,12 +590,12 @@ void pmpd3d_linksPos(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) { for (i=0; i< x->nb_link; i++) { - SETFLOAT(&(toout[0]), i); - SETSYMBOL(&(toout[1]), x->link[i].Id); + SETSYMBOL(&(toout[0]), x->mass[i].Id); + SETFLOAT(&(toout[1]), i); SETFLOAT(&(toout[2]), (x->link[i].mass1->posX+x->link[i].mass2->posX)/2); SETFLOAT(&(toout[3]), (x->link[i].mass1->posY+x->link[i].mass2->posY)/2); SETFLOAT(&(toout[4]), (x->link[i].mass1->posZ+x->link[i].mass2->posZ)/2); - outlet_anything(x->main_outlet, gensym("linksEnds"), 5, toout); + outlet_anything(x->main_outlet, gensym("linkEnd"), 5, toout); } } } diff --git a/pmpd3d_interactor.c b/pmpd3d_interactor.c new file mode 100644 index 0000000..57fcd82 --- /dev/null +++ b/pmpd3d_interactor.c @@ -0,0 +1,203 @@ +void pmpd3d_iCylinder_i(t_pmpd3d *x, int i, t_float xc, t_float yc, t_float zc, t_float a, t_float b, t_float c, t_float d, t_float R, t_float K, t_float power, t_float Kt, t_float powert, t_float Rmin, t_float Rmax) +{ + t_float profondeur, rayon, Xb, Yb, Zb, Xt, Yt, Zt, tmp; + + profondeur = a * x->mass[i].posX + b * x->mass[i].posY + c * x->mass[i].posZ - d; + + Xb = x->mass[i].posX -xc - profondeur * a; + Yb = x->mass[i].posY -yc - profondeur * b; + Zb = x->mass[i].posZ -zc - profondeur * c; + + rayon = sqrt ( sqr(Xb) + sqr(Yb) + sqr(Zb) ); + + if (rayon != 0) + { + Xb /= rayon; // normalisation + Yb /= rayon; + Zb /= rayon; + } + else + { + Xb = 0; // normalisation + Yb = 0; + Zb = 0; + } + + Xt = b*Zb - c*Yb; // vecteur tengentiel au cercle + Yt = c*Xb - a*Zb; + Zt = a*Yb - b*Xb; + +// Xb, Yb, Zb : vecteur unitaire normal au cercle +// Xt, Yt, Zt : vecteur unitaire tengent au cercle +// rayon : distance au centre. + + if ( ((rayon>Rmin) || (Rmin<0)) && ((rayon<Rmax) || (Rmax<0)) ) + { + rayon -= R; + + tmp = pow(K * R, power); + x->mass[i].forceX += Xb * tmp; + x->mass[i].forceY += Yb * tmp; + x->mass[i].forceZ += Zb * tmp; + + tmp = pow(Kt * R, powert); + x->mass[i].forceX += Xt * tmp; + x->mass[i].forceY += Yt * tmp; + x->mass[i].forceZ += Zt * tmp; + } +} + +void pmpd3d_iCylinder(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) +{ + // Argument : + // 0 : mass to apply this interactor + // 1,2,3 : XYZ : center vector of the cylinder + // 4,5,6 : XYZ : center point of the cylinder + // 7 : cylinder radius + // 8 : K + // [9] : power of the force + // [10] : Kt + // [11] : power of the force tengential force + // [12] : min radium of the interactor + // [13] : max radium of the interactor + + t_float xc, yc, zc, a, b, c, d, r, K, Kt, power, powert, tmp, Rmin, Rmax; + t_int i; + + a = atom_getfloatarg(1, argc, argv); + b = atom_getfloatarg(2, argc, argv); + c = atom_getfloatarg(3, argc, argv); + + tmp = sqrt (a*a + b*b + c*c); + if (tmp != 0) + { + a /= tmp; + b /= tmp; + c /= tmp; + } + else + { + a=1; + b=0; + c=0; + } + xc = atom_getfloatarg(4, argc, argv); + yc = atom_getfloatarg(5, argc, argv); + zc = atom_getfloatarg(6, argc, argv); + + d = a * xc + b * yc + c * zc; + + r = atom_getfloatarg(7, argc, argv); + + K = atom_getfloatarg(8, argc, argv); + power = atom_getfloatarg(9, argc, argv); + if (power == 0) power = 1; + + Kt = atom_getfloatarg(10, argc, argv); + powert = atom_getfloatarg(11, argc, argv); + if (powert == 0) power = 1; + + Rmin = -1; + Rmax = -1; + if (argc > 12) { Rmin = atom_getfloatarg(12, argc, argv); } + if (argc > 13) { Rmax = atom_getfloatarg(13, argc, argv); } + + if (atom_getfloatarg(0,argc,argv) == -1) // all + { + for (i=0; i < x->nb_mass; i++) + { + pmpd3d_iCylinder_i(x, i, xc, yc, zc, a, b, c, d, r, K, power, Kt, powert, Rmin, Rmax); + } + } + else if (argv[0].a_type == A_FLOAT) + { + pmpd3d_iCylinder_i(x, atom_getfloatarg(0,argc,argv), xc, yc, zc, a, b, c, d, r, K, power, Kt, powert, Rmin, Rmax); + } + else if (argv[0].a_type == A_SYMBOL) + { + for (i=0; i < x->nb_mass; i++) + { + if (atom_getsymbolarg(0,argc,argv) == x->mass[i].Id) + { + pmpd3d_iCylinder_i(x, i, xc, yc, zc, a, b, c, d, r, K, power, Kt, powert, Rmin, Rmax); + } + } + } +} + +void pmpd3d_iPlane_i(t_pmpd3d *x, int i, t_float a, t_float b, t_float c, t_float d, t_float K, t_float power) +{ + + t_float profondeur, force; + + profondeur = a * x->mass[i].posX + b * x->mass[i].posY + c * x->mass[i].posZ - d; + if (profondeur < 0) + { + force = K * pow(abs(profondeur), power); + + x->mass[i].forceX += a * force; + x->mass[i].forceY += b * force; + x->mass[i].forceZ += c * force; + } +} + +void pmpd3d_iPlane(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) +{ + // Argument : + // 0 : mass to apply this interactor + // 1,2,3 : XYZ : vector perpendicular to the plane + // 4,5,6 : XYZ : one point of the plane + // 7 : K + // 8 : power of the force + + // ax+by+cz-d=0 + // d est tel que aXcenter +bYcenter + cYcenter = d + t_float a, b, c, d, K, power, tmp; + t_int i; + + a = atom_getfloatarg(1, argc, argv); + b = atom_getfloatarg(2, argc, argv); + c = atom_getfloatarg(3, argc, argv); + + tmp = sqrt (a*a + b*b + c*c); + if (tmp != 0) + { + a /= tmp; + b /= tmp; + c /= tmp; + } + else + { + a=1; + b=0; + c=0; + } + + d = a * atom_getfloatarg(4, argc, argv) + b * atom_getfloatarg(5, argc, argv) + c * atom_getfloatarg(6, argc, argv); + + K = atom_getfloatarg(7, argc, argv); + power = atom_getfloatarg(8, argc, argv); + if (power == 0) power = 1; + + if (atom_getfloatarg(0,argc,argv) == -1) // all + { + for (i=0; i < x->nb_mass; i++) + { + pmpd3d_iPlane_i(x, i, a, b, c, d, K, power); + } + } + else if (argv[0].a_type == A_FLOAT) + { + pmpd3d_iPlane_i(x,atom_getfloatarg(0,argc,argv), a, b, c, d, K, power); + } + else if (argv[0].a_type == A_SYMBOL) + { + for (i=0; i < x->nb_mass; i++) + { + if (atom_getsymbolarg(0,argc,argv) == x->mass[i].Id) + { + pmpd3d_iPlane_i(x, i, a, b, c, d, K, power); + } + } + } +} diff --git a/pmpd3d_set.c b/pmpd3d_set.c index 58bd812..4792a72 100644 --- a/pmpd3d_set.c +++ b/pmpd3d_set.c @@ -136,13 +136,34 @@ void pmpd3d_setL(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) } } } - else if ( (argc== 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) && ( atom_getsymbolarg(1,argc,argv) == gensym("current") ) ) +} +void pmpd3d_setLCurrent(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) +{ + int tmp, i; + + if ( ( argv[0].a_type == A_FLOAT ) && ( argc == 1 ) ) + { + tmp = atom_getfloatarg(0, argc, argv); + tmp = max(0, min( x->nb_link-1, tmp)); + x->link[tmp].L = x->link[tmp].mass2->posX - x->link[tmp].mass1->posX; + } + else if ( ( argv[0].a_type == A_SYMBOL ) && ( argc == 1 ) ) + { + for (i=0; i< x->nb_link; i++) + { + if ( atom_getsymbolarg(0,argc,argv) == x->link[i].Id) + { + x->link[i].L = x->link[i].mass2->posX - x->link[i].mass1->posX; + } + } + } + else if ( ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) ) { i = atom_getfloatarg(0, argc, argv); i = max(0, min( x->nb_link-1, i)); x->link[i].L = mix(x->link[i].L,x->link[i].distance,atom_getfloatarg(2, argc, argv)); } - else if ( (argc== 3) && ( argv[0].a_type == A_SYMBOL ) && ( argv[2].a_type == A_FLOAT ) && ( atom_getsymbolarg(1,argc,argv) == gensym("current") ) ) + else if ( ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) ) { for (i=0; i< x->nb_link; i++) { @@ -154,6 +175,8 @@ void pmpd3d_setL(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) } } + + void pmpd3d_setLKTab(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) { int tmp, i; diff --git a/pmpd3d_stat.c b/pmpd3d_stat.c index cc8cb9c..83018dd 100644 --- a/pmpd3d_stat.c +++ b/pmpd3d_stat.c @@ -393,3 +393,567 @@ 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_linkPosMean(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float sommeX, sommeY, sommeZ, somme; + t_int i,j; + t_atom mean[4]; + + sommeX = 0; + sommeY = 0; + sommeZ = 0; + somme = 0; + j = 0; + + if ( (argc >= 1) && (argv[0].a_type == A_SYMBOL) ) + { + for (i=0; i< x->nb_link; i++) + { + if (atom_getsymbolarg(0,argc,argv) == x->link[i].Id) + { + sommeX += (x->link[i].mass1->posX + x->link[i].mass2->posX)/2; + sommeY += (x->link[i].mass1->posY + x->link[i].mass2->posY)/2; + sommeZ += (x->link[i].mass1->posZ + x->link[i].mass2->posZ)/2; + somme += sqrt(sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + sqr((x->link[i].mass1->posX + x->link[i].mass1->posX)/2)); + j++; + } + } + } + else + { + for (i=0; i< x->nb_link; i++) + { + sommeX += (x->link[i].mass1->posX + x->link[i].mass2->posX)/2; + sommeY += (x->link[i].mass1->posY + x->link[i].mass2->posY)/2; + sommeZ += (x->link[i].mass1->posZ + x->link[i].mass2->posZ)/2; + somme += sqrt(sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + sqr((x->link[i].mass1->posX + x->link[i].mass1->posX)/2)); + j++; + } + } + + sommeX /= j; + sommeY /= j; + sommeZ /= j; + somme /= j; + + SETFLOAT(&(mean[0]),sommeX); + SETFLOAT(&(mean[1]),sommeY); + SETFLOAT(&(mean[2]),sommeZ); + SETFLOAT(&(mean[3]),somme); + + outlet_anything(x->main_outlet, gensym("linkPosMean"),4 , mean); +} + +void pmpd3d_linkLengthMean(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float sommeX, sommeY, sommeZ, somme, tmp; + t_int i,j; + t_atom mean[4]; + + sommeX = 0; + sommeY = 0; + sommeZ = 0; + somme = 0; + j = 0; + + if ( (argc >= 1) && (argv[0].a_type == A_SYMBOL) ) + { + for (i=0; i< x->nb_link; i++) + { + if (atom_getsymbolarg(0,argc,argv) == x->link[i].Id) + { + sommeX += abs(x->link[i].mass1->posX - x->link[i].mass2->posX); + sommeX += abs(x->link[i].mass1->posY - x->link[i].mass2->posY); + sommeX += abs(x->link[i].mass1->posZ - x->link[i].mass2->posZ); + somme += x->link[i].distance; + j++; + } + } + } + else + { + for (i=0; i< x->nb_link; i++) + { + sommeX += abs(x->link[i].mass1->posX - x->link[i].mass2->posX); + sommeX += abs(x->link[i].mass1->posY - x->link[i].mass2->posY); + sommeX += abs(x->link[i].mass1->posZ - x->link[i].mass2->posZ); + somme += x->link[i].distance; + j++; + } + } + + sommeX /= j; + sommeY /= j; + sommeZ /= j; + somme /= j; + + SETFLOAT(&(mean[0]),sommeX); + SETFLOAT(&(mean[1]),sommeY); + SETFLOAT(&(mean[2]),sommeZ); + SETFLOAT(&(mean[3]),somme); + + outlet_anything(x->main_outlet, gensym("linkLengthMean"),4 , mean); +} + +void pmpd3d_linkPosSpeedMean(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float sommeX, sommeY, sommeZ, somme; + t_int i,j; + t_atom mean[4]; + + sommeX = 0; + sommeY = 0; + sommeZ = 0; + somme = 0; + j = 0; + + if ( (argc >= 1) && (argv[0].a_type == A_SYMBOL) ) + { + for (i=0; i< x->nb_link; i++) + { + if (atom_getsymbolarg(0,argc,argv) == x->link[i].Id) + { + sommeX += (x->link[i].mass1->speedX + x->link[i].mass2->speedX)/2; + sommeY += (x->link[i].mass1->speedY + x->link[i].mass2->speedY)/2; + sommeZ += (x->link[i].mass1->speedZ + x->link[i].mass2->speedZ)/2; + somme += 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)); + j++; + } + } + } + else + { + for (i=0; i< x->nb_link; i++) + { + sommeX += (x->link[i].mass1->speedX + x->link[i].mass2->speedX)/2; + sommeY += (x->link[i].mass1->speedY + x->link[i].mass2->speedY)/2; + sommeZ += (x->link[i].mass1->speedZ + x->link[i].mass2->speedZ)/2; + somme += 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)); + j++; + } + } + + sommeX /= j; + sommeY /= j; + sommeZ /= j; + somme /= j; + + SETFLOAT(&(mean[0]),sommeX); + SETFLOAT(&(mean[1]),sommeY); + SETFLOAT(&(mean[2]),sommeZ); + SETFLOAT(&(mean[3]),somme); + + outlet_anything(x->main_outlet, gensym("linkPosSpeedMean"),4 , mean); +} + +void pmpd3d_linkLengthSpeedMean(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float sommeX, sommeY, sommeZ, somme, tmp; + t_int i,j; + t_atom mean[4]; + + sommeX = 0; + sommeY = 0; + sommeZ = 0; + somme = 0; + j = 0; + + if ( (argc >= 1) && (argv[0].a_type == A_SYMBOL) ) + { + for (i=0; i< x->nb_link; i++) + { + if (atom_getsymbolarg(0,argc,argv) == x->link[i].Id) + { + sommeX += abs(x->link[i].mass1->speedX - x->link[i].mass2->speedX); + sommeX += abs(x->link[i].mass1->speedY - x->link[i].mass2->speedY); + sommeX += abs(x->link[i].mass1->speedZ - x->link[i].mass2->speedZ); + somme += sqrt(sqr(x->link[i].mass1->speedX - x->link[i].mass2->speedX) + + sqr(x->link[i].mass1->speedY - x->link[i].mass2->speedY) + + sqr(x->link[i].mass1->speedZ - x->link[i].mass2->speedZ)); + j++; + } + } + } + else + { + for (i=0; i< x->nb_link; i++) + { + sommeX += abs(x->link[i].mass1->speedX - x->link[i].mass2->speedX); + sommeX += abs(x->link[i].mass1->speedY - x->link[i].mass2->speedY); + sommeX += abs(x->link[i].mass1->speedZ - x->link[i].mass2->speedZ); + somme += sqrt(sqr(x->link[i].mass1->speedX - x->link[i].mass2->speedX) + + sqr(x->link[i].mass1->speedY - x->link[i].mass2->speedY) + + sqr(x->link[i].mass1->speedZ - x->link[i].mass2->speedZ)); + j++; + } + } + + sommeX /= j; + sommeY /= j; + sommeZ /= j; + somme /= j; + + SETFLOAT(&(mean[0]),sommeX); + SETFLOAT(&(mean[1]),sommeY); + SETFLOAT(&(mean[2]),sommeZ); + SETFLOAT(&(mean[3]),somme); + + outlet_anything(x->main_outlet, gensym("linkLengthSpeedMean"),4 , mean); +} + +void pmpd3d_linkPosStd(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float sommeX, sommeY, sommeZ, somme; + t_int i,j; + t_float stdX, stdY, stdZ, std; + t_atom std_out[4]; + + sommeX = 0; + sommeY = 0; + sommeZ = 0; + somme = 0; + stdX = 0; + stdY = 0; + stdZ = 0; + std = 0; + j = 0; + + if ( (argc >= 1) && (argv[0].a_type == A_SYMBOL) ) + { + for (i=0; i< x->nb_link; i++) + { + if (atom_getsymbolarg(0,argc,argv) == x->link[i].Id) + { + sommeX += (x->link[i].mass1->posX + x->link[i].mass2->posX)/2; + sommeY += (x->link[i].mass1->posY + x->link[i].mass2->posY)/2; + sommeZ += (x->link[i].mass1->posZ + x->link[i].mass2->posZ)/2; + somme += sqrt(sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + sqr((x->link[i].mass1->posX + x->link[i].mass1->posX)/2)); + j++; + } + } + } + else + { + for (i=0; i< x->nb_link; i++) + { + sommeX += (x->link[i].mass1->posX + x->link[i].mass2->posX)/2; + sommeY += (x->link[i].mass1->posY + x->link[i].mass2->posY)/2; + sommeZ += (x->link[i].mass1->posZ + x->link[i].mass2->posZ)/2; + somme += sqrt(sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + sqr((x->link[i].mass1->posX + x->link[i].mass1->posX)/2)); + j++; + } + } + + sommeX /= j; + sommeY /= j; + sommeZ /= j; + somme /= j; + + if ( (argc >= 1) && (argv[0].a_type == A_SYMBOL) ) + { + for (i=0; i< x->nb_link; i++) + { + if (atom_getsymbolarg(0,argc,argv) == x->link[i].Id) + { + stdX += sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2 - sommeX); + stdY += sqr((x->link[i].mass1->posY + x->link[i].mass2->posY)/2 - sommeY); + stdZ += sqr((x->link[i].mass1->posZ + x->link[i].mass2->posZ)/2 - sommeZ); + std += sqr(sqrt(sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + sqr((x->link[i].mass1->posX + x->link[i].mass1->posX)/2)) - somme); + j+=1; + } + } + } + else + { + for (i=0; i< x->nb_link; i++) + { + stdX += sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2 - sommeX); + stdY += sqr((x->link[i].mass1->posY + x->link[i].mass2->posY)/2 - sommeY); + stdZ += sqr((x->link[i].mass1->posZ + x->link[i].mass2->posZ)/2 - sommeZ); + std += sqr(sqrt(sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + sqr((x->link[i].mass1->posX + x->link[i].mass1->posX)/2)) - somme); + j+=1; + } + } + + stdX = sqrt(stdX/j); + stdY = sqrt(stdY/j); + stdZ = sqrt(stdZ/j); + std = sqrt(std /j); + + SETFLOAT(&(std_out[0]),stdX); + SETFLOAT(&(std_out[1]),stdY); + SETFLOAT(&(std_out[2]),stdZ); + SETFLOAT(&(std_out[3]),std); + + outlet_anything(x->main_outlet, gensym("linkPosStd"),4 , std_out); +} + +void pmpd3d_linkLengthStd(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float sommeX, sommeY, sommeZ, somme, tmp; + t_int i,j; + t_float stdX, stdY, stdZ, std; + t_atom std_out[4]; + + sommeX = 0; + sommeY = 0; + sommeZ = 0; + somme = 0; + stdX = 0; + stdY = 0; + stdZ = 0; + std = 0; + j = 0; + + if ( (argc >= 1) && (argv[0].a_type == A_SYMBOL) ) + { + for (i=0; i< x->nb_link; i++) + { + if (atom_getsymbolarg(0,argc,argv) == x->link[i].Id) + { + sommeX += abs(x->link[i].mass1->posX - x->link[i].mass2->posX); + sommeX += abs(x->link[i].mass1->posY - x->link[i].mass2->posY); + sommeX += abs(x->link[i].mass1->posZ - x->link[i].mass2->posZ); + somme += x->link[i].distance; + j+=1; + } + } + } + else + { + for (i=0; i< x->nb_link; i++) + { + sommeX += abs(x->link[i].mass1->posX - x->link[i].mass2->posX); + sommeX += abs(x->link[i].mass1->posY - x->link[i].mass2->posY); + sommeX += abs(x->link[i].mass1->posZ - x->link[i].mass2->posZ); + somme += x->link[i].distance; + j+=1; + } + } + + sommeX /= j; + sommeY /= j; + sommeZ /= j; + somme /= j; + + if ( (argc >= 1) && (argv[0].a_type == A_SYMBOL) ) + { + for (i=0; i< x->nb_link; i++) + { + if (atom_getsymbolarg(0,argc,argv) == x->link[i].Id) + { + stdX += sqr(abs(x->link[i].mass1->posX - x->link[i].mass2->posX)-sommeX); + stdX += sqr(abs(x->link[i].mass1->posY - x->link[i].mass2->posY)-sommeY); + stdX += sqr(abs(x->link[i].mass1->posZ - x->link[i].mass2->posZ)-sommeZ); + std += sqr(x->link[i].distance - somme); + j+=1; + } + } + } + else + { + for (i=0; i< x->nb_link; i++) + { + stdX += sqr(abs(x->link[i].mass1->posX - x->link[i].mass2->posX) - sommeX); + stdX += sqr(abs(x->link[i].mass1->posY - x->link[i].mass2->posY) - sommeY); + stdX += sqr(abs(x->link[i].mass1->posZ - x->link[i].mass2->posZ) - sommeZ); + std += sqr(x->link[i].distance - somme); + j+=1; + } + } + + stdX = sqrt(stdX/j); + stdY = sqrt(stdY/j); + stdZ = sqrt(stdZ/j); + std = sqrt(std /j); + + SETFLOAT(&(std_out[0]),stdX); + SETFLOAT(&(std_out[1]),stdY); + SETFLOAT(&(std_out[2]),stdZ); + SETFLOAT(&(std_out[3]),std); + + outlet_anything(x->main_outlet, gensym("linkLengthStd"),4 , std_out); +} + +void pmpd3d_linkPosSpeedStd(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float sommeX, sommeY, sommeZ, somme; + t_float stdX, stdY, stdZ, std; + t_int i,j; + t_atom std_out[4]; + + sommeX = 0; + sommeY = 0; + sommeZ = 0; + somme = 0; + stdX = 0; + stdY = 0; + stdZ = 0; + std = 0; + j = 0; + + if ( (argc >= 1) && (argv[0].a_type == A_SYMBOL) ) + { + for (i=0; i< x->nb_link; i++) + { + if (atom_getsymbolarg(0,argc,argv) == x->link[i].Id) + { + sommeX += (x->link[i].mass1->speedX + x->link[i].mass2->speedX)/2; + sommeY += (x->link[i].mass1->speedY + x->link[i].mass2->speedY)/2; + sommeZ += (x->link[i].mass1->speedZ + x->link[i].mass2->speedZ)/2; + somme += 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)); + j++; + } + } + } + else + { + for (i=0; i< x->nb_link; i++) + { + sommeX += (x->link[i].mass1->speedX + x->link[i].mass2->speedX)/2; + sommeY += (x->link[i].mass1->speedY + x->link[i].mass2->speedY)/2; + sommeZ += (x->link[i].mass1->speedZ + x->link[i].mass2->speedZ)/2; + somme += 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)); + j++; + } + } + + sommeX /= j; + sommeY /= j; + sommeZ /= j; + somme /= j; + + if ( (argc >= 1) && (argv[0].a_type == A_SYMBOL) ) + { + for (i=0; i< x->nb_link; i++) + { + if (atom_getsymbolarg(0,argc,argv) == x->link[i].Id) + { + stdX += sqr((x->link[i].mass1->speedX + x->link[i].mass2->speedX)/2-sommeX); + stdY += sqr((x->link[i].mass1->speedY + x->link[i].mass2->speedY)/2-sommeY); + stdZ += sqr((x->link[i].mass1->speedZ + x->link[i].mass2->speedZ)/2-sommeZ); + somme += sqr(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)) - somme); + j++; + } + } + } + else + { + for (i=0; i< x->nb_link; i++) + { + stdX += sqr((x->link[i].mass1->speedX + x->link[i].mass2->speedX)/2-sommeX); + stdY += sqr((x->link[i].mass1->speedY + x->link[i].mass2->speedY)/2-sommeY); + stdZ += sqr((x->link[i].mass1->speedZ + x->link[i].mass2->speedZ)/2-sommeZ); + somme += sqr(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)) - somme); + j++; + } + } + + stdX = sqrt(stdX/j); + stdY = sqrt(stdY/j); + stdZ = sqrt(stdZ/j); + std = sqrt(std /j); + + SETFLOAT(&(std_out[0]),stdX); + SETFLOAT(&(std_out[1]),stdY); + SETFLOAT(&(std_out[2]),stdZ); + SETFLOAT(&(std_out[3]),std); + + outlet_anything(x->main_outlet, gensym("linkPosSpeedStd"),4 , std_out); +} + +void pmpd3d_linkLengthSpeedStd(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float sommeX, sommeY, sommeZ, somme, tmp; + t_float stdX, stdY, stdZ, std; + t_int i,j; + t_atom std_out[4]; + + sommeX = 0; + sommeY = 0; + sommeZ = 0; + somme = 0; + stdX = 0; + stdY = 0; + stdZ = 0; + std = 0; + j = 0; + + if ( (argc >= 1) && (argv[0].a_type == A_SYMBOL) ) + { + for (i=0; i< x->nb_link; i++) + { + if (atom_getsymbolarg(0,argc,argv) == x->link[i].Id) + { + sommeX += abs(x->link[i].mass1->speedX - x->link[i].mass2->speedX); + sommeX += abs(x->link[i].mass1->speedY - x->link[i].mass2->speedY); + sommeX += abs(x->link[i].mass1->speedZ - x->link[i].mass2->speedZ); + somme += sqrt(sqr(x->link[i].mass1->speedX - x->link[i].mass2->speedX) + + sqr(x->link[i].mass1->speedY - x->link[i].mass2->speedY) + + sqr(x->link[i].mass1->speedZ - x->link[i].mass2->speedZ)); + j++; + } + } + } + else + { + for (i=0; i< x->nb_link; i++) + { + sommeX += abs(x->link[i].mass1->speedX - x->link[i].mass2->speedX); + sommeX += abs(x->link[i].mass1->speedY - x->link[i].mass2->speedY); + sommeX += abs(x->link[i].mass1->speedZ - x->link[i].mass2->speedZ); + somme += sqrt(sqr(x->link[i].mass1->speedX - x->link[i].mass2->speedX) + + sqr(x->link[i].mass1->speedY - x->link[i].mass2->speedY) + + sqr(x->link[i].mass1->speedZ - x->link[i].mass2->speedZ)); + j++; + } + } + + sommeX /= j; + sommeY /= j; + sommeZ /= j; + somme /= j; + + if ( (argc >= 1) && (argv[0].a_type == A_SYMBOL) ) + { + for (i=0; i< x->nb_link; i++) + { + if (atom_getsymbolarg(0,argc,argv) == x->link[i].Id) + { + stdX += sqr(abs(x->link[i].mass1->speedX - x->link[i].mass2->speedX) - sommeX); + stdX += sqr(abs(x->link[i].mass1->speedY - x->link[i].mass2->speedY) - sommeY); + stdX += sqr(abs(x->link[i].mass1->speedZ - x->link[i].mass2->speedZ) - sommeZ); + std += sqr( sqrt(sqr(x->link[i].mass1->speedX - x->link[i].mass2->speedX) + + sqr(x->link[i].mass1->speedY - x->link[i].mass2->speedY) + + sqr(x->link[i].mass1->speedZ - x->link[i].mass2->speedZ)) - somme); + j++; + } + } + } + else + { + for (i=0; i< x->nb_link; i++) + { + stdX += sqr(abs(x->link[i].mass1->speedX - x->link[i].mass2->speedX) - sommeX); + stdX += sqr(abs(x->link[i].mass1->speedY - x->link[i].mass2->speedY) - sommeY); + stdX += sqr(abs(x->link[i].mass1->speedZ - x->link[i].mass2->speedZ) - sommeZ); + std += sqr( sqrt(sqr(x->link[i].mass1->speedX - x->link[i].mass2->speedX) + + sqr(x->link[i].mass1->speedY - x->link[i].mass2->speedY) + + sqr(x->link[i].mass1->speedZ - x->link[i].mass2->speedZ)) - somme); + j++; + } + } + + stdX = sqrt(stdX/j); + stdY = sqrt(stdY/j); + stdZ = sqrt(stdZ/j); + std = sqrt(std /j); + + SETFLOAT(&(std_out[0]),stdX); + SETFLOAT(&(std_out[1]),stdY); + SETFLOAT(&(std_out[2]),stdZ); + SETFLOAT(&(std_out[3]),std); + + outlet_anything(x->main_outlet, gensym("linkLengthSpeedStd"),4 , std_out); +} diff --git a/pmpd3d_tab.c b/pmpd3d_tab.c index 9278cb7..8550399 100644 --- a/pmpd3d_tab.c +++ b/pmpd3d_tab.c @@ -1888,3 +1888,575 @@ void pmpd3d_linksEndT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) } } } + +void pmpd3d_linksEndXT(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-1)/2); + for (i=0; i < taille_max ; i++) + { + vec[2*i ].w_float = x->link[i].mass1->posX; + vec[2*i+1].w_float = x->link[i].mass2->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-2) && (j < x->nb_link)) + { + if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id) + { + vec[i].w_float = x->link[j].mass1->posX; + i++; + vec[i].w_float = x->link[j].mass2->posX; + i++; + } + j++; + } + garray_redraw(a); + } + } +} + +void pmpd3d_linksEndYT(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-1)/2); + for (i=0; i < taille_max ; i++) + { + vec[2*i ].w_float = x->link[i].mass1->posY; + vec[2*i+1].w_float = x->link[i].mass2->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->link[j].Id) + { + vec[i].w_float = x->link[j].mass1->posY; + i++; + vec[i].w_float = x->link[j].mass2->posY; + i++; + } + j++; + } + garray_redraw(a); + } + } +} + +void pmpd3d_linksEndZT(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-1)/2); + for (i=0; i < taille_max ; i++) + { + vec[2*i ].w_float = x->link[i].mass1->posZ; + vec[2*i+1].w_float = x->link[i].mass2->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->link[j].Id) + { + vec[i].w_float = x->link[j].mass1->posZ; + i++; + vec[i].w_float = x->link[j].mass2->posZ; + i++; + } + j++; + } + garray_redraw(a); + } + } +} + +void pmpd3d_linksEnd1T(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].mass1->posX; + vec[3*i+1].w_float = x->link[i].mass1->posY; + vec[3*i+2].w_float = 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-3) && (j < x->nb_link)) + { + if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id) + { + vec[i].w_float = x->link[j].mass1->posX; + i++; + vec[i].w_float = x->link[j].mass1->posY; + i++; + vec[i].w_float = x->link[j].mass1->posZ; + i++; + } + j++; + } + garray_redraw(a); + } + } +} + +void pmpd3d_linksEnd1XT(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; + } + 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->link[j].Id) + { + vec[i].w_float = x->link[j].mass1->posX; + i++; + } + j++; + } + garray_redraw(a); + } + } +} + +void pmpd3d_linksEnd1YT(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; + } + 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->link[j].Id) + { + vec[i].w_float = x->link[j].mass1->posY; + i++; + } + j++; + } + garray_redraw(a); + } + } +} + +void pmpd3d_linksEnd1ZT(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; + } + 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->link[j].Id) + { + vec[i].w_float = x->link[j].mass1->posZ; + i++; + } + j++; + } + garray_redraw(a); + } + } +} + +void pmpd3d_linksEnd2T(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; + vec[3*i+1].w_float = x->link[i].mass2->posY; + vec[3*i+2].w_float = x->link[i].mass2->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-3) && (j < x->nb_link)) + { + if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id) + { + vec[i].w_float = x->link[j].mass2->posX; + i++; + vec[i].w_float = x->link[j].mass2->posY; + i++; + vec[i].w_float = x->link[j].mass2->posZ; + i++; + } + j++; + } + garray_redraw(a); + } + } +} + +void pmpd3d_linksEnd2XT(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; + } + 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->link[j].Id) + { + vec[i].w_float = x->link[j].mass2->posX; + i++; + } + j++; + } + garray_redraw(a); + } + } +} + +void pmpd3d_linksEnd2YT(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; + } + 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->link[j].Id) + { + vec[i].w_float = x->link[j].mass2->posY; + i++; + } + j++; + } + garray_redraw(a); + } + } +} + +void pmpd3d_linksEnd2ZT(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; + } + 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->link[j].Id) + { + vec[i].w_float = x->link[j].mass2->posZ; + i++; + } + j++; + } + garray_redraw(a); + } + } +} + diff --git a/pmpd3d_test.c b/pmpd3d_test.c new file mode 100644 index 0000000..8aa3a5f --- /dev/null +++ b/pmpd3d_test.c @@ -0,0 +1,446 @@ +int test_3d_mass(int i, t_pmpd3d *x, int argc, t_atom *argv) +{ + t_int tmp, tmp2; + t_int j = 1; + while (j < argc) + { + if (atom_getsymbolarg(j,argc,argv) == gensym("Id") ) + { + if ( x->mass[i].Id != atom_getsymbolarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if (atom_getsymbolarg(j,argc,argv) == gensym("posXSup") ) + { + if ( x->mass[i].posX < atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("posXInf") ) + { + if ( x->mass[i].posX >= atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if (atom_getsymbolarg(j,argc,argv) == gensym("posYSup") ) + { + if ( x->mass[i].posY < atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("posYInf") ) + { + if ( x->mass[i].posY >= atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if (atom_getsymbolarg(j,argc,argv) == gensym("posZSup") ) + { + if ( x->mass[i].posZ < atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("posZInf") ) + { + if ( x->mass[i].posZ >= atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedXSup") ) + { + if ( x->mass[i].speedX < atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedXInf") ) + { + if ( x->mass[i].speedX >= atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedYSup") ) + { + if ( x->mass[i].speedY < atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedYInf") ) + { + if ( x->mass[i].speedY >= atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedZSup") ) + { + if ( x->mass[i].speedZ < atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedZInf") ) + { + if ( x->mass[i].speedZ >= atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedSup") ) + { + tmp = x->mass[i].speedX * x->mass[i].speedX; + tmp += x->mass[i].speedY * x->mass[i].speedY; + tmp += x->mass[i].speedZ * x->mass[i].speedZ; + + if ( ( tmp < atom_getfloatarg(j+1,argc,argv)) * atom_getfloatarg(j+1,argc,argv) ) { return(0); } + + j+= 2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedInf") ) + { + tmp = x->mass[i].speedX * x->mass[i].speedX; + tmp += x->mass[i].speedY * x->mass[i].speedY; + tmp += x->mass[i].speedZ * x->mass[i].speedZ; + + if ( ( tmp >= atom_getfloatarg(j+1,argc,argv)) * atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if (atom_getsymbolarg(j,argc,argv) == gensym("distanceCircleInf")) + { + tmp = x->mass[i].posX - atom_getfloatarg(j+1,argc,argv); + tmp *= tmp; + tmp2 = x->mass[i].posY - atom_getfloatarg(j+2,argc,argv); + tmp = tmp + tmp2 * tmp2; + tmp2 = x->mass[i].posZ - atom_getfloatarg(j+3,argc,argv); + tmp = tmp + tmp2 * tmp2; + tmp2 = atom_getfloatarg(j+4,argc,argv); + + if ( tmp >= (tmp2 * tmp2) ) { return(0); } + j += 5; + } + else if (atom_getsymbolarg(j,argc,argv) == gensym("distanceCircleSup")) + { + tmp = x->mass[i].posX - atom_getfloatarg(j+1,argc,argv); + tmp *= tmp; + tmp2 = x->mass[i].posY - atom_getfloatarg(j+2,argc,argv); + tmp = tmp + tmp2 * tmp2; + tmp2 = x->mass[i].posZ - atom_getfloatarg(j+3,argc,argv); + tmp = tmp + tmp2 * tmp2; + tmp2 = atom_getfloatarg(j+4,argc,argv); + + if ( tmp < (tmp2 * tmp2) ) { return(0); } + j += 5; + } + else if (atom_getsymbolarg(j,argc,argv) == gensym("massSup")) + { + tmp = 1/ x->mass[i].invM; + if ( tmp < atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j += 2; + } + else if (atom_getsymbolarg(j,argc,argv) == gensym("massInf")) + { + tmp = 1/ x->mass[i].invM; + if ( tmp >= atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j += 2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("forceSup") ) + { + tmp = x->mass[i].forceX * x->mass[i].forceX; + tmp += x->mass[i].forceY * x->mass[i].forceY; + tmp += x->mass[i].forceZ * x->mass[i].forceZ; + + if ( ( tmp < atom_getfloatarg(j+1,argc,argv)) * atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+= 2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("forceInf") ) + { + tmp = x->mass[i].forceX * x->mass[i].forceX; + tmp += x->mass[i].forceY * x->mass[i].forceY; + tmp += x->mass[i].forceZ * x->mass[i].forceZ; + + if ( ( tmp >= atom_getfloatarg(j+1,argc,argv)) * atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+= 2; + } + else if (atom_getsymbolarg(j,argc,argv) == gensym("forceXSup") ) + { + if ( x->mass[i].forceX < atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if (atom_getsymbolarg(j,argc,argv) == gensym("forceXInf") ) + { + if ( x->mass[i].forceX >= atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if (atom_getsymbolarg(j,argc,argv) == gensym("forceYSup") ) + { + if ( x->mass[i].forceY < atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if (atom_getsymbolarg(j,argc,argv) == gensym("forceYInf") ) + { + if ( x->mass[i].forceY >= atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if (atom_getsymbolarg(j,argc,argv) == gensym("forceZSup") ) + { + if ( x->mass[i].forceZ < atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if (atom_getsymbolarg(j,argc,argv) == gensym("forceZInf") ) + { + if ( x->mass[i].forceZ >= atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else + { + post("nor reconize %s",atom_getsymbolarg(j,argc,argv)); + j+=1; + } + } + return(1); +} + +int test_3d_link(int i, t_pmpd3d *x, int argc, t_atom *argv) +{ + t_int j, tmp, tmp2; + j = 1; + + while (j < argc-1) + { + if (atom_getsymbolarg(j,argc,argv) == gensym("Id") ) + { + if ( x->link[i].Id != atom_getsymbolarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if (atom_getsymbolarg(j,argc,argv) == gensym("forceXSup") ) + { + if ( x->link[i].forceX < atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("forceXInf") ) + { + if ( x->link[i].forceX >= atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if (atom_getsymbolarg(j,argc,argv) == gensym("forceYSup") ) + { + if ( x->link[i].forceY < atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("forceYInf") ) + { + if ( x->link[i].forceY >= atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if (atom_getsymbolarg(j,argc,argv) == gensym("forceZSup") ) + { + if ( x->link[i].forceZ < atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("forceZInf") ) + { + if ( x->link[i].forceZ >= atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if (atom_getsymbolarg(j,argc,argv) == gensym("forceSup") ) + { + tmp = x->link[i].forceX; + tmp *= tmp; + tmp2 = x->link[i].forceY; + tmp = tmp + tmp2*tmp2; + tmp2 = x->link[i].forceZ; + tmp = tmp + tmp2*tmp2; + + tmp2 = atom_getfloatarg(j+1,argc,argv); + tmp2 *= tmp2; + + if ( tmp < tmp2 ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("forceInf") ) + { + tmp = x->link[i].forceX; + tmp = tmp * tmp; + tmp2 = x->link[i].forceY; + tmp = tmp + tmp2*tmp2; + tmp2 = x->link[i].forceZ; + tmp = tmp + tmp2*tmp2; + + tmp2 = atom_getfloatarg(j+1,argc,argv); + tmp2 *= tmp2; + + if ( tmp >= tmp2 ) { return(0); } + j+=2; + } + else if (atom_getsymbolarg(j,argc,argv) == gensym("lengthSup") ) + { + if ( x->link[i].distance < atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("lengthInf") ) + { + if ( x->link[i].distance >= atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("lengthXInf") ) + { + tmp = abs(x->link[i].mass1->posX - x->link[i].mass2->posX); + if ( tmp >= atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("lengthXSup") ) + { + tmp = abs(x->link[i].mass1->posX - x->link[i].mass2->posX); + if ( tmp < atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("lengthYInf") ) + { + tmp = abs(x->link[i].mass1->posY - x->link[i].mass2->posY); + if ( tmp >= atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("lengthYSup") ) + { + tmp = abs(x->link[i].mass1->posY - x->link[i].mass2->posY); + if ( tmp < atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("lengthZInf") ) + { + tmp = abs(x->link[i].mass1->posZ - x->link[i].mass2->posZ); + if ( tmp >= atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("lengthZSup") ) + { + tmp = abs(x->link[i].mass1->posZ - x->link[i].mass2->posZ); + if ( tmp < atom_getfloatarg(j+1,argc,argv) ) { return(0); } + j+=2; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("connectedTo") ) + { + if (argv[j+1].a_type == A_SYMBOL) + { + if (!( (x->link[i].mass1->Id == atom_getsymbolarg(j+1,argc,argv)) || (x->link[i].mass2->Id == atom_getsymbolarg(j+1,argc,argv)) )) + { return(0); } + j+=2; + } + else if (argv[j+1].a_type == A_FLOAT) + { + if (!( (x->link[i].mass1->num == atom_getfloatarg(j+1,argc,argv)) || (x->link[i].mass2->num == atom_getfloatarg(j+1,argc,argv)) )) + { return(0); } + j+=2; + } + else + { + post("bad argument for connectedTo"); + j+=1; + } + } + else + { + post("nor reconize %s",atom_getsymbolarg(j,argc,argv)); + j+=1; + } + } +} + +//---------------------------------------------------------------------- + +void pmpd3d_testMass(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) +{ + t_int i; + t_atom std_out[2]; + + SETSYMBOL(&(std_out[0]),atom_getsymbolarg(0,argc,argv)); + + for (i=0; i < x->nb_mass; i++) + { + if (test_3d_mass(i,x,argc,argv)) + { + SETFLOAT(&(std_out[1]),i); + outlet_anything(x->main_outlet, gensym("testMass"),2,std_out); + } + } +} + +void pmpd3d_testLink(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) +{ + t_int i; + t_atom std_out[2]; + + SETSYMBOL(&(std_out[0]),atom_getsymbolarg(0,argc,argv)); + + for (i=0; i < x->nb_link; i++) + { + if (test_3d_link(i,x,argc,argv)) + { + SETFLOAT(&(std_out[1]),i); + outlet_anything(x->main_outlet, gensym("testLink"),1,std_out); + } + } +} + +void pmpd3d_testLinkT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) +{ + int i, vecsize; + t_garray *a; + t_word *vec; + + if (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 = (t_float)test_3d_link(i,x,argc,argv); + } + garray_redraw(a); + } + } +} + +void pmpd3d_testMassT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) +{ + int i, vecsize; + t_garray *a; + t_word *vec; + + if (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_mass; + taille_max = min(taille_max, vecsize); + + for (i=0; i < taille_max; i++) + { + vec[i].w_float = (t_float)test_3d_mass(i,x,argc,argv); + } + garray_redraw(a); + } + } +} + +void pmpd3d_testLinkL(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom list[x->nb_link+1]; + + for (i=0; i < x->nb_link; i++) + { + SETFLOAT(&(list[i+1]), test_3d_link(i,x,argc,argv)); + } + SETSYMBOL(&(list[0]),atom_getsymbolarg(0,argc,argv)); + outlet_anything(x->main_outlet, gensym("testLink"),x->nb_link+1 , list); +} + +void pmpd3d_testMassL(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom list[x->nb_mass+1]; + + for (i=0; i < x->nb_mass; i++) + { + SETFLOAT(&(list[i+1]), test_3d_link(i,x,argc,argv)); + } + SETSYMBOL(&(list[0]),atom_getsymbolarg(0,argc,argv)); + outlet_anything(x->main_outlet, gensym("testMass"),x->nb_mass+1 , list); +} diff --git a/pmpd3d_various.c b/pmpd3d_various.c index 5ff2ec5..88713c6 100644 --- a/pmpd3d_various.c +++ b/pmpd3d_various.c @@ -418,263 +418,6 @@ void pmpd3d_massesDistances(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) } } -void pmpd3d_enumMasses(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) -{ - t_int i, j, test, tmp, tmp2; - t_atom std_out[1]; - - - for (i=0; i < x->nb_mass; i++) - { - j = 0; - test = 1; - - while ( (j < argc-1) && (test) ) - { - if (atom_getsymbolarg(j,argc,argv) == gensym("Id") ) - { - if ( x->mass[i].Id != atom_getsymbolarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if (atom_getsymbolarg(j,argc,argv) == gensym("posXSup") ) - { - if ( x->mass[i].posX < atom_getfloatarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if ( atom_getsymbolarg(j,argc,argv) == gensym("posXInf") ) - { - if ( x->mass[i].posX > atom_getfloatarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if (atom_getsymbolarg(j,argc,argv) == gensym("posYSup") ) - { - if ( x->mass[i].posY < atom_getfloatarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if ( atom_getsymbolarg(j,argc,argv) == gensym("posYInf") ) - { - if ( x->mass[i].posY > atom_getfloatarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if (atom_getsymbolarg(j,argc,argv) == gensym("posZSup") ) - { - if ( x->mass[i].posZ < atom_getfloatarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if ( atom_getsymbolarg(j,argc,argv) == gensym("posZInf") ) - { - if ( x->mass[i].posZ > atom_getfloatarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedXSup") ) - { - if ( x->mass[i].speedX < atom_getfloatarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedXInf") ) - { - if ( x->mass[i].speedX > atom_getfloatarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedYSup") ) - { - if ( x->mass[i].speedY < atom_getfloatarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedYInf") ) - { - if ( x->mass[i].speedY > atom_getfloatarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedZSup") ) - { - if ( x->mass[i].speedZ < atom_getfloatarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedZInf") ) - { - if ( x->mass[i].speedZ > atom_getfloatarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedSup") ) - { - tmp = x->mass[i].speedX * x->mass[i].speedX; - tmp += x->mass[i].speedY * x->mass[i].speedY; - tmp += x->mass[i].speedZ * x->mass[i].speedZ; - - if ( ( tmp < atom_getfloatarg(j+1,argc,argv)) * atom_getfloatarg(j+1,argc,argv) ) test = 0; - - j+= 2; - } - else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedInf") ) - { - tmp = x->mass[i].speedX * x->mass[i].speedX; - tmp += x->mass[i].speedY * x->mass[i].speedY; - tmp += x->mass[i].speedZ * x->mass[i].speedZ; - - if ( ( tmp > atom_getfloatarg(j+1,argc,argv)) * atom_getfloatarg(j+1,argc,argv) ) test = 0; - j+=2; - } - else if (atom_getsymbolarg(j,argc,argv) == gensym("distanceCircleInf")) - { - tmp = x->mass[i].posX - atom_getfloatarg(j+1,argc,argv); - tmp *= tmp; - tmp2 = x->mass[i].posY - atom_getfloatarg(j+2,argc,argv); - tmp = tmp + tmp2 * tmp2; - tmp2 = x->mass[i].posZ - atom_getfloatarg(j+3,argc,argv); - tmp = tmp + tmp2 * tmp2; - tmp2 = atom_getfloatarg(j+4,argc,argv); - - if ( tmp > (tmp2 * tmp2) ) test = 0; - j += 5; - } - else if (atom_getsymbolarg(j,argc,argv) == gensym("distanceCircleSup")) - { - tmp = x->mass[i].posX - atom_getfloatarg(j+1,argc,argv); - tmp *= tmp; - tmp2 = x->mass[i].posY - atom_getfloatarg(j+2,argc,argv); - tmp = tmp + tmp2 * tmp2; - tmp2 = x->mass[i].posZ - atom_getfloatarg(j+3,argc,argv); - tmp = tmp + tmp2 * tmp2; - tmp2 = atom_getfloatarg(j+4,argc,argv); - - if ( tmp < (tmp2 * tmp2) ) test = 0; - j += 5; - } - // mass weight - else - { - post("nor reconize %s",atom_getsymbolarg(j,argc,argv)); - j+=1; - } - } - if (test) - { - SETFLOAT(&(std_out[0]),i); - outlet_anything(x->main_outlet, gensym("listMasses"),1,std_out); - } - } -} - -void pmpd3d_enumLinks(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) -{ - t_int i, j, test, tmp, tmp2; - t_atom std_out[1]; - - - for (i=0; i < x->nb_link; i++) - { - j = 0; - test = 1; - - while ( (j < argc-1) && (test) ) - { - - if (atom_getsymbolarg(j,argc,argv) == gensym("Id") ) - { - if ( x->link[i].Id != atom_getsymbolarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if (atom_getsymbolarg(j,argc,argv) == gensym("forcesXSup") ) - { - if ( x->link[i].forceX < atom_getfloatarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if ( atom_getsymbolarg(j,argc,argv) == gensym("forcesXInf") ) - { - if ( x->link[i].forceX > atom_getfloatarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if (atom_getsymbolarg(j,argc,argv) == gensym("forcesYSup") ) - { - if ( x->link[i].forceY < atom_getfloatarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if ( atom_getsymbolarg(j,argc,argv) == gensym("forcesYInf") ) - { - if ( x->link[i].forceY > atom_getfloatarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if (atom_getsymbolarg(j,argc,argv) == gensym("forcesZSup") ) - { - if ( x->link[i].forceZ < atom_getfloatarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if ( atom_getsymbolarg(j,argc,argv) == gensym("forcesZInf") ) - { - if ( x->link[i].forceZ > atom_getfloatarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if (atom_getsymbolarg(j,argc,argv) == gensym("forcesSup") ) - { - tmp = x->link[i].forceX; - tmp *= tmp; - tmp2 = x->link[i].forceY; - tmp = tmp + tmp2*tmp2; - tmp2 = x->link[i].forceZ; - tmp = tmp + tmp2*tmp2; - - tmp2 = atom_getfloatarg(j+1,argc,argv); - tmp2 *= tmp2; - - if ( tmp < tmp2 ) { test = 0; j+=2;} - } - else if ( atom_getsymbolarg(j,argc,argv) == gensym("forcesInf") ) - { - tmp = x->link[i].forceX; - tmp = tmp * tmp; - tmp2 = x->link[i].forceY; - tmp = tmp + tmp2*tmp2; - tmp2 = x->link[i].forceZ; - tmp = tmp + tmp2*tmp2; - - tmp2 = atom_getfloatarg(j+1,argc,argv); - tmp2 *= tmp2; - - if ( tmp > tmp2 ) { test = 0; j+=2;} - } - else if (atom_getsymbolarg(j,argc,argv) == gensym("lengthSup") ) - { - if ( x->link[i].distance < atom_getfloatarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if ( atom_getsymbolarg(j,argc,argv) == gensym("lengthInf") ) - { - if ( x->link[i].distance > atom_getfloatarg(j+1,argc,argv) ) { test = 0; } - j+=2; - } - else if ( atom_getsymbolarg(j,argc,argv) == gensym("connectedTo") ) - { - if (argv[j+1].a_type == A_SYMBOL) - { - if (!( (x->link[i].mass1->Id == atom_getsymbolarg(j+1,argc,argv)) || (x->link[i].mass2->Id == atom_getsymbolarg(j+1,argc,argv)) )) - { test = 0; j+=2;} - } - else if (argv[j+1].a_type == A_FLOAT) - { - if (!( (x->link[i].mass1->num == atom_getfloatarg(j+1,argc,argv)) || (x->link[i].mass2->num == atom_getfloatarg(j+1,argc,argv)) )) - { test = 0; j+=2;} - } - else - { - post("bad argument for connectedTo"); - j+=1; - } - } - else - { - post("nor reconize %s",atom_getsymbolarg(j,argc,argv)); - j+=1; - } - } - if (test) - { - SETFLOAT(&(std_out[0]),i); - outlet_anything(x->main_outlet, gensym("listLinks"),1,std_out); - } - } -} - void pmpd3d_forcesXT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) { // add forces to masses. forces comes from a table, masse can be filter on ther Id or not |