diff options
-rw-r--r-- | TODO.txt | 4 | ||||
-rw-r--r-- | pmpd2d_various.c | 18 | ||||
-rw-r--r-- | pmpd3d_various.c | 23 |
3 files changed, 23 insertions, 22 deletions
@@ -23,11 +23,9 @@ DONE : - rename message posX to setPosX - debug "setL Id" with no arg : bad computation of link length (2d / 3d) - lot's of bugfix +- switch to makefile template 1.0.14 TODO : -massDistance : ajouter distanceX, Y, et Z - - closestNeighbor linkEndL add creation parametter to fix maximum number of link and mass diff --git a/pmpd2d_various.c b/pmpd2d_various.c index c6151cf..8a33f5d 100644 --- a/pmpd2d_various.c +++ b/pmpd2d_various.c @@ -289,19 +289,21 @@ void pmpd2d_closestMass(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)// t_fl void pmpd2d_massDistances_f_f(t_pmpd2d *x, t_int i, t_int j) { - t_float dist, tmp; - t_atom to_out[3]; + t_float dist, tmp, dx, dy; + t_atom to_out[5]; - tmp = x->mass[i].posX - x->mass[j].posX; - dist = sqr(tmp); - tmp = x->mass[i].posY - x->mass[j].posY; - dist += sqr(tmp); + + dx = x->mass[i].posX - x->mass[j].posX; + dy = x->mass[i].posY - x->mass[j].posY; + dist = sqr(dx) + sqr(dy); dist = sqrt(dist); SETFLOAT(&(to_out[0]), i); SETFLOAT(&(to_out[1]), j); - SETFLOAT(&(to_out[2]), dist); - outlet_anything(x->main_outlet, gensym("distance"), 3, to_out); + SETFLOAT(&(to_out[2]), dx); + SETFLOAT(&(to_out[3]), dy); + SETFLOAT(&(to_out[4]), dist); + outlet_anything(x->main_outlet, gensym("distance"), 5, to_out); } void pmpd2d_massDistances(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) diff --git a/pmpd3d_various.c b/pmpd3d_various.c index c67fc89..e05fc23 100644 --- a/pmpd3d_various.c +++ b/pmpd3d_various.c @@ -355,21 +355,22 @@ void pmpd3d_closestMass(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) void pmpd3d_massDistances_f_f(t_pmpd3d *x, t_int i, t_int j) { - t_float dist, tmp; - t_atom to_out[3]; - - tmp = x->mass[i].posX - x->mass[j].posX; - dist = sqr(tmp); - tmp = x->mass[i].posY - x->mass[j].posY; - dist += sqr(tmp); - tmp = x->mass[i].posZ - x->mass[j].posZ; - dist += sqr(tmp); + t_float dist, tmp,dx,dy,dz; + t_atom to_out[6]; + + dx = x->mass[i].posX - x->mass[j].posX; + dy = x->mass[i].posY - x->mass[j].posY; + dz = x->mass[i].posZ - x->mass[j].posZ; + dist = sqr(dx) + sqr(dy) + sqr(dz); dist = sqrt(dist); SETFLOAT(&(to_out[0]), i); SETFLOAT(&(to_out[1]), j); - SETFLOAT(&(to_out[2]), dist); - outlet_anything(x->main_outlet, gensym("distance"), 3, to_out); + SETFLOAT(&(to_out[2]), dx); + SETFLOAT(&(to_out[3]), dy); + SETFLOAT(&(to_out[4]), dz); + SETFLOAT(&(to_out[5]), dist); + outlet_anything(x->main_outlet, gensym("distance"), 6, to_out); } void pmpd3d_massDistances(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) |