From 6e61a93db2dceb3aba8c1b1623d41a9f19d4b7a0 Mon Sep 17 00:00:00 2001 From: Cyrille Henry Date: Tue, 22 Jan 2013 10:43:25 +0000 Subject: add a field for saving force in link structure so that it's possibile to filter link regarding to last force generated svn path=/trunk/externals/pmpd/; revision=16944 --- pmpd3d.c | 8 ++++++++ pmpd3d_various.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/pmpd3d.c b/pmpd3d.c index 71320b4..a19e091 100644 --- a/pmpd3d.c +++ b/pmpd3d.c @@ -96,6 +96,9 @@ typedef struct _link { t_symbol *arrayD; t_float K_L; // longeur du tabeau K t_float D_L; // longeur du tabeau D + t_float forceX; + t_float forceY; + t_float forceZ; } foo1 ; typedef struct _pmpd3d { @@ -243,6 +246,9 @@ void pmpd3d_bang(t_pmpd3d *x) x->link[i].mass2->forceX += Fx; x->link[i].mass2->forceY += Fy; x->link[i].mass2->forceZ += Fz; + x->link[i].forceX = Fx; // save for latter use + x->link[i].forceY = Fy; + x->link[i].forceZ = Fz; } x->link[i].distance=L; } @@ -551,7 +557,9 @@ void pmpd3d_setup(void) 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); diff --git a/pmpd3d_various.c b/pmpd3d_various.c index b5688a1..48a6835 100644 --- a/pmpd3d_various.c +++ b/pmpd3d_various.c @@ -667,7 +667,7 @@ void pmpd3d_enumMasses(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) void pmpd3d_enumLinks(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) { - t_int i, j, test; + t_int i, j, test, tmp, tmp2; t_atom std_out[1]; j = 0; @@ -682,7 +682,7 @@ void pmpd3d_enumLinks(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) { if ( x->link[i].Id != atom_getsymbolarg(j+1,argc,argv) ) { test = 0; j+=2;} } -/* else if (atom_getsymbolarg(j,argc,argv) == gensym("forcesXSup") ) + else if (atom_getsymbolarg(j,argc,argv) == gensym("forcesXSup") ) { if ( x->link[i].forceX < atom_getfloatarg(j+1,argc,argv) ) { test = 0; j+=2;} } @@ -690,7 +690,51 @@ void pmpd3d_enumLinks(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) { if ( x->link[i].forceX > atom_getfloatarg(j+1,argc,argv) ) { test = 0; j+=2;} } -*/ else if (atom_getsymbolarg(j,argc,argv) == gensym("lengthSup") ) + 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;} } -- cgit v1.2.1