diff options
author | Cyrille Henry <nusmuk@users.sourceforge.net> | 2013-04-08 22:54:39 +0000 |
---|---|---|
committer | Cyrille Henry <nusmuk@users.sourceforge.net> | 2013-04-08 22:54:39 +0000 |
commit | 308f704b85f93da39a8a3559c11aab1dac9ae2f9 (patch) | |
tree | de6cf8ced157a77d342e4e38119a375df7ef5e6d | |
parent | f4e258a9d70ea1355e3e4bcce676e35c511ff3f3 (diff) |
bugfix and code refactorisation
svn path=/trunk/externals/pmpd/; revision=17071
-rw-r--r-- | pmpd3d.c | 9 | ||||
-rw-r--r-- | pmpd3d_set.c | 4 | ||||
-rw-r--r-- | pmpd3d_stat.c | 13 | ||||
-rw-r--r-- | pmpd3d_tab.c | 3 | ||||
-rw-r--r-- | pmpd3d_various.c | 4 |
5 files changed, 14 insertions, 19 deletions
@@ -51,7 +51,6 @@ void pmpd3d_setup(void) (t_newmethod)pmpd3d_new,
0, sizeof(t_pmpd3d),CLASS_DEFAULT, 0);
/*
-
pmpd3d_core
--
Basic functions for creation of the structure
@@ -81,14 +80,14 @@ void pmpd3d_setup(void) 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_setSpeed, gensym("setSpeed"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_setSpeedX, gensym("setSpeedX"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_setSpeedY, gensym("setSpeedY"), A_GIMME, 0);
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_setForce, gensym("setForce"), 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);
@@ -162,7 +161,7 @@ void pmpd3d_setup(void) class_addmethod(pmpd3d_class, (t_method)pmpd3d_linkLengthSpeedNormL, gensym("linkLengthSpeedNormL"), A_GIMME, 0);
/*
- pmpd3d_list
+ pmpd3d_tab
--
Functions to copy the internal state of the object in arrays
Output Syntax : none
@@ -334,7 +333,7 @@ void pmpd3d_setup(void) 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_massDistances, 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);
diff --git a/pmpd3d_set.c b/pmpd3d_set.c index 1e5dddc..fccdb26 100644 --- a/pmpd3d_set.c +++ b/pmpd3d_set.c @@ -137,6 +137,7 @@ void pmpd3d_setL(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) } } } + void pmpd3d_setLCurrent(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) { int tmp, i; @@ -175,8 +176,6 @@ void pmpd3d_setLCurrent(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; @@ -677,7 +676,6 @@ void pmpd3d_posZ(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) } } - void pmpd3d_overdamp(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) { // set the overdamped factor to a mass diff --git a/pmpd3d_stat.c b/pmpd3d_stat.c index 18ab6ff..b88a93b 100644 --- a/pmpd3d_stat.c +++ b/pmpd3d_stat.c @@ -443,7 +443,7 @@ void pmpd3d_linkPosMean(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) 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)); + somme += sqrt(sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + sqr((x->link[i].mass1->posY + x->link[i].mass2->posY)/2) + sqr((x->link[i].mass1->posZ + x->link[i].mass1->posZ)/2)); j++; } } @@ -455,7 +455,7 @@ void pmpd3d_linkPosMean(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) 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)); + somme += sqrt(sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + sqr((x->link[i].mass1->posY + x->link[i].mass2->posY)/2) + sqr((x->link[i].mass1->posZ + x->link[i].mass1->posZ)/2)); j++; } } @@ -668,7 +668,7 @@ void pmpd3d_linkPosStd(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) 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)); + somme += sqrt(sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + sqr((x->link[i].mass1->posY + x->link[i].mass2->posY)/2) + sqr((x->link[i].mass1->posZ + x->link[i].mass1->posZ)/2)); j++; } } @@ -680,7 +680,7 @@ void pmpd3d_linkPosStd(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) 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)); + somme += sqrt(sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + sqr((x->link[i].mass1->posY + x->link[i].mass2->posY)/2) + sqr((x->link[i].mass1->posZ + x->link[i].mass1->posZ)/2)); j++; } } @@ -702,7 +702,7 @@ void pmpd3d_linkPosStd(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) 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); + std += sqr(sqrt(sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + sqr((x->link[i].mass1->posY + x->link[i].mass2->posY)/2) + sqr((x->link[i].mass1->posZ + x->link[i].mass1->posZ)/2)) - somme); j+=1; } } @@ -714,7 +714,7 @@ void pmpd3d_linkPosStd(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) 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); + std += sqr(sqrt(sqr((x->link[i].mass1->posX + x->link[i].mass2->posX)/2) + sqr((x->link[i].mass1->posY + x->link[i].mass2->posY)/2) + sqr((x->link[i].mass1->posZ + x->link[i].mass1->posZ)/2)) - somme); j+=1; } } @@ -1016,7 +1016,6 @@ void pmpd3d_linkLengthSpeedStd(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) std = sqrt(std /j); } - SETFLOAT(&(std_out[0]),stdX); SETFLOAT(&(std_out[1]),stdY); SETFLOAT(&(std_out[2]),stdZ); diff --git a/pmpd3d_tab.c b/pmpd3d_tab.c index be7f9ff..15b74f8 100644 --- a/pmpd3d_tab.c +++ b/pmpd3d_tab.c @@ -1848,7 +1848,6 @@ void pmpd3d_linkEndT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) vec[6*i+3].w_float = x->link[i].mass2->posX; vec[6*i+4].w_float = x->link[i].mass2->posY; vec[6*i+5].w_float = x->link[i].mass2->posZ; - } garray_redraw(a); } @@ -1865,7 +1864,7 @@ void pmpd3d_linkEndT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) { i = 0; j = 0; - while ((i < vecsize-6) && (j < x->nb_link)) + while ((i < vecsize-5) && (j < x->nb_link)) { if (atom_getsymbolarg(1,argc,argv) == x->link[j].Id) { diff --git a/pmpd3d_various.c b/pmpd3d_various.c index d33828d..1004601 100644 --- a/pmpd3d_various.c +++ b/pmpd3d_various.c @@ -353,7 +353,7 @@ void pmpd3d_closestMass(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) } -void pmpd3d_massesDistances_f_f(t_pmpd3d *x, t_int i, t_int j) +void pmpd3d_massDistances_f_f(t_pmpd3d *x, t_int i, t_int j) { t_float dist, tmp; t_atom to_out[3]; @@ -372,7 +372,7 @@ void pmpd3d_massesDistances_f_f(t_pmpd3d *x, t_int i, t_int j) outlet_anything(x->main_outlet, gensym("distance"), 3, to_out); } -void pmpd3d_massesDistances(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) +void pmpd3d_massDistances(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) { t_int i,j; |