aboutsummaryrefslogtreecommitdiff
path: root/pmpd2d_interactor.c
diff options
context:
space:
mode:
authorCyrille Henry <nusmuk@users.sourceforge.net>2014-01-27 11:27:51 +0000
committerCyrille Henry <nusmuk@users.sourceforge.net>2014-01-27 11:27:51 +0000
commit355bfd8d94bbdac999247a7778a49a96837fae9e (patch)
tree1b09eaa0304c0fcd683d4a4d319ae529cbbb3944 /pmpd2d_interactor.c
parent8e2046a5796957c47871f95bc6496b6971043ccf (diff)
add rigididy for iTable
svn path=/trunk/externals/pmpd/; revision=17256
Diffstat (limited to 'pmpd2d_interactor.c')
-rw-r--r--pmpd2d_interactor.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/pmpd2d_interactor.c b/pmpd2d_interactor.c
index b1e4639..a2c7437 100644
--- a/pmpd2d_interactor.c
+++ b/pmpd2d_interactor.c
@@ -193,7 +193,7 @@ void pmpd2d_iLine(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
// --------------------------------------------------------
-void pmpd2d_iTable_i(t_pmpd2d *x, int i, t_float zone_x_min, t_float zone_x_max, t_float zone_y_min, t_float zone_y_max, int taille_x, int taille_y, t_word *tableX, t_word *tableY)
+void pmpd2d_iTable_i(t_pmpd2d *x, int i, t_float zone_x_min, t_float zone_x_max, t_float zone_y_min, t_float zone_y_max, int taille_x, int taille_y, t_float K, t_word *tableX, t_word *tableY)
{
t_float Xtable, Ytable, Xindex, Yindex, force1, force2, force;
int index;
@@ -211,11 +211,11 @@ void pmpd2d_iTable_i(t_pmpd2d *x, int i, t_float zone_x_min, t_float zone_x_max,
force1 = (1-Xtable) * tableX[index].w_float + (Xtable) * tableX[index+1].w_float ;
force2 = (1-Xtable) * tableX[index+taille_y].w_float + (Xtable) * tableX[index+1+taille_y].w_float;
force = (1-Ytable) * force1 + Ytable * force2;
- x->mass[i].forceX += force;
+ x->mass[i].forceX += K * force;
force1 = (1-Xtable) * tableY[index].w_float + (Xtable) * tableY[index+1].w_float ;
force2 = (1-Xtable) * tableY[index+taille_y].w_float + (Xtable) * tableY[index+1+taille_y].w_float;
force = (1-Ytable) * force1 + Ytable * force2;
- x->mass[i].forceY += force;
+ x->mass[i].forceY += K * force;
}
}
@@ -223,55 +223,56 @@ void pmpd2d_iTable(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
{
// Argument :
// 0 : mass to apply this interactor
- // 1, 2 : Xmin, Xmax
- // 3, 4 : Ymin, Ymax physical location of the interator
- // 5, 6 : matrix size
- // 7, 8 : table name containing the matrix
+ // 1 : K;
+ // 2, 3 : Xmin, Xmax
+ // 4, 5 : Ymin, Ymax physical location of the interator
+ // 6, 7 : matrix size
+ // 8, 9 : table name containing the matrix
t_garray *a1, *a2;
int npoints1, npoints2;
t_word *vec1, *vec2;
- t_float Xmin, Xmax, Ymin, Ymax;
+ t_float Xmin, Xmax, Ymin, Ymax, K;
int X, Y, i;
- if (!((argc==9) && (argv[1].a_type == A_FLOAT) && (argv[2].a_type == A_FLOAT) &&
+ if (!((argc==10) && (argv[1].a_type == A_FLOAT) && (argv[2].a_type == A_FLOAT) &&
(argv[3].a_type == A_FLOAT) && (argv[4].a_type == A_FLOAT) && (argv[5].a_type == A_FLOAT) &&
- (argv[6].a_type == A_FLOAT) && (argv[7].a_type == A_SYMBOL) && (argv[8].a_type == A_SYMBOL) ) )
+ (argv[6].a_type == A_FLOAT) && (argv[7].a_type == A_FLOAT) && (argv[8].a_type == A_SYMBOL) && (argv[9].a_type == A_SYMBOL) ) )
{
pd_error(x,"bad argument for iTable");
return;
}
+ X = atom_getfloatarg(6, argc, argv);
+ Y = atom_getfloatarg(7, argc, argv);
- if (!(a1 = (t_garray *)pd_findbyclass(atom_getsymbolarg(7,argc,argv), garray_class)))
- pd_error(x, "%s: no such array", atom_getsymbolarg(7,argc,argv)->s_name);
- else if (!garray_getfloatwords(a1, &npoints1, &vec1))
- pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(7,argc,argv)->s_name);
- else if (!(a2 = (t_garray *)pd_findbyclass(atom_getsymbolarg(8,argc,argv), garray_class)))
+ if (!(a1 = (t_garray *)pd_findbyclass(atom_getsymbolarg(8,argc,argv), garray_class)))
pd_error(x, "%s: no such array", atom_getsymbolarg(8,argc,argv)->s_name);
- else if (!garray_getfloatwords(a2, &npoints2, &vec2))
+ else if (!garray_getfloatwords(a1, &npoints1, &vec1))
pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(8,argc,argv)->s_name);
- else if ( ( npoints1 < atom_getfloatarg(5,argc,argv) * atom_getfloatarg(6,argc,argv) ) || ( npoints2 < atom_getfloatarg(5,argc,argv) * atom_getfloatarg(6,argc,argv) ) )
+ else if (!(a2 = (t_garray *)pd_findbyclass(atom_getsymbolarg(9,argc,argv), garray_class)))
+ pd_error(x, "%s: no such array", atom_getsymbolarg(9,argc,argv)->s_name);
+ else if (!garray_getfloatwords(a2, &npoints2, &vec2))
+ pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(9,argc,argv)->s_name);
+ else if ( ( npoints1 < X * Y ) || ( npoints2 < X * Y ) )
pd_error(x, "not enough point in tables for iTable");
else
{
-
- Xmin = atom_getfloatarg(1, argc, argv);
- Xmax = atom_getfloatarg(2, argc, argv);
- Ymin = atom_getfloatarg(3, argc, argv);
- Ymax = atom_getfloatarg(4, argc, argv);
- X = atom_getfloatarg(5, argc, argv);
- Y = atom_getfloatarg(6, argc, argv);
-
+ K = atom_getfloatarg(1, argc, argv);
+ Xmin = atom_getfloatarg(2, argc, argv);
+ Xmax = atom_getfloatarg(3, argc, argv);
+ Ymin = atom_getfloatarg(4, argc, argv);
+ Ymax = atom_getfloatarg(5, argc, argv);
+
if ( argv[0].a_type == A_FLOAT )
{
- pmpd2d_iTable_i(x, (int)atom_getfloatarg(0,argc,argv), Xmin, Xmax, Ymin, Ymax, X, Y, vec1, vec2);
+ pmpd2d_iTable_i(x, (int)atom_getfloatarg(0,argc,argv), Xmin, Xmax, Ymin, Ymax, X, Y, K, vec1, vec2);
}
else if ( argv[0].a_type == A_SYMBOL )
{ for (i=0; i < x->nb_mass; i++)
{ if (atom_getsymbolarg(0,argc,argv) == x->mass[i].Id)
{
- pmpd2d_iTable_i(x, i, Xmin, Xmax, Ymin, Ymax, X, Y, vec1, vec2);
+ pmpd2d_iTable_i(x, i, Xmin, Xmax, Ymin, Ymax, X, Y, K, vec1, vec2);
}
}
}