From ebbeac04a2f1f57cac1bfd87b6da0f58c033e9a8 Mon Sep 17 00:00:00 2001 From: "N.N." Date: Thu, 28 Apr 2005 15:22:14 +0000 Subject: MSD version 0.05 svn path=/trunk/externals/nusmuk/; revision=2846 --- msd2D/main.cpp | 438 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 239 insertions(+), 199 deletions(-) (limited to 'msd2D/main.cpp') diff --git a/msd2D/main.cpp b/msd2D/main.cpp index ccefdc6..436703b 100755 --- a/msd2D/main.cpp +++ b/msd2D/main.cpp @@ -30,7 +30,7 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Version 0.04 -- 26.04.2005 + Version 0.05 -- 28.04.2005 */ // include flext header @@ -38,7 +38,7 @@ #include // define constants -#define MSD2D_VERSION 0.04 +#define MSD2D_VERSION 0.05 #define nb_max_link 4000 #define nb_max_mass 4000 #define Id_length 20 @@ -115,13 +115,14 @@ protected: void m_reset() { t_int i; -// t_atom sortie; + t_mass **mi; + t_link **li; - for (i=0; imass1->posX-link[i]->mass2->posX,2) + - pow(link[i]->mass1->posY-link[i]->mass2->posY,2)); // L[n] = sqrt( (x1-x2)² +(y1-y2)²) - if (distance < link[i]->long_min || distance > link[i]->long_max) { + distance = sqrt(pow((*li)->mass1->posX-(*li)->mass2->posX,2) + + pow((*li)->mass1->posY-(*li)->mass2->posY,2)); // L[n] = sqrt( (x1-x2)² +(y1-y2)²) + if (distance < (*li)->long_min || distance > (*li)->long_max) { Fx = 0; Fy = 0; } else { - F = link[i]->K1 * (distance - link[i]->longueur) ; // F[n] = k1 (L[n] - L[0]) - F += link[i]->D1 * (distance - link[i]->distance_old) ; // F[n] = F[n] + D1 (L[n] - L[n-1]) + F = (*li)->K1 * (distance - (*li)->longueur) ; // F[n] = k1 (L[n] - L[0]) + F += (*li)->D1 * (distance - (*li)->distance_old) ; // F[n] = F[n] + D1 (L[n] - L[n-1]) if (distance != 0) { - Fx = F * (link[i]->mass1->posX - link[i]->mass2->posX)/distance; // Fx = F * Lx[n]/L[n] - Fy = F * (link[i]->mass1->posY - link[i]->mass2->posY)/distance; // Fy = F * Ly[n]/L[n] + Fx = F * ((*li)->mass1->posX - (*li)->mass2->posX)/distance; // Fx = F * Lx[n]/L[n] + Fy = F * ((*li)->mass1->posY - (*li)->mass2->posY)/distance; // Fy = F * Ly[n]/L[n] } } - link[i]->mass1->forceX -= Fx; // Fx1[n] = -Fx - link[i]->mass1->forceX -= link[i]->D2*link[i]->mass1->speedX; // Fx1[n] = Fx1[n] - D2 * vx1[n-1] - link[i]->mass2->forceX += Fx; // Fx2[n] = Fx - link[i]->mass2->forceX -= link[i]->D2*link[i]->mass2->speedX; // Fx2[n] = Fx2[n] - D2 * vx2[n-1] - link[i]->mass1->forceY -= Fy; // Fy1[n] = -Fy - link[i]->mass1->forceY -= link[i]->D2*link[i]->mass1->speedY; // Fy1[n] = Fy1[n] - D2 * vy1[n-1] - link[i]->mass2->forceY += Fy; // Fy2[n] = Fy - link[i]->mass2->forceY -= link[i]->D2*link[i]->mass2->speedY; // Fy1[n] = Fy1[n] - D2 * vy1[n-1] - link[i]->distance_old = distance; // L[n-1] = L[n] + (*li)->mass1->forceX -= Fx; // Fx1[n] = -Fx + (*li)->mass1->forceX -= (*li)->D2*(*li)->mass1->speedX; // Fx1[n] = Fx1[n] - D2 * vx1[n-1] + (*li)->mass2->forceX += Fx; // Fx2[n] = Fx + (*li)->mass2->forceX -= (*li)->D2*(*li)->mass2->speedX; // Fx2[n] = Fx2[n] - D2 * vx2[n-1] + (*li)->mass1->forceY -= Fy; // Fy1[n] = -Fy + (*li)->mass1->forceY -= (*li)->D2*(*li)->mass1->speedY; // Fy1[n] = Fy1[n] - D2 * vy1[n-1] + (*li)->mass2->forceY += Fy; // Fy2[n] = Fy + (*li)->mass2->forceY -= (*li)->D2*(*li)->mass2->speedY; // Fy1[n] = Fy1[n] - D2 * vy1[n-1] + (*li)->distance_old = distance; // L[n-1] = L[n] } - for (i=0; imobile == 1) { - X_new = mass[i]->forceX * mass[i]->invM + 2*mass[i]->posX - mass[i]->posX2; // x[n] =Fx[n]/M+2x[n]-x[n-1] - mass[i]->posX2 = mass[i]->posX; // x[n-2] = x[n-1] - mass[i]->posX = max(min(X_new,Xmax),Xmin); // x[n-1] = x[n] - mass[i]->speedX = mass[i]->posX - mass[i]->posX2; // vx[n] = x[n] - x[n-1] - Y_new = mass[i]->forceY * mass[i]->invM + 2*mass[i]->posY - mass[i]->posY2; // x[n] =Fx[n]/M+2x[n]-x[n-1] - mass[i]->posY2 = mass[i]->posY; // x[n-2] = x[n-1] - mass[i]->posY = max(min(Y_new,Ymax),Ymin); // x[n-1] = x[n] - mass[i]->speedY = mass[i]->posY - mass[i]->posY2; // vx[n] = x[n] - x[n-1] + if ((*mi)->mobile == 1) { + X_new = (*mi)->forceX * (*mi)->invM + 2*(*mi)->posX - (*mi)->posX2; // x[n] =Fx[n]/M+2x[n]-x[n-1] + (*mi)->posX2 = (*mi)->posX; // x[n-2] = x[n-1] + (*mi)->posX = max(min(X_new,Xmax),Xmin); // x[n-1] = x[n] + (*mi)->speedX = (*mi)->posX - (*mi)->posX2; // vx[n] = x[n] - x[n-1] + Y_new = (*mi)->forceY * (*mi)->invM + 2*(*mi)->posY - (*mi)->posY2; // x[n] =Fx[n]/M+2x[n]-x[n-1] + (*mi)->posY2 = (*mi)->posY; // x[n-2] = x[n-1] + (*mi)->posY = max(min(Y_new,Ymax),Ymin); // x[n-1] = x[n] + (*mi)->speedY = (*mi)->posY - (*mi)->posY2; // vx[n] = x[n] - x[n-1] } - for (i=0; iout_forceX = mass[i]->forceX; - mass[i]->forceX = 0; // Fx[n] = 0 - mass[i]->out_forceY = mass[i]->forceY; - mass[i]->forceY = 0; // Fy[n] = 0 + (*mi)->out_forceX = (*mi)->forceX; + (*mi)->forceX = 0; // Fx[n] = 0 + (*mi)->out_forceY = (*mi)->forceY; + (*mi)->forceY = 0; // Fy[n] = 0 } } @@ -231,34 +233,54 @@ protected: void m_forceX(int argc,t_atom *argv) { - // add a force to mass(es) named Id + // add a force to mass(es) named Id or No t_int i; - const t_symbol *sym = GetSymbol(argv[0]); + const t_symbol *sym = GetASymbol(argv[0]); + t_mass **mi; if (argc != 2) error("forceX : Idmass value"); - for (i=0; iId) - mass[i]->forceX += GetFloat(argv[1]); - } + if (sym ==0) + for (i=0, mi=mass; inbr) { + (*mi)->forceX = GetFloat(argv[1]); + break; + } + } + else + for (i=0, mi=mass; iId) + (*mi)->forceX = GetFloat(argv[1]); + } } void m_forceY(int argc,t_atom *argv) { - // add a force to mass(es) named Id + // add a force to mass(es) named Id or No t_int i; - const t_symbol *sym = GetSymbol(argv[0]); + const t_symbol *sym = GetASymbol(argv[0]); + t_mass **mi; if (argc != 2) - error("forceY : Idmass value"); + error("forceX : Idmass value"); - for (i=0; iId) - mass[i]->forceY += GetFloat(argv[1]); - } + if (sym ==0) + for (i=0, mi=mass; inbr) { + (*mi)->forceY = GetFloat(argv[1]); + break; + } + } + else + for (i=0, mi=mass; iId) + (*mi)->forceY = GetFloat(argv[1]); + } } void m_posX(int argc,t_atom *argv) @@ -266,24 +288,25 @@ protected: // displace mass(es) named Id to a certain position t_int i; const t_symbol *sym = GetASymbol(argv[0]); + t_mass **mi; if (argc != 2) error("posX : Id/Nomass value"); if (GetFloat(argv[1]) < Xmax && GetFloat(argv[1]) > Xmin) if (sym ==0) - for (i=0; inbr) { - mass[i]->posX = GetFloat(argv[1]); + if (GetInt(argv[0]) == (*mi)->nbr) { + (*mi)->posX = GetFloat(argv[1]); break; } } else - for (i=0; iId) - mass[i]->posX = GetFloat(argv[1]); + if (sym == (*mi)->Id) + (*mi)->posX = GetFloat(argv[1]); } } @@ -292,24 +315,25 @@ protected: // displace mass(es) named Id to a certain position t_int i; const t_symbol *sym = GetASymbol(argv[0]); + t_mass **mi; if (argc != 2) error("posY : Id/Nomass value"); if (GetFloat(argv[1]) < Ymax && GetFloat(argv[1]) > Ymin) if (sym ==0) - for (i=0; inbr) { - mass[i]->posY = GetFloat(argv[1]); + if (GetInt(argv[0]) == (*mi)->nbr) { + (*mi)->posY = GetFloat(argv[1]); break; } } else - for (i=0; iId) - mass[i]->posY = GetFloat(argv[1]); + if (sym == (*mi)->Id) + (*mi)->posY = GetFloat(argv[1]); } } @@ -317,15 +341,16 @@ protected: { // set mass No to mobile t_int i,aux; + t_mass **mi; if (argc != 1) error("setMobile : Idmass"); aux = GetInt(argv[0]); - for (i=0; inbr == aux) - mass[i]->mobile = 1; + if ((*mi)->nbr == aux) + (*mi)->mobile = 1; } } @@ -334,15 +359,16 @@ protected: { // set mass No to fixed t_int i,aux; + t_mass **mi; if (argc != 1) error("setFixed : Idmass"); aux = GetAInt(argv[0]); - for (i=0; inbr == aux) - mass[i]->mobile = 0; + if ((*mi)->nbr == aux) + (*mi)->mobile = 0; } } @@ -353,14 +379,16 @@ protected: t_int i,nb_link_delete=0; t_atom sortie[6]; NEWARR(t_atom,aux,nb_link); + t_mass **mi; + t_link **li; if (argc != 1) error("deleteMass : Nomass"); // Delete associated links - for (i=0; imass1->nbr == GetInt(argv[0]) || link[i]->mass2->nbr == GetInt(argv[0])) { - SetFloat((aux[nb_link_delete]),link[i]->nbr); + for (i=0, li=link; imass1->nbr == GetInt(argv[0]) || (*li)->mass2->nbr == GetInt(argv[0])) { + SetFloat((aux[nb_link_delete]),(*li)->nbr); nb_link_delete++; } } @@ -369,16 +397,16 @@ protected: m_delete_link(1,&aux[i]); // delete mass - for (i=0; inbr == GetAInt(argv[0])) { - SetFloat((sortie[0]),mass[i]->nbr); - SetSymbol((sortie[1]),mass[i]->Id); - SetFloat((sortie[2]),mass[i]->mobile); - SetFloat((sortie[3]),1/mass[i]->invM); - SetFloat((sortie[4]),mass[i]->posX); - SetFloat((sortie[5]),mass[i]->posY); - delete mass[i]; - mass[i] = mass[nb_mass-1]; + for (i=0, mi=mass; inbr == GetAInt(argv[0])) { + SetFloat((sortie[0]),(*mi)->nbr); + SetSymbol((sortie[1]),(*mi)->Id); + SetFloat((sortie[2]),(*mi)->mobile); + SetFloat((sortie[3]),1/(*mi)->invM); + SetFloat((sortie[4]),(*mi)->posX); + SetFloat((sortie[5]),(*mi)->posY); + delete (*mi); + (*mi) = mass[nb_mass-1]; nb_mass--; ToOutAnything(1,S_Mass_deleted,6,sortie); break; @@ -429,18 +457,19 @@ protected: t_int i; t_mass *mass1 = NULL; t_mass *mass2 = NULL; - + t_mass **mi; + if (argc < 6 || argc > 8) error("link : Id Nomass1 Nomass2 K D1 D2 (Lmin Lmax)"); // check for existence of link masses: - for (i=0; inbr==GetInt(argv[1])) // pointer to mass1 + for (i=0, mi=mass; inbr==GetInt(argv[1])) // pointer to mass1 // we found mass1 - mass1 = mass[i]; - else if (mass[i]->nbr==GetInt(argv[2])) // pointer to mass2 + mass1 = (*mi); + else if ((*mi)->nbr==GetInt(argv[2])) // pointer to mass2 // ... and mass2 - mass2 = mass[i]; + mass2 = (*mi); if (mass1 and mass2) { @@ -495,6 +524,7 @@ protected: NEWARR(t_int,imass1,nb_mass); NEWARR(t_int,imass2,nb_mass); t_symbol *Id1, *Id2; + t_mass **mi; if (argc < 6 || argc > 8) error("ilink : Id Idmass1 Idmass2 K D1 D2 (Lmin Lmax)"); @@ -503,12 +533,12 @@ protected: Id2 = GetSymbol(argv[2]); ToOutAnything(1,S_iLink,0,aux); - for (i=0;iId) { + for (i=0, mi=mass; iId) { imass1[nbmass1]=i; nbmass1++; } - if (Id2 == mass[i]->Id) { + if (Id2 == (*mi)->Id) { imass2[nbmass2]=i; nbmass2++; } @@ -543,14 +573,15 @@ protected: // set rigidity of link(s) named Id t_int i; const t_symbol *sym = GetSymbol(argv[0]); + t_link **li; if (argc != 2) error("setK : IdLink Value"); - for (i=0; iId) - link[i]->K1 = GetFloat(argv[1]); + if (sym == (*li)->Id) + (*li)->K1 = GetFloat(argv[1]); } } @@ -559,14 +590,15 @@ protected: // set damping of link(s) named Id t_int i; const t_symbol *sym = GetSymbol(argv[0]); + t_link **li; if (argc != 2) error("setD : IdLink Value"); - for (i=0; iId) - link[i]->D1 = GetFloat(argv[1]); + if (sym == (*li)->Id) + (*li)->D1 = GetFloat(argv[1]); } } @@ -575,14 +607,15 @@ protected: // set damping of link(s) named Id t_int i; const t_symbol *sym = GetSymbol(argv[0]); + t_link **li; if (argc != 2) error("setD2 : IdLink Value"); - for (i=0; iId) - link[i]->D2 = GetFloat(argv[1]); + if (sym == (*li)->Id) + (*li)->D2 = GetFloat(argv[1]); } } @@ -591,21 +624,22 @@ protected: // Delete link t_int i; t_atom sortie[7]; + t_link **li; if (argc != 1) error("deleteLink : NoLink"); - for (i=0; inbr == GetInt(argv[0])) { - SetFloat((sortie[0]),link[i]->nbr); - SetSymbol((sortie[1]),link[i]->Id); - SetFloat((sortie[2]),link[i]->mass1->nbr); - SetFloat((sortie[3]),link[i]->mass2->nbr); - SetFloat((sortie[4]),link[i]->K1); - SetFloat((sortie[5]),link[i]->D1); - SetFloat((sortie[6]),link[i]->D2); - delete link[i]; - link[i]=link[nb_link-1]; // copy last link instead + for (i=0, li=link; inbr == GetInt(argv[0])) { + SetFloat((sortie[0]),(*li)->nbr); + SetSymbol((sortie[1]),(*li)->Id); + SetFloat((sortie[2]),(*li)->mass1->nbr); + SetFloat((sortie[3]),(*li)->mass2->nbr); + SetFloat((sortie[4]),(*li)->K1); + SetFloat((sortie[5]),(*li)->D1); + SetFloat((sortie[6]),(*li)->D2); + delete (*li); + (*li)=link[nb_link-1]; // copy last link instead nb_link--; ToOutAnything(1,S_Link_deleted,7,sortie); break; @@ -623,41 +657,43 @@ protected: t_atom sortie[5]; auxtype = GetSymbol(argv[0]); auxarg = GetASymbol(argv[1]); //auxarg : & symbol, 0 else + t_mass **mi; + t_link **li; if (argc == 1) { if (auxtype == S_massesPos) // get all masses positions - for (i=0; inbr); - SetFloat(sortie[1],mass[i]->posX); - SetFloat(sortie[2],mass[i]->posY); + SetFloat(sortie[0],(*mi)->nbr); + SetFloat(sortie[1],(*mi)->posX); + SetFloat(sortie[2],(*mi)->posY); ToOutAnything(0,S_massesPos,3,sortie); } else if (auxtype == S_massesForces) // get all masses forces - for (i=0; inbr); - SetFloat(sortie[1],mass[i]->out_forceX); - SetFloat(sortie[2],mass[i]->out_forceY); + SetFloat(sortie[0],(*mi)->nbr); + SetFloat(sortie[1],(*mi)->out_forceX); + SetFloat(sortie[2],(*mi)->out_forceY); ToOutAnything(0,S_massesForces,3,sortie); } else if (auxtype == S_linksPos) // get all links positions - for (i=0; inbr); - SetFloat(sortie[1],link[i]->mass1->posX); - SetFloat(sortie[2],link[i]->mass1->posY); - SetFloat(sortie[3],link[i]->mass2->posX); - SetFloat(sortie[4],link[i]->mass2->posY); + SetFloat(sortie[0],(*li)->nbr); + SetFloat(sortie[1],(*li)->mass1->posX); + SetFloat(sortie[2],(*li)->mass1->posY); + SetFloat(sortie[3],(*li)->mass2->posX); + SetFloat(sortie[4],(*li)->mass2->posY); ToOutAnything(0,S_linksPos,5,sortie); } else // get all masses speeds - for (i=0; inbr); - SetFloat(sortie[1],mass[i]->speedX); - SetFloat(sortie[2],mass[i]->speedY); + SetFloat(sortie[0],(*mi)->nbr); + SetFloat(sortie[1],(*mi)->speedX); + SetFloat(sortie[2],(*mi)->speedY); ToOutAnything(0,S_massesSpeeds,3,sortie); } } @@ -666,12 +702,12 @@ protected: if (auxarg == 0) // No { for (j = 1; jnbr==GetInt(argv[j])) + for (i=0, mi=mass; inbr==GetInt(argv[j])) { - SetFloat(sortie[0],mass[i]->nbr); - SetFloat(sortie[1],mass[i]->posX); - SetFloat(sortie[2],mass[i]->posY); + SetFloat(sortie[0],(*mi)->nbr); + SetFloat(sortie[1],(*mi)->posX); + SetFloat(sortie[2],(*mi)->posY); ToOutAnything(0,S_massesPosNo,3,sortie); } } @@ -680,13 +716,13 @@ protected: for (j = 1; jId) + if (auxarg2==(*mi)->Id) { - SetSymbol(sortie[0],mass[i]->Id); - SetFloat(sortie[1],mass[i]->posX); - SetFloat(sortie[2],mass[i]->posY); + SetSymbol(sortie[0],(*mi)->Id); + SetFloat(sortie[1],(*mi)->posX); + SetFloat(sortie[2],(*mi)->posY); ToOutAnything(0,S_massesPosId,3,sortie); } } @@ -698,12 +734,12 @@ protected: if (auxarg == 0) // No { for (j = 1; jnbr==GetInt(argv[j])) + for (i=0, mi=mass; inbr==GetInt(argv[j])) { - SetFloat(sortie[0],mass[i]->nbr); - SetFloat(sortie[1],mass[i]->out_forceX); - SetFloat(sortie[2],mass[i]->out_forceY); + SetFloat(sortie[0],(*mi)->nbr); + SetFloat(sortie[1],(*mi)->out_forceX); + SetFloat(sortie[2],(*mi)->out_forceY); ToOutAnything(0,S_massesForcesNo,3,sortie); } } @@ -712,13 +748,13 @@ protected: for (j = 1; jId) + if (auxarg2==(*mi)->Id) { - SetSymbol(sortie[0],mass[i]->Id); - SetFloat(sortie[1],mass[i]->out_forceX); - SetFloat(sortie[2],mass[i]->out_forceY); + SetSymbol(sortie[0],(*mi)->Id); + SetFloat(sortie[1],(*mi)->out_forceX); + SetFloat(sortie[2],(*mi)->out_forceY); ToOutAnything(0,S_massesForcesId,3,sortie); } } @@ -730,14 +766,14 @@ protected: if (auxarg == 0) // No { for (j = 1; jnbr==GetInt(argv[j])) + for (i=0, li=link; inbr==GetInt(argv[j])) { - SetFloat(sortie[0],link[i]->nbr); - SetFloat(sortie[1],link[i]->mass1->posX); - SetFloat(sortie[2],link[i]->mass1->posY); - SetFloat(sortie[3],link[i]->mass2->posX); - SetFloat(sortie[4],link[i]->mass2->posY); + SetFloat(sortie[0],(*li)->nbr); + SetFloat(sortie[1],(*li)->mass1->posX); + SetFloat(sortie[2],(*li)->mass1->posY); + SetFloat(sortie[3],(*li)->mass2->posX); + SetFloat(sortie[4],(*li)->mass2->posY); ToOutAnything(0,S_linksPosNo,5,sortie); } } @@ -746,15 +782,15 @@ protected: for (j = 1; jId) + if (auxarg2==(*li)->Id) { - SetSymbol(sortie[0],link[i]->Id); - SetFloat(sortie[1],link[i]->mass1->posX); - SetFloat(sortie[2],link[i]->mass1->posY); - SetFloat(sortie[3],link[i]->mass2->posX); - SetFloat(sortie[4],link[i]->mass2->posY); + SetSymbol(sortie[0],(*li)->Id); + SetFloat(sortie[1],(*li)->mass1->posX); + SetFloat(sortie[2],(*li)->mass1->posY); + SetFloat(sortie[3],(*li)->mass2->posX); + SetFloat(sortie[4],(*li)->mass2->posY); ToOutAnything(0,S_linksPosId,5,sortie); } } @@ -766,12 +802,12 @@ protected: if (auxarg == 0) // No { for (j = 1; jnbr==GetInt(argv[j])) + for (i=0, mi=mass; inbr==GetInt(argv[j])) { - SetFloat(sortie[0],mass[i]->nbr); - SetFloat(sortie[1],mass[i]->speedX); - SetFloat(sortie[2],mass[i]->speedY); + SetFloat(sortie[0],(*mi)->nbr); + SetFloat(sortie[1],(*mi)->speedX); + SetFloat(sortie[2],(*mi)->speedY); ToOutAnything(0,S_massesSpeedsNo,3,sortie); } } @@ -780,13 +816,13 @@ protected: for (j = 1; jId) + if (auxarg2==(*mi)->Id) { - SetSymbol(sortie[0],mass[i]->Id); - SetFloat(sortie[1],mass[i]->speedX); - SetFloat(sortie[2],mass[i]->speedY); + SetSymbol(sortie[0],(*mi)->Id); + SetFloat(sortie[1],(*mi)->speedX); + SetFloat(sortie[2],(*mi)->speedY); ToOutAnything(0,S_massesSpeedsId,3,sortie); } } @@ -802,10 +838,11 @@ protected: { NEWARR(t_atom,sortie,2*nb_mass); t_int i; + t_mass **mi; - for (i=0; iposX); - SetFloat((sortie[2*i+1]),mass[i]->posY); + for (i=0, mi=mass; iposX); + SetFloat((sortie[2*i+1]),(*mi)->posY); } ToOutAnything(0, S_massesPosL, 2*nb_mass, sortie); DELARR(sortie); @@ -816,10 +853,11 @@ protected: { NEWARR(t_atom,sortie,2*nb_mass); t_int i; + t_mass **mi; - for (i=0; iout_forceX); - SetFloat((sortie[2*i+1]),mass[i]->out_forceY); + for (i=0, mi=mass; iout_forceX); + SetFloat((sortie[2*i+1]),(*mi)->out_forceY); } ToOutAnything(0, S_massesForcesL, 2*nb_mass, sortie); DELARR(sortie); @@ -830,25 +868,27 @@ protected: { t_atom sortie[7]; t_int i; - - for (i=0; inbr); - SetSymbol((sortie[1]),mass[i]->Id); - SetFloat((sortie[2]),mass[i]->mobile); - SetFloat((sortie[3]),1/mass[i]->invM); - SetFloat((sortie[4]),mass[i]->posX); - SetFloat((sortie[5]),mass[i]->posY); + t_mass **mi; + t_link **li; + + for (i=0, mi=mass; inbr); + SetSymbol((sortie[1]),(*mi)->Id); + SetFloat((sortie[2]),(*mi)->mobile); + SetFloat((sortie[3]),1/(*mi)->invM); + SetFloat((sortie[4]),(*mi)->posX); + SetFloat((sortie[5]),(*mi)->posY); ToOutAnything(1, S_Mass, 6, sortie); } - for (i=0; inbr); - SetSymbol((sortie[1]),link[i]->Id); - SetFloat((sortie[2]),link[i]->mass1->nbr); - SetFloat((sortie[3]),link[i]->mass2->nbr); - SetFloat((sortie[4]),link[i]->K1); - SetFloat((sortie[5]),link[i]->D1); - SetFloat((sortie[6]),link[i]->D2); + for (i=0, li=link; inbr); + SetSymbol((sortie[1]),(*li)->Id); + SetFloat((sortie[2]),(*li)->mass1->nbr); + SetFloat((sortie[3]),(*li)->mass2->nbr); + SetFloat((sortie[4]),(*li)->K1); + SetFloat((sortie[5]),(*li)->D1); + SetFloat((sortie[6]),(*li)->D2); ToOutAnything(1, S_Link, 7, sortie); } -- cgit v1.2.1