Update of /cvsroot/pure-data/externals/nusmuk/msd
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25007/msd
Modified Files:
03_msdwave.pd help-msd.pd main.cpp
Log Message:
MSD version 0.05
Index: main.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/nusmuk/msd/main.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** main.cpp 26 Apr 2005 16:10:07 -0000 1.7
--- main.cpp 28 Apr 2005 15:22:05 -0000 1.8
***************
*** 31,35 ****
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! Version 0.04 -- 26.04.2005
*/
--- 31,35 ----
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! Version 0.05 -- 28.04.2005
*/
***************
*** 39,43 ****
// define constants
! #define MSD_VERSION 0.04
#define nb_max_link 4000
#define nb_max_mass 4000
--- 39,43 ----
// define constants
! #define MSD_VERSION 0.05
#define nb_max_link 4000
#define nb_max_mass 4000
***************
*** 113,123 ****
{
t_int i;
! // t_atom sortie;
! for (i=0; i<nb_mass; i++) {
! delete mass[i];
}
! for (i=0; i<nb_link; i++) {
! delete link[i];
}
ToOutAnything(1,S_Reset,0,NULL);
--- 113,124 ----
{
t_int i;
! t_mass **mi;
! t_link **li;
! for (i=0, mi=mass; i<nb_mass; mi++, i++) {
! delete (*mi);
}
! for (i=0, li=link; i<nb_link; li++,i++) {
! delete (*li);
}
ToOutAnything(1,S_Reset,0,NULL);
***************
*** 135,177 ****
t_float F=0,Fx=0,distance,vitesse, X_new;
t_int i;
! struct _mass mass_1, mass_2;
!
! for (i=0; i<nb_link; i++) {
// compute link forces
! distance = link[i]->mass1->posX-link[i]->mass2->posX; // L[n] = x1 - x2
if (distance < 0)
distance = -distance; // |L[n]|
! if (distance < link[i]->long_min || distance > link[i]->long_max)
Fx = 0;
else { // Lmin < L < Lmax
! 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])
if (distance != 0)
! Fx = F * (link[i]->mass1->posX - link[i]->mass2->posX)/distance; // Fx = F * Lx[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]->distance_old = distance; // L[n-1] = L[n]
}
!
!
! for (i=0; i<nb_mass; i++)
// compute new masses position only if mobile = 1
! if (mass[i]->mobile == 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]
}
! for (i=0; i<nb_mass; i++) {
// clear forces
! mass[i]->out_forceX = mass[i]->forceX;
! mass[i]->forceX = 0; // Fx[n] = 0
}
}
--- 136,176 ----
t_float F=0,Fx=0,distance,vitesse, X_new;
t_int i;
! t_mass **mi;
! t_link **li;
! for (i=0, li=link; i<nb_link; li++,i++) {
// compute link forces
! distance = (*li)->mass1->posX-(*li)->mass2->posX; // L[n] = x1 - x2
if (distance < 0)
distance = -distance; // |L[n]|
! if (distance < (*li)->long_min || distance > (*li)->long_max)
Fx = 0;
else { // Lmin < L < Lmax
! 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 * ((*li)->mass1->posX - (*li)->mass2->posX)/distance; // Fx = F * Lx[n]/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)->distance_old = distance; // L[n-1] = L[n]
}
! for (i=0, mi=mass; i<nb_mass; mi++, i++)
// compute new masses position only if mobile = 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]
}
! for (i=0, mi=mass; i<nb_mass; mi++, i++) {
// clear forces
! (*mi)->out_forceX = (*mi)->forceX;
! (*mi)->forceX = 0; // Fx[n] = 0
}
}
***************
*** 214,236 ****
void m_forceX(int argc,t_atom *argv)
{
! // add a force to mass(es) named Id
t_int i;
! const t_symbol *sym = GetSymbol(argv[0]);
if (argc != 2)
error("forceX : Idmass value");
! for (i=0; i<nb_mass;i++)
! {
! if (sym == mass[i]->Id)
! mass[i]->forceX += GetFloat(argv[1]);
! }
}
void m_posX(int argc,t_atom *argv)
{
! // displace mass(es) named Id to a certain position
t_int i;
const t_symbol *sym = GetASymbol(argv[0]);
if (argc != 2)
--- 213,246 ----
void m_forceX(int argc,t_atom *argv)
{
! // add a force to mass(es) named Id or No
t_int i;
! const t_symbol *sym = GetASymbol(argv[0]);
! t_mass **mi;
if (argc != 2)
error("forceX : Idmass value");
! if (sym ==0)
! for (i=0, mi=mass; i<nb_mass; mi++, i++)
! {
! if (GetInt(argv[0]) == (*mi)->nbr) {
! (*mi)->forceX = GetFloat(argv[1]);
! break;
! }
! }
! else
! for (i=0, mi=mass; i<nb_mass; mi++, i++)
! {
! if (sym == (*mi)->Id)
! (*mi)->forceX = GetFloat(argv[1]);
! }
}
void m_posX(int argc,t_atom *argv)
{
! // displace mass(es) named Id or No to a certain position
t_int i;
const t_symbol *sym = GetASymbol(argv[0]);
+ t_mass **mi;
if (argc != 2)
***************
*** 239,254 ****
if (GetFloat(argv[1]) < Xmax && GetFloat(argv[1]) > Xmin)
if (sym ==0)
! for (i=0; i<nb_mass;i++)
{
! if (GetInt(argv[0]) == mass[i]->nbr) {
! mass[i]->posX = GetFloat(argv[1]);
break;
}
}
else
! for (i=0; i<nb_mass;i++)
{
! if (sym == mass[i]->Id)
! mass[i]->posX = GetFloat(argv[1]);
}
}
--- 249,264 ----
if (GetFloat(argv[1]) < Xmax && GetFloat(argv[1]) > Xmin)
if (sym ==0)
! for (i=0, mi=mass; i<nb_mass; mi++, i++)
{
! if (GetInt(argv[0]) == (*mi)->nbr) {
! (*mi)->posX = GetFloat(argv[1]);
break;
}
}
else
! for (i=0, mi=mass; i<nb_mass; mi++, i++)
{
! if (sym == (*mi)->Id)
! (*mi)->posX = GetFloat(argv[1]);
}
}
***************
*** 258,261 ****
--- 268,272 ----
// set mass No to mobile
t_int i,aux;
+ t_mass **mi;
if (argc != 1)
***************
*** 263,270 ****
aux = GetInt(argv[0]);
! for (i=0; i<nb_mass;i++)
{
! if (mass[i]->nbr == aux)
! mass[i]->mobile = 1;
}
--- 274,281 ----
aux = GetInt(argv[0]);
! for (i=0, mi=mass; i<nb_mass; mi++, i++)
{
! if ((*mi)->nbr == aux)
! (*mi)->mobile = 1;
}
***************
*** 275,278 ****
--- 286,290 ----
// set mass No to fixed
t_int i,aux;
+ t_mass **mi;
if (argc != 1)
***************
*** 280,287 ****
aux = GetInt(argv[0]);
! for (i=0; i<nb_mass;i++)
{
! if (mass[i]->nbr == aux)
! mass[i]->mobile = 0;
}
--- 292,299 ----
aux = GetInt(argv[0]);
! for (i=0, mi=mass; i<nb_mass; mi++, i++)
{
! if ((*mi)->nbr == aux)
! (*mi)->mobile = 0;
}
***************
*** 294,305 ****
t_atom sortie[5];
NEWARR(t_atom,aux,nb_link);
!
if (argc != 1)
error("deleteMass : Nomass");
// Delete all associated links
! for (i=0; i<nb_link;i++) {
! if (link[i]->mass1->nbr == GetAInt(argv[0]) || link[i]->mass2->nbr == GetAInt(argv[0])) {
! SetFloat((aux[nb_link_delete]),link[i]->nbr);
nb_link_delete++;
}
--- 306,319 ----
t_atom sortie[5];
NEWARR(t_atom,aux,nb_link);
! t_mass **mi;
! t_link **li;
!
if (argc != 1)
error("deleteMass : Nomass");
// Delete all associated links
! for (i=0, li=link; i<nb_link; li++,i++) {
! if ((*li)->mass1->nbr == GetAInt(argv[0]) || (*li)->mass2->nbr == GetAInt(argv[0])) {
! SetFloat((aux[nb_link_delete]),(*li)->nbr);
nb_link_delete++;
}
***************
*** 310,322 ****
// Delete mass
! for (i=0; i<nb_mass;i++)
! if (mass[i]->nbr == 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);
! delete mass[i];
! mass[i] = mass[nb_mass-1]; // copy last mass instead
nb_mass--;
ToOutAnything(1,S_Mass_deleted,5,sortie);
--- 324,336 ----
// Delete mass
! for (i=0, mi=mass; i<nb_mass; mi++, i++)
! if ((*mi)->nbr == 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);
! delete (*mi);
! (*mi) = mass[nb_mass-1]; // copy last mass instead
nb_mass--;
ToOutAnything(1,S_Mass_deleted,5,sortie);
***************
*** 355,370 ****
t_mass *mass1 = NULL;
t_mass *mass2 = NULL;
!
if (argc < 6 || argc > 8)
error("link : Id Nomass1 Nomass2 K D1 D2 (Lmin Lmax)");
// check for existence of link masses:
! for (i=0; i<nb_mass;i++)
! if (mass[i]->nbr==GetInt(argv[1])) // pointer to mass1
// we found mass1
! mass1 = mass[i];
! else if (mass[i]->nbr==GetInt(argv[2])) // pointer to mass2
// ... and mass2
! mass2 = mass[i];
if (mass1 and mass2)
--- 369,386 ----
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, mi=mass; i<nb_mass; mi++, i++)
! if ((*mi)->nbr==GetInt(argv[1])) // pointer to mass1
// we found mass1
! mass1 = (*mi);
! else if ((*mi)->nbr==GetInt(argv[2])) // pointer to mass2
// ... and mass2
! mass2 = (*mi);
if (mass1 and mass2)
***************
*** 423,426 ****
--- 439,443 ----
NEWARR(t_int,imass2,nb_mass);
t_symbol *Id1, *Id2;
+ t_mass **mi;
if (argc < 6 || argc > 8)
***************
*** 431,440 ****
ToOutAnything(1,S_iLink,0,aux);
! for (i=0;i<nb_mass;i++) {
! if (Id1 == mass[i]->Id) {
imass1[nbmass1]=i;
nbmass1++;
}
! if (Id2 == mass[i]->Id) {
imass2[nbmass2]=i;
nbmass2++;
--- 448,457 ----
ToOutAnything(1,S_iLink,0,aux);
! for (i=0, mi=mass; i<nb_mass; mi++, i++) {
! if (Id1 == (*mi)->Id) {
imass1[nbmass1]=i;
nbmass1++;
}
! if (Id2 == (*mi)->Id) {
imass2[nbmass2]=i;
nbmass2++;
***************
*** 472,483 ****
t_int i;
const t_symbol *sym = GetSymbol(argv[0]);
if (argc != 2)
error("setK : IdLink Value");
! for (i=0; i<nb_link;i++)
{
! if (sym == link[i]->Id)
! link[i]->K1 = GetFloat(argv[1]);
}
}
--- 489,501 ----
t_int i;
const t_symbol *sym = GetSymbol(argv[0]);
+ t_link **li;
if (argc != 2)
error("setK : IdLink Value");
! for (i=0, li=link; i<nb_link; li++,i++)
{
! if (sym == (*li)->Id)
! (*li)->K1 = GetFloat(argv[1]);
}
}
***************
*** 488,499 ****
t_int i;
const t_symbol *sym = GetSymbol(argv[0]);
if (argc != 2)
error("setD : IdLink Value");
! for (i=0; i<nb_link;i++)
{
! if (sym == link[i]->Id)
! link[i]->D1 = GetFloat(argv[1]);
}
}
--- 506,518 ----
t_int i;
const t_symbol *sym = GetSymbol(argv[0]);
+ t_link **li;
if (argc != 2)
error("setD : IdLink Value");
! for (i=0, li=link; i<nb_link; li++,i++)
{
! if (sym == (*li)->Id)
! (*li)->D1 = GetFloat(argv[1]);
}
}
***************
*** 504,515 ****
t_int i;
const t_symbol *sym = GetSymbol(argv[0]);
if (argc != 2)
error("setD2 : IdLink Value");
! for (i=0; i<nb_link;i++)
{
! if (sym == link[i]->Id)
! link[i]->D2 = GetFloat(argv[1]);
}
}
--- 523,535 ----
t_int i;
const t_symbol *sym = GetSymbol(argv[0]);
+ t_link **li;
if (argc != 2)
error("setD2 : IdLink Value");
! for (i=0, li=link; i<nb_link; li++,i++)
{
! if (sym == (*li)->Id)
! (*li)->D2 = GetFloat(argv[1]);
}
}
***************
*** 520,538 ****
t_int i;
t_atom sortie[7];
if (argc != 1)
error("deleteLink : NoLink");
! for (i=0; i<nb_link;i++)
! if (link[i]->nbr == 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
nb_link--;
ToOutAnything(1,S_Link_deleted,7,sortie);
--- 540,559 ----
t_int i;
t_atom sortie[7];
+ t_link **li;
if (argc != 1)
error("deleteLink : NoLink");
! for (i=0, li=link; i<nb_link; li++,i++)
! if ((*li)->nbr == 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);
***************
*** 551,554 ****
--- 572,578 ----
t_symbol *auxarg,*auxarg2, *auxtype;
t_atom sortie[3];
+ t_mass **mi;
+ t_link **li;
+
auxtype = GetSymbol(argv[0]);
auxarg = GetASymbol(argv[1]); //auxarg : & symbol, 0 else
***************
*** 556,585 ****
{
if (auxtype == S_massesPos) // get all masses positions
! for (i=0; i<nb_mass; i++)
{
! SetFloat(sortie[0],mass[i]->nbr);
! SetFloat(sortie[1],mass[i]->posX);
ToOutAnything(0,S_massesPos,2,sortie);
}
else if (auxtype == S_massesForces) // get all masses forces
! for (i=0; i<nb_mass; i++)
{
! SetFloat(sortie[0],mass[i]->nbr);
! SetFloat(sortie[1],mass[i]->out_forceX);
ToOutAnything(0,S_massesForces,2,sortie);
}
else if (auxtype == S_linksPos) // get all links positions
! for (i=0; i<nb_link; i++)
{
! SetFloat(sortie[0],link[i]->nbr);
! SetFloat(sortie[1],link[i]->mass1->posX);
! SetFloat(sortie[2],link[i]->mass2->posX);
ToOutAnything(0,S_linksPos,3,sortie);
}
else // get all masses speeds
! for (i=0; i<nb_mass; i++)
{
! SetFloat(sortie[0],mass[i]->nbr);
! SetFloat(sortie[1],mass[i]->speedX);
ToOutAnything(0,S_massesSpeeds,2,sortie);
}
--- 580,609 ----
{
if (auxtype == S_massesPos) // get all masses positions
! for (i=0, mi=mass; i<nb_mass; mi++, i++)
{
! SetFloat(sortie[0],(*mi)->nbr);
! SetFloat(sortie[1],(*mi)->posX);
ToOutAnything(0,S_massesPos,2,sortie);
}
else if (auxtype == S_massesForces) // get all masses forces
! for (i=0, mi=mass; i<nb_mass; mi++, i++)
{
! SetFloat(sortie[0],(*mi)->nbr);
! SetFloat(sortie[1],(*mi)->out_forceX);
ToOutAnything(0,S_massesForces,2,sortie);
}
else if (auxtype == S_linksPos) // get all links positions
! for (i=0, li=link; i<nb_link; li++,i++)
{
! SetFloat(sortie[0],(*li)->nbr);
! SetFloat(sortie[1],(*li)->mass1->posX);
! SetFloat(sortie[2],(*li)->mass2->posX);
ToOutAnything(0,S_linksPos,3,sortie);
}
else // get all masses speeds
! for (i=0, mi=mass; i<nb_mass; mi++, i++)
{
! SetFloat(sortie[0],(*mi)->nbr);
! SetFloat(sortie[1],(*mi)->speedX);
ToOutAnything(0,S_massesSpeeds,2,sortie);
}
***************
*** 590,598 ****
{
for (j = 1; j<argc; j++)
! for (i=0;i<nb_mass;i++)
! if (mass[i]->nbr==GetInt(argv[j]))
{
! SetFloat(sortie[0],mass[i]->nbr);
! SetFloat(sortie[1],mass[i]->posX);
ToOutAnything(0,S_massesPosNo,2,sortie);
}
--- 614,622 ----
{
for (j = 1; j<argc; j++)
! for (i=0, mi=mass; i<nb_mass; mi++, i++)
! if ((*mi)->nbr==GetInt(argv[j]))
{
! SetFloat(sortie[0],(*mi)->nbr);
! SetFloat(sortie[1],(*mi)->posX);
ToOutAnything(0,S_massesPosNo,2,sortie);
}
***************
*** 603,612 ****
{
auxarg2 = GetSymbol(argv[j]);
! for (i=0;i<nb_mass;i++)
{
! if (auxarg2==mass[i]->Id)
{
! SetSymbol(sortie[0],mass[i]->Id);
! SetFloat(sortie[1],mass[i]->posX);
ToOutAnything(0,S_massesPosId,2,sortie);
}
--- 627,636 ----
{
auxarg2 = GetSymbol(argv[j]);
! for (i=0, mi=mass; i<nb_mass; mi++, i++)
{
! if (auxarg2==(*mi)->Id)
{
! SetSymbol(sortie[0],(*mi)->Id);
! SetFloat(sortie[1],(*mi)->posX);
ToOutAnything(0,S_massesPosId,2,sortie);
}
***************
*** 620,628 ****
{
for (j = 1; j<argc; j++)
! for (i=0;i<nb_mass;i++)
! if (mass[i]->nbr==GetInt(argv[j]))
{
! SetFloat(sortie[0],mass[i]->nbr);
! SetFloat(sortie[1],mass[i]->out_forceX);
ToOutAnything(0,S_massesForcesNo,2,sortie);
}
--- 644,652 ----
{
for (j = 1; j<argc; j++)
! for (i=0, mi=mass; i<nb_mass; mi++, i++)
! if ((*mi)->nbr==GetInt(argv[j]))
{
! SetFloat(sortie[0],(*mi)->nbr);
! SetFloat(sortie[1],(*mi)->out_forceX);
ToOutAnything(0,S_massesForcesNo,2,sortie);
}
***************
*** 633,642 ****
{
auxarg2 = GetSymbol(argv[j]);
! for (i=0;i<nb_mass;i++)
{
! if (auxarg2==mass[i]->Id)
{
! SetSymbol(sortie[0],mass[i]->Id);
! SetFloat(sortie[1],mass[i]->out_forceX);
ToOutAnything(0,S_massesForcesId,2,sortie);
}
--- 657,666 ----
{
auxarg2 = GetSymbol(argv[j]);
! for (i=0, mi=mass; i<nb_mass; mi++, i++)
{
! if (auxarg2==(*mi)->Id)
{
! SetSymbol(sortie[0],(*mi)->Id);
! SetFloat(sortie[1],(*mi)->out_forceX);
ToOutAnything(0,S_massesForcesId,2,sortie);
}
***************
*** 650,659 ****
{
for (j = 1; j<argc; j++)
! for (i=0;i<nb_link;i++)
! if (link[i]->nbr==GetInt(argv[j]))
{
! SetFloat(sortie[0],link[i]->nbr);
! SetFloat(sortie[1],link[i]->mass1->posX);
! SetFloat(sortie[2],link[i]->mass2->posX);
ToOutAnything(0,S_linksPosNo,3,sortie);
}
--- 674,683 ----
{
for (j = 1; j<argc; j++)
! for (i=0, li=link; i<nb_link; li++,i++)
! if ((*li)->nbr==GetInt(argv[j]))
{
! SetFloat(sortie[0],(*li)->nbr);
! SetFloat(sortie[1],(*li)->mass1->posX);
! SetFloat(sortie[2],(*li)->mass2->posX);
ToOutAnything(0,S_linksPosNo,3,sortie);
}
***************
*** 664,674 ****
{
auxarg2 = GetSymbol(argv[j]);
! for (i=0;i<nb_link;i++)
{
! if (auxarg2==link[i]->Id)
{
! SetSymbol(sortie[0],link[i]->Id);
! SetFloat(sortie[1],link[i]->mass1->posX);
! SetFloat(sortie[2],link[i]->mass2->posX);
ToOutAnything(0,S_linksPosId,3,sortie);
}
--- 688,698 ----
{
auxarg2 = GetSymbol(argv[j]);
! for (i=0, li=link; i<nb_link; li++,i++)
{
! if (auxarg2==(*li)->Id)
{
! SetSymbol(sortie[0],(*li)->Id);
! SetFloat(sortie[1],(*li)->mass1->posX);
! SetFloat(sortie[2],(*li)->mass2->posX);
ToOutAnything(0,S_linksPosId,3,sortie);
}
***************
*** 682,690 ****
{
for (j = 1; j<argc; j++)
! for (i=0;i<nb_mass;i++)
! if (mass[i]->nbr==GetInt(argv[j]))
{
! SetFloat(sortie[0],mass[i]->nbr);
! SetFloat(sortie[1],mass[i]->speedX);
ToOutAnything(0,S_massesSpeedsNo,2,sortie);
}
--- 706,714 ----
{
for (j = 1; j<argc; j++)
! for (i=0, mi=mass; i<nb_mass; mi++, i++)
! if ((*mi)->nbr==GetInt(argv[j]))
{
! SetFloat(sortie[0],(*mi)->nbr);
! SetFloat(sortie[1],(*mi)->speedX);
ToOutAnything(0,S_massesSpeedsNo,2,sortie);
}
***************
*** 695,704 ****
{
auxarg2 = GetSymbol(argv[j]);
! for (i=0;i<nb_mass;i++)
{
! if (auxarg2==mass[i]->Id)
{
! SetSymbol(sortie[0],mass[i]->Id);
! SetFloat(sortie[1],mass[i]->speedX);
ToOutAnything(0,S_massesSpeedsId,2,sortie);
}
--- 719,728 ----
{
auxarg2 = GetSymbol(argv[j]);
! for (i=0, mi=mass; i<nb_mass; mi++, i++)
{
! if (auxarg2==(*mi)->Id)
{
! SetSymbol(sortie[0],(*mi)->Id);
! SetFloat(sortie[1],(*mi)->speedX);
ToOutAnything(0,S_massesSpeedsId,2,sortie);
}
***************
*** 716,722 ****
NEWARR(t_atom,sortie,nb_mass);
t_int i;
! for (i=0; i<nb_mass; i++) {
! SetFloat((sortie[i]),mass[i]->posX);
}
ToOutAnything(0, S_massesPosL, nb_mass, sortie);
--- 740,747 ----
NEWARR(t_atom,sortie,nb_mass);
t_int i;
+ t_mass **mi;
! for (i=0, mi=mass; i<nb_mass; mi++, i++) {
! SetFloat((sortie[i]),(*mi)->posX);
}
ToOutAnything(0, S_massesPosL, nb_mass, sortie);
***************
*** 729,735 ****
NEWARR(t_atom,sortie,nb_mass);
t_int i;
! for (i=0; i<nb_mass; i++) {
! SetFloat((sortie[i]),mass[i]->out_forceX);
}
ToOutAnything(0, S_massesForcesL, nb_mass, sortie);
--- 754,761 ----
NEWARR(t_atom,sortie,nb_mass);
t_int i;
+ t_mass **mi;
! for (i=0, mi=mass; i<nb_mass; mi++, i++) {
! SetFloat((sortie[i]),(*mi)->out_forceX);
}
ToOutAnything(0, S_massesForcesL, nb_mass, sortie);
***************
*** 742,763 ****
t_atom sortie[7];
t_int i;
! for (i=0; i<nb_mass; i++) {
! 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);
ToOutAnything(1, S_Mass, 5, sortie);
}
! for (i=0; i<nb_link; i++) {
! 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);
ToOutAnything(1, S_Link, 7, sortie);
}
--- 768,791 ----
t_atom sortie[7];
t_int i;
+ t_mass **mi;
+ t_link **li;
! for (i=0, mi=mass; i<nb_mass; mi++, i++) {
! 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);
ToOutAnything(1, S_Mass, 5, sortie);
}
! for (i=0, li=link; i<nb_link; li++,i++) {
! 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);
ToOutAnything(1, S_Link, 7, sortie);
}
Index: help-msd.pd
===================================================================
RCS file: /cvsroot/pure-data/externals/nusmuk/msd/help-msd.pd,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** help-msd.pd 25 Apr 2005 16:18:38 -0000 1.4
--- help-msd.pd 28 Apr 2005 15:22:05 -0000 1.5
***************
*** 17,21 ****
-262131 -66577 0;
#X text 350 467 \$2 : New value;
- #X text 348 503 \$1 : Id (symbol);
#X text 348 521 \$2 : New value;
#X msg 87 429 posX \$1 \$2;
--- 17,20 ----
***************
*** 59,74 ****
#X text 334 271 \$4 : initial position;
#X text 350 449 \$1 : Id (symbol) or No;
#X connect 2 0 0 0;
#X connect 9 0 0 0;
! #X connect 15 0 0 0;
! #X connect 18 0 0 0;
#X connect 20 0 0 0;
! #X connect 21 0 0 0;
! #X connect 24 0 0 0;
#X connect 28 0 0 0;
! #X connect 29 0 0 0;
! #X connect 32 0 0 0;
! #X connect 34 0 0 0;
! #X connect 43 0 0 0;
#X restore 282 323 pd masses;
#N canvas 222 83 808 841 links 0;
--- 58,74 ----
#X text 334 271 \$4 : initial position;
#X text 350 449 \$1 : Id (symbol) or No;
+ #X text 348 503 \$1 : Id (symbol) or No;
#X connect 2 0 0 0;
#X connect 9 0 0 0;
! #X connect 14 0 0 0;
! #X connect 17 0 0 0;
! #X connect 19 0 0 0;
#X connect 20 0 0 0;
! #X connect 23 0 0 0;
! #X connect 27 0 0 0;
#X connect 28 0 0 0;
! #X connect 31 0 0 0;
! #X connect 33 0 0 0;
! #X connect 42 0 0 0;
#X restore 282 323 pd masses;
#N canvas 222 83 808 841 links 0;
Index: 03_msdwave.pd
===================================================================
RCS file: /cvsroot/pure-data/externals/nusmuk/msd/03_msdwave.pd,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** 03_msdwave.pd 26 Apr 2005 16:10:06 -0000 1.2
--- 03_msdwave.pd 28 Apr 2005 15:22:04 -0000 1.3
***************
*** 13,17 ****
#X obj 127 22 inlet;
#X obj 48 203 translateXYZ;
- #X obj 64 114 gemhead;
#X obj 48 177 separator;
#X obj 48 153 any;
--- 13,16 ----
***************
*** 19,32 ****
#X obj 127 57 unpack f f f;
#X obj 48 283 cuboid 0.065 0.065 0.07;
! #X connect 0 0 6 0;
! #X connect 1 0 7 0;
! #X connect 2 0 4 1;
! #X connect 3 0 1 0;
#X connect 4 0 3 0;
#X connect 5 0 4 0;
! #X connect 5 1 1 1;
! #X connect 6 0 5 0;
! #X connect 6 1 1 2;
! #X connect 6 2 7 3;
#X restore 265 625 pd massrender;
#X msg 203 83 symbol reset;
--- 18,32 ----
#X obj 127 57 unpack f f f;
#X obj 48 283 cuboid 0.065 0.065 0.07;
! #X obj 64 114 gemhead 45;
! #X connect 0 0 5 0;
! #X connect 1 0 6 0;
! #X connect 2 0 1 0;
! #X connect 3 0 2 0;
#X connect 4 0 3 0;
+ #X connect 4 1 1 1;
#X connect 5 0 4 0;
! #X connect 5 1 1 2;
! #X connect 5 2 6 3;
! #X connect 7 0 3 1;
#X restore 265 625 pd massrender;
#X msg 203 83 symbol reset;
***************
*** 68,72 ****
#X obj 602 334 rotateXYZ;
#X obj 651 450 vsl 15 128 0 4 0 0 empty empty empty 0 -8 0 8 -262131
! -1 -1 0 1;
#X obj 670 450 vsl 15 128 0 4 0 0 empty empty empty 0 -8 0 8 -262131
-1 -1 0 1;
--- 68,72 ----
#X obj 602 334 rotateXYZ;
#X obj 651 450 vsl 15 128 0 4 0 0 empty empty empty 0 -8 0 8 -262131
! -1 -1 1400 1;
#X obj 670 450 vsl 15 128 0 4 0 0 empty empty empty 0 -8 0 8 -262131
-1 -1 0 1;
***************
*** 105,109 ****
#X obj 33 537 unpack f f f;
#X obj 443 546 unpack f f;
! #X obj 173 598 f;
#X obj 33 574 t b f;
#X connect 0 0 12 0;
--- 105,109 ----
#X obj 33 537 unpack f f f;
#X obj 443 546 unpack f f;
! #X obj 173 597 f;
#X obj 33 574 t b f;
#X connect 0 0 12 0;