aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/iAmbient2D.c200
-rwxr-xr-xsrc/iAmbient3D.c259
-rwxr-xr-xsrc/iCircle2D.c276
-rwxr-xr-xsrc/iCircle3D.c211
-rwxr-xr-xsrc/iCylinder3D.c292
-rwxr-xr-xsrc/iLine2D.c179
-rwxr-xr-xsrc/iPlane3D.c193
-rwxr-xr-xsrc/iSeg2D.c175
-rwxr-xr-xsrc/iSphere3D.c253
-rwxr-xr-xsrc/lia.c162
-rwxr-xr-xsrc/lia2D.c213
-rwxr-xr-xsrc/lia3D.c238
-rwxr-xr-xsrc/makefile95
-rwxr-xr-xsrc/masse.c153
-rwxr-xr-xsrc/masse2D.c810
-rwxr-xr-xsrc/masse3D.c1093
-rwxr-xr-xsrc/pmpd.c146
-rwxr-xr-xsrc/tCircle2D.c113
-rwxr-xr-xsrc/tCircle3D.c195
-rwxr-xr-xsrc/tCube3D.c114
-rwxr-xr-xsrc/tCylinder3D.c218
-rwxr-xr-xsrc/tLia2D.c157
-rwxr-xr-xsrc/tLia3D.c153
-rwxr-xr-xsrc/tLine2D.c137
-rwxr-xr-xsrc/tPlane3D.c175
-rwxr-xr-xsrc/tSeg2D.c139
-rwxr-xr-xsrc/tSphere3D.c128
-rwxr-xr-xsrc/tSquare2D.c92
28 files changed, 6569 insertions, 0 deletions
diff --git a/src/iAmbient2D.c b/src/iAmbient2D.c
new file mode 100755
index 0000000..f5050ce
--- /dev/null
+++ b/src/iAmbient2D.c
@@ -0,0 +1,200 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *iAmbient2D_class;
+
+typedef struct _iAmbient2D {
+ t_object x_obj;
+ t_atom force[12];
+ /*
+ force =
+ forceX,
+ forceY,
+ randomFX,
+ randomFY,
+ damp,
+ Xmin,
+ Xmax,
+ Ymin,
+ Ymax,
+ dX,
+ dY;
+ */
+
+ t_outlet *force_new;// outlet
+ t_symbol *x_sym; // send
+} t_iAmbient2D;
+
+void iAmbient2D_forceX(t_iAmbient2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[0]), f1);
+}
+
+void iAmbient2D_forceY(t_iAmbient2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[1]), f1);
+}
+
+void iAmbient2D_force(t_iAmbient2D *x, t_floatarg f1, t_floatarg f2)
+{
+ SETFLOAT(&(x->force[0]), f1);
+ SETFLOAT(&(x->force[1]), f2 );
+}
+
+void iAmbient2D_rndFX(t_iAmbient2D *x, t_float X)
+{
+ SETFLOAT(&(x->force[2]), X);
+}
+
+void iAmbient2D_rndFY(t_iAmbient2D *x, t_float X)
+{
+ SETFLOAT(&(x->force[3]), X);
+}
+
+void iAmbient2D_rndF(t_iAmbient2D *x, t_floatarg f1, t_floatarg f2)
+{
+ SETFLOAT(&(x->force[2]), f1);
+ SETFLOAT(&(x->force[3]), f2);
+}
+
+void iAmbient2D_damp(t_iAmbient2D *x, t_float X)
+{
+ SETFLOAT(&(x->force[4]), X);
+}
+
+void iAmbient2D_Xmin(t_iAmbient2D *x, t_float Xmin)
+{
+ SETFLOAT(&(x->force[6]), Xmin);
+}
+
+void iAmbient2D_Xmax(t_iAmbient2D *x, t_float Xmax)
+{
+ SETFLOAT(&(x->force[7]), Xmax);
+}
+
+void iAmbient2D_Ymin(t_iAmbient2D *x, t_float Ymin)
+{
+ SETFLOAT(&(x->force[8]), Ymin);
+}
+
+void iAmbient2D_Ymax(t_iAmbient2D *x, t_float Ymax)
+{
+ SETFLOAT(&(x->force[9]), Ymax);
+}
+
+void iAmbient2D_dXY(t_iAmbient2D *x, t_float dX, t_float dY)
+{
+ SETFLOAT(&(x->force[10]), dX);
+ SETFLOAT(&(x->force[11]), dY);
+}
+
+void iAmbient2D_dX(t_iAmbient2D *x, t_float dX)
+{
+ SETFLOAT(&(x->force[10]), dX);
+}
+
+void iAmbient2D_dY(t_iAmbient2D *x, t_float dY)
+{
+ SETFLOAT(&(x->force[11]), dY);
+}
+
+void iAmbient2D_bang(t_iAmbient2D *x)
+{
+ if (x->x_sym->s_thing) typedmess(x->x_sym->s_thing, gensym("interactor_ambient_2D"), 12, x->force);
+
+ outlet_anything(x->force_new, gensym("interactor_ambient_2D"), 12, x->force);
+}
+
+void *iAmbient2D_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_iAmbient2D *x = (t_iAmbient2D *)pd_new(iAmbient2D_class);
+
+ x->x_sym = atom_getsymbolarg(0, argc, argv);
+
+ x->force_new=outlet_new(&x->x_obj, 0);
+
+ SETFLOAT(&(x->force[5]), 0);
+
+
+ if (argc>=12)
+ SETFLOAT(&(x->force[11]), atom_getfloatarg(11, argc, argv));
+ else
+ SETFLOAT(&(x->force[11]), 0);
+
+ if (argc>=11)
+ SETFLOAT(&(x->force[10]), atom_getfloatarg(10, argc, argv));
+ else
+ SETFLOAT(&(x->force[10]), 0);
+
+ if (argc>=10)
+ SETFLOAT(&(x->force[9]), atom_getfloatarg(9, argc, argv));
+ else
+ SETFLOAT(&(x->force[9]), 100000);
+
+ if (argc>=9)
+ SETFLOAT(&(x->force[8]), atom_getfloatarg(8, argc, argv));
+ else
+ SETFLOAT(&(x->force[8]), -100000);
+
+ if (argc>=8)
+ SETFLOAT(&(x->force[7]), atom_getfloatarg(7, argc, argv));
+ else
+ SETFLOAT(&(x->force[7]), 100000);
+
+ if (argc>=7)
+ SETFLOAT(&(x->force[6]), atom_getfloatarg(6, argc, argv));
+ else
+ SETFLOAT(&(x->force[6]), -100000);
+
+ if (argc>=6)
+ SETFLOAT(&(x->force[4]), atom_getfloatarg(5, argc, argv));
+ else
+ SETFLOAT(&(x->force[4]), 0);
+
+ if (argc>=5)
+ SETFLOAT(&(x->force[3]), atom_getfloatarg(4, argc, argv));
+ else
+ SETFLOAT(&(x->force[3]), 0);
+
+ if (argc>=4)
+ SETFLOAT(&(x->force[2]), atom_getfloatarg(3, argc, argv));
+ else
+ SETFLOAT(&(x->force[2]), 0);
+
+ if (argc>=3)
+ SETFLOAT(&(x->force[1]), atom_getfloatarg(2, argc, argv));
+ else
+ SETFLOAT(&(x->force[1]), 0);
+
+ if (argc>=2)
+ SETFLOAT(&(x->force[0]), atom_getfloatarg(1, argc, argv));
+ else
+ SETFLOAT(&(x->force[0]), 0);
+
+ return (x);
+}
+
+void iAmbient2D_setup(void)
+{
+ iAmbient2D_class = class_new(gensym("iAmbient2D"),
+ (t_newmethod)iAmbient2D_new,
+ 0, sizeof(t_iAmbient2D),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addcreator((t_newmethod)iAmbient2D_new, gensym("pmpd.iAmbient2D"), A_GIMME, 0);
+
+ class_addbang(iAmbient2D_class, iAmbient2D_bang);
+ class_addmethod(iAmbient2D_class, (t_method)iAmbient2D_force, gensym("setFXY"), A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(iAmbient2D_class, (t_method)iAmbient2D_forceX, gensym("setFX"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient2D_class, (t_method)iAmbient2D_forceY, gensym("setFY"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient2D_class, (t_method)iAmbient2D_Xmin, gensym("setXmin"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient2D_class, (t_method)iAmbient2D_Ymin, gensym("setYmin"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient2D_class, (t_method)iAmbient2D_Xmax, gensym("setXmax"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient2D_class, (t_method)iAmbient2D_Ymax, gensym("setYmax"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient2D_class, (t_method)iAmbient2D_rndFY, gensym("setRndFY"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient2D_class, (t_method)iAmbient2D_rndFX, gensym("setRndFX"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient2D_class, (t_method)iAmbient2D_damp, gensym("setD"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient2D_class, (t_method)iAmbient2D_dX, gensym("setdX"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient2D_class, (t_method)iAmbient2D_dY, gensym("setdY"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient2D_class, (t_method)iAmbient2D_dXY, gensym("setdXY"), A_DEFFLOAT, A_DEFFLOAT, 0);
+}
diff --git a/src/iAmbient3D.c b/src/iAmbient3D.c
new file mode 100755
index 0000000..cd95088
--- /dev/null
+++ b/src/iAmbient3D.c
@@ -0,0 +1,259 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *iAmbient3D_class;
+
+typedef struct _iAmbient3D {
+ t_object x_obj;
+ t_atom force[17];
+/* 1 : name of the mass (send interactors informations to this masses)
+ 2 : FX (constant X force apply to the masses) (0)
+ 3 : FY (constant Y force apply to the masses) (0)
+ 4 : FZ (constant Z force apply to the masses) (0)
+ 5 : Rnd FX (random X force apply to the masses) (0)
+ 6 : Rnd FY (random Y force apply to the masses) (0)
+ 7 : Rnd FZ (random Z force apply to the masses) (0)
+ 8 : Damping (velocity damping of the masses) (0)
+ 9 : Rien
+ 10 : Xmin (minimum and maximum limit of the interactors) (-10000)
+ 9 : Xmax (a mass interact with this object only if it is inside the interactor bounds) (10000)
+ 10 : Ymin (-10000)
+ 11 : Ymax (10000)
+ 12 : Zmin (-10000)
+ 13 : Zmax (10000)
+ 14 : dX (displace the mass by a constant value) (0)
+ 15 : dY (0)
+ 16 : dZ (0)
+*/
+ t_outlet *force_new;// outlet
+ t_symbol *x_sym; // send
+} t_iAmbient3D;
+
+void iAmbient3D_forceX(t_iAmbient3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[0]), f1);
+}
+
+void iAmbient3D_forceY(t_iAmbient3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[1]), f1);
+}
+
+void iAmbient3D_forceZ(t_iAmbient3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[2]), f1);
+}
+
+void iAmbient3D_force(t_iAmbient3D *x, t_floatarg f1, t_floatarg f2, t_floatarg f3)
+{
+ SETFLOAT(&(x->force[0]), f1 );
+ SETFLOAT(&(x->force[1]), f2 );
+ SETFLOAT(&(x->force[2]), f3 );
+}
+
+void iAmbient3D_rndFX(t_iAmbient3D *x, t_float X)
+{
+ SETFLOAT(&(x->force[3]), X);
+}
+
+void iAmbient3D_rndFY(t_iAmbient3D *x, t_float X)
+{
+ SETFLOAT(&(x->force[4]), X);
+}
+
+void iAmbient3D_rndFZ(t_iAmbient3D *x, t_float X)
+{
+ SETFLOAT(&(x->force[5]), X);
+}
+
+void iAmbient3D_rndF(t_iAmbient3D *x, t_floatarg f1, t_floatarg f2, t_floatarg f3)
+{
+ SETFLOAT(&(x->force[3]), f1);
+ SETFLOAT(&(x->force[4]), f2);
+ SETFLOAT(&(x->force[5]), f3);
+}
+
+void iAmbient3D_damp(t_iAmbient3D *x, t_float X)
+{
+ SETFLOAT(&(x->force[6]), X);
+}
+
+
+void iAmbient3D_Xmin(t_iAmbient3D *x, t_float Xmin)
+{
+ SETFLOAT(&(x->force[8]), Xmin);
+}
+
+void iAmbient3D_Xmax(t_iAmbient3D *x, t_float Xmax)
+{
+ SETFLOAT(&(x->force[9]), Xmax);
+}
+
+void iAmbient3D_Ymin(t_iAmbient3D *x, t_float Ymin)
+{
+ SETFLOAT(&(x->force[10]), Ymin);
+}
+
+void iAmbient3D_Ymax(t_iAmbient3D *x, t_float Ymax)
+{
+ SETFLOAT(&(x->force[11]), Ymax);
+}
+
+void iAmbient3D_Zmin(t_iAmbient3D *x, t_float Zmin)
+{
+ SETFLOAT(&(x->force[12]), Zmin);
+}
+
+void iAmbient3D_Zmax(t_iAmbient3D *x, t_float Zmax)
+{
+ SETFLOAT(&(x->force[13]), Zmax);
+}
+
+void iAmbient3D_dXYZ(t_iAmbient3D *x, t_float dX, t_float dY, t_float dZ)
+{
+ SETFLOAT(&(x->force[14]), dX);
+ SETFLOAT(&(x->force[15]), dY);
+ SETFLOAT(&(x->force[16]), dZ);
+}
+
+void iAmbient3D_dX(t_iAmbient3D *x, t_float dX)
+{
+ SETFLOAT(&(x->force[14]), dX);
+}
+
+void iAmbient3D_dY(t_iAmbient3D *x, t_float dY)
+{
+ SETFLOAT(&(x->force[15]), dY);
+}
+
+void iAmbient3D_dZ(t_iAmbient3D *x, t_float dZ)
+{
+ SETFLOAT(&(x->force[16]), dZ);
+}
+
+void iAmbient3D_bang(t_iAmbient3D *x)
+{
+ if (x->x_sym->s_thing) typedmess(x->x_sym->s_thing, gensym("interactor_ambient_3D"), 17, x->force);
+
+ outlet_anything(x->force_new, gensym("interactor_ambient_3D"), 17, x->force);
+}
+
+void *iAmbient3D_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_iAmbient3D *x = (t_iAmbient3D *)pd_new(iAmbient3D_class);
+
+ x->x_sym = atom_getsymbolarg(0, argc, argv);
+
+ x->force_new=outlet_new(&x->x_obj, 0);
+
+ if (argc>=16)
+ SETFLOAT(&(x->force[15]), atom_getfloatarg(15, argc, argv));
+ else
+ SETFLOAT(&(x->force[15]), 0);
+
+ if (argc>=15)
+ SETFLOAT(&(x->force[14]), atom_getfloatarg(14, argc, argv));
+ else
+ SETFLOAT(&(x->force[14]), 0);
+
+ if (argc>=14)
+ SETFLOAT(&(x->force[13]), atom_getfloatarg(13, argc, argv));
+ else
+ SETFLOAT(&(x->force[13]), 10000);
+
+ if (argc>=13)
+ SETFLOAT(&(x->force[12]), atom_getfloatarg(12, argc, argv));
+ else
+ SETFLOAT(&(x->force[12]), -10000);
+
+ if (argc>=12)
+ SETFLOAT(&(x->force[11]), atom_getfloatarg(11, argc, argv));
+ else
+ SETFLOAT(&(x->force[11]), 10000);
+
+ if (argc>=11)
+ SETFLOAT(&(x->force[10]), atom_getfloatarg(10, argc, argv));
+ else
+ SETFLOAT(&(x->force[10]), -10000);
+
+ if (argc>=10)
+ SETFLOAT(&(x->force[9]), atom_getfloatarg(9, argc, argv));
+ else
+ SETFLOAT(&(x->force[9]), 10000);
+
+ if (argc>=9)
+ SETFLOAT(&(x->force[8]), atom_getfloatarg(8, argc, argv));
+ else
+ SETFLOAT(&(x->force[8]), -10000);
+
+ SETFLOAT(&(x->force[7]), 0);
+
+ if (argc>=8)
+ SETFLOAT(&(x->force[6]), atom_getfloatarg(7, argc, argv));
+ else
+ SETFLOAT(&(x->force[6]), 0);
+
+ if (argc>=7)
+ SETFLOAT(&(x->force[5]), atom_getfloatarg(6, argc, argv));
+ else
+ SETFLOAT(&(x->force[5]), 0);
+
+ if (argc>=6)
+ SETFLOAT(&(x->force[4]), atom_getfloatarg(5, argc, argv));
+ else
+ SETFLOAT(&(x->force[4]), 0);
+
+ if (argc>=5)
+ SETFLOAT(&(x->force[3]), atom_getfloatarg(4, argc, argv));
+ else
+ SETFLOAT(&(x->force[3]), 0);
+
+ if (argc>=4)
+ SETFLOAT(&(x->force[2]), atom_getfloatarg(3, argc, argv));
+ else
+ SETFLOAT(&(x->force[2]), 0);
+
+ if (argc>=3)
+ SETFLOAT(&(x->force[1]), atom_getfloatarg(2, argc, argv));
+ else
+ SETFLOAT(&(x->force[1]), 0);
+
+ if (argc>=2)
+ SETFLOAT(&(x->force[0]), atom_getfloatarg(1, argc, argv));
+ else
+ SETFLOAT(&(x->force[0]), 0);
+
+ return (x);
+}
+
+void iAmbient3D_setup(void)
+{
+
+ iAmbient3D_class = class_new(gensym("iAmbient3D"),
+ (t_newmethod)iAmbient3D_new,
+ 0, sizeof(t_iAmbient3D),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addcreator((t_newmethod)iAmbient3D_new, gensym("pmpd.iAmbient3D"), A_GIMME, 0);
+
+ class_addbang(iAmbient3D_class, iAmbient3D_bang);
+ class_addmethod(iAmbient3D_class, (t_method)iAmbient3D_force, gensym("setFXYZ"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(iAmbient3D_class, (t_method)iAmbient3D_forceX, gensym("setFX"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient3D_class, (t_method)iAmbient3D_forceY, gensym("setFY"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient3D_class, (t_method)iAmbient3D_forceZ, gensym("setFZ"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient3D_class, (t_method)iAmbient3D_Xmin, gensym("setXmin"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient3D_class, (t_method)iAmbient3D_Ymin, gensym("setYmin"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient3D_class, (t_method)iAmbient3D_Zmin, gensym("setZmin"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient3D_class, (t_method)iAmbient3D_Xmax, gensym("setXmax"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient3D_class, (t_method)iAmbient3D_Ymax, gensym("setYmax"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient3D_class, (t_method)iAmbient3D_Zmax, gensym("setZmax"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient3D_class, (t_method)iAmbient3D_rndFY, gensym("setRndFY"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient3D_class, (t_method)iAmbient3D_rndFX, gensym("setRndFX"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient3D_class, (t_method)iAmbient3D_rndFZ, gensym("setRndFZ"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient3D_class, (t_method)iAmbient3D_damp, gensym("setD"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient3D_class, (t_method)iAmbient3D_dXYZ, gensym("dXYZ"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient3D_class, (t_method)iAmbient3D_dX, gensym("setdX"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient3D_class, (t_method)iAmbient3D_dY, gensym("setdY"), A_DEFFLOAT, 0);
+ class_addmethod(iAmbient3D_class, (t_method)iAmbient3D_dZ, gensym("setdZ"), A_DEFFLOAT, 0);
+
+}
diff --git a/src/iCircle2D.c b/src/iCircle2D.c
new file mode 100755
index 0000000..869dd70
--- /dev/null
+++ b/src/iCircle2D.c
@@ -0,0 +1,276 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *iCircle2D_class;
+
+typedef struct _iCircle2D {
+ t_object x_obj;
+ t_atom force[20];
+ t_outlet *force_new; // outlet
+ t_symbol *x_sym; // send
+ t_float posX_old, posY_old, posX, posY; // anciennes position, pour calculer la vitesse de cette interacteur.
+
+} t_iCircle2D;
+
+void iCircle2D_bang(t_iCircle2D *x)
+{
+ SETFLOAT(&(x->force[14]), x->posX_old); // posX_old
+ SETFLOAT(&(x->force[15]), x->posY_old); // posY_old
+
+ x->posX_old = x->posX;
+ x->posY_old = x->posY;
+
+ if (x->x_sym->s_thing) typedmess(x->x_sym->s_thing, gensym("interactor_circle_2D"), 20, x->force);
+
+ outlet_anything(x->force_new, gensym("interactor_circle_2D"), 20, x->force);
+}
+
+void iCircle2D_setXY(t_iCircle2D *x, t_float X, t_float Y)
+{
+ SETFLOAT(&(x->force[0]), X);
+ x->posX= X;
+ SETFLOAT(&(x->force[1]), Y);
+ x->posY = Y;
+}
+
+void iCircle2D_setX(t_iCircle2D *x, t_float X)
+{
+ SETFLOAT(&(x->force[0]), X);
+ x->posX= X;
+}
+
+void iCircle2D_setY(t_iCircle2D *x, t_float Y)
+{
+ SETFLOAT(&(x->force[1]), Y);
+ x->posY = Y;
+}
+
+void iCircle2D_setRmin(t_iCircle2D *x, t_float X)
+{
+ SETFLOAT(&(x->force[2]), X);
+}
+
+void iCircle2D_setRmax(t_iCircle2D *x, t_float X)
+{
+ SETFLOAT(&(x->force[3]), X);
+}
+
+void iCircle2D_setFN(t_iCircle2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[4]), f1);
+}
+
+void iCircle2D_setFT(t_iCircle2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[5]), f1);
+}
+
+void iCircle2D_setKN(t_iCircle2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[6]), f1);
+}
+
+void iCircle2D_setKT(t_iCircle2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[7]), f1);
+}
+
+void iCircle2D_setRN(t_iCircle2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[8]), f1);
+}
+
+void iCircle2D_setRT(t_iCircle2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[9]), f1);
+}
+
+void iCircle2D_setDN(t_iCircle2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[10]), f1);
+}
+
+void iCircle2D_setDT(t_iCircle2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[11]), f1);
+}
+
+void iCircle2D_setdRN(t_iCircle2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[12]), f1);
+}
+
+void iCircle2D_setdRT(t_iCircle2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[13]), f1);
+}
+
+void iCircle2D_setD(t_iCircle2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[16]), f1);
+}
+
+void iCircle2D_setG(t_iCircle2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[17]), f1);
+}
+
+void iCircle2D_setdN(t_iCircle2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[18]), f1);
+}
+
+void iCircle2D_setdT(t_iCircle2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[19]), f1);
+}
+
+void *iCircle2D_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_iCircle2D *x = (t_iCircle2D *)pd_new(iCircle2D_class);
+
+ x->x_sym = atom_getsymbolarg(0, argc, argv);
+
+ x->force_new=outlet_new(&x->x_obj, 0);
+
+ if (argc>=19)
+ SETFLOAT(&(x->force[19]), atom_getfloatarg(18, argc, argv));
+ else
+ SETFLOAT(&(x->force[19]), 0);
+
+ if (argc>=18)
+ SETFLOAT(&(x->force[18]), atom_getfloatarg(17, argc, argv));
+ else
+ SETFLOAT(&(x->force[18]), 0);
+
+ if (argc>=17)
+ SETFLOAT(&(x->force[17]), atom_getfloatarg(16, argc, argv));
+ else
+ SETFLOAT(&(x->force[17]), 0);
+
+ if (argc>=16)
+ SETFLOAT(&(x->force[16]), atom_getfloatarg(15, argc, argv));
+ else
+ SETFLOAT(&(x->force[16]), 0);
+
+ if (argc>=15)
+ SETFLOAT(&(x->force[13]), atom_getfloatarg(14, argc, argv));
+ else
+ SETFLOAT(&(x->force[13]), 0);
+
+ if (argc>=14)
+ SETFLOAT(&(x->force[12]), atom_getfloatarg(13, argc, argv));
+ else
+ SETFLOAT(&(x->force[12]), 0);
+
+ if (argc>=13)
+ SETFLOAT(&(x->force[11]), atom_getfloatarg(12, argc, argv));
+ else
+ SETFLOAT(&(x->force[11]), 0);
+
+ if (argc>=12)
+ SETFLOAT(&(x->force[10]), atom_getfloatarg(11, argc, argv));
+ else
+ SETFLOAT(&(x->force[10]), 0);
+
+ if (argc>=11)
+ SETFLOAT(&(x->force[9]), atom_getfloatarg(10, argc, argv));
+ else
+ SETFLOAT(&(x->force[9]), 0);
+
+ if (argc>=10)
+ SETFLOAT(&(x->force[8]), atom_getfloatarg(9, argc, argv));
+ else
+ SETFLOAT(&(x->force[8]), 0);
+
+ if (argc>=9)
+ SETFLOAT(&(x->force[7]), atom_getfloatarg(8, argc, argv));
+ else
+ SETFLOAT(&(x->force[7]), 0);
+
+ if (argc>=8)
+ SETFLOAT(&(x->force[6]), atom_getfloatarg(7, argc, argv));
+ else
+ SETFLOAT(&(x->force[6]), 0);
+
+ if (argc>=7)
+ SETFLOAT(&(x->force[5]), atom_getfloatarg(6, argc, argv));
+ else
+ SETFLOAT(&(x->force[5]), 0);
+
+ if (argc>=6)
+ SETFLOAT(&(x->force[4]), atom_getfloatarg(5, argc, argv));
+ else
+ SETFLOAT(&(x->force[4]), 0);
+
+ if (argc>=5)
+ SETFLOAT(&(x->force[3]), atom_getfloatarg(4, argc, argv));
+ else
+ SETFLOAT(&(x->force[3]), 1);
+
+ if (argc>=4)
+ SETFLOAT(&(x->force[2]), atom_getfloatarg(3, argc, argv));
+ else
+ SETFLOAT(&(x->force[2]), 0);
+
+ if (argc>=3)
+ {
+ SETFLOAT(&(x->force[1]), atom_getfloatarg(2, argc, argv));
+ SETFLOAT(&(x->force[15]), atom_getfloatarg(2, argc, argv));
+ x->posY_old = atom_getfloatarg(2, argc, argv);
+ }
+ else
+ {
+ SETFLOAT(&(x->force[1]), 0);
+ SETFLOAT(&(x->force[15]), 0);
+ x->posY_old = 0;
+ }
+
+ if (argc>=2)
+ {
+ SETFLOAT(&(x->force[0]), atom_getfloatarg(1, argc, argv));
+ SETFLOAT(&(x->force[14]), atom_getfloatarg(1, argc, argv));
+ x->posX_old = atom_getfloatarg(1, argc, argv);
+ }
+ else
+ {
+ SETFLOAT(&(x->force[0]), 0);
+ SETFLOAT(&(x->force[14]), 0);
+ x->posX_old = 0;
+ }
+
+ return (x);
+}
+
+void iCircle2D_setup(void)
+{
+
+ iCircle2D_class = class_new(gensym("iCircle2D"),
+ (t_newmethod)iCircle2D_new,
+ 0, sizeof(t_iCircle2D),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addcreator((t_newmethod)iCircle2D_new, gensym("pmpd.iCircle2D"), A_GIMME, 0);
+
+ class_addbang(iCircle2D_class, iCircle2D_bang);
+ class_addmethod(iCircle2D_class, (t_method)iCircle2D_setFN, gensym("setFN"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle2D_class, (t_method)iCircle2D_setFT, gensym("setFT"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle2D_class, (t_method)iCircle2D_setKN, gensym("setKN"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle2D_class, (t_method)iCircle2D_setKT, gensym("setKT"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle2D_class, (t_method)iCircle2D_setDN, gensym("setDN"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle2D_class, (t_method)iCircle2D_setDT, gensym("setDT"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle2D_class, (t_method)iCircle2D_setD, gensym("setD"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle2D_class, (t_method)iCircle2D_setX, gensym("setX"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle2D_class, (t_method)iCircle2D_setY, gensym("setY"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle2D_class, (t_method)iCircle2D_setXY, gensym("setXY"), A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(iCircle2D_class, (t_method)iCircle2D_setRmin, gensym("setRmin"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle2D_class, (t_method)iCircle2D_setRmax, gensym("setRmax"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle2D_class, (t_method)iCircle2D_setRN, gensym("setRN"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle2D_class, (t_method)iCircle2D_setRT, gensym("setRT"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle2D_class, (t_method)iCircle2D_setdN, gensym("setdN"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle2D_class, (t_method)iCircle2D_setdT, gensym("setdT"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle2D_class, (t_method)iCircle2D_setdRN, gensym("setdRN"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle2D_class, (t_method)iCircle2D_setdRT, gensym("setdRT"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle2D_class, (t_method)iCircle2D_setG, gensym("setG"), A_DEFFLOAT, 0);
+
+}
diff --git a/src/iCircle3D.c b/src/iCircle3D.c
new file mode 100755
index 0000000..cfbc412
--- /dev/null
+++ b/src/iCircle3D.c
@@ -0,0 +1,211 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *iCircle3D_class;
+
+typedef struct _iCircle3D {
+ t_object x_obj;
+ t_atom force[14];
+ t_outlet *force_new; // outlet
+ t_symbol *x_sym; // send
+
+} t_iCircle3D;
+
+void iCircle3D_bang(t_iCircle3D *x)
+{
+ if (x->x_sym->s_thing) typedmess(x->x_sym->s_thing, gensym("interactor_circle_3D"), 14, x->force);
+
+ outlet_anything(x->force_new, gensym("interactor_circle_3D"), 14, x->force);
+}
+
+void iCircle3D_setXYZ(t_iCircle3D *x, t_float X, t_float Y, t_float Z)
+{
+ SETFLOAT(&(x->force[3]), X);
+ SETFLOAT(&(x->force[4]), Y);
+ SETFLOAT(&(x->force[5]), Z);
+}
+void iCircle3D_setVXYZ(t_iCircle3D *x, t_float X, t_float Y, t_float Z)
+{
+ SETFLOAT(&(x->force[0]), X);
+ SETFLOAT(&(x->force[1]), Y);
+ SETFLOAT(&(x->force[2]), Z);
+}
+
+void iCircle3D_setVX(t_iCircle3D *x, t_float X)
+{
+ SETFLOAT(&(x->force[0]), X);
+}
+
+void iCircle3D_setVY(t_iCircle3D *x, t_float Y)
+{
+ SETFLOAT(&(x->force[1]), Y);
+}
+
+void iCircle3D_setVZ(t_iCircle3D *x, t_float Z)
+{
+ SETFLOAT(&(x->force[2]), Z);
+}
+void iCircle3D_setX(t_iCircle3D *x, t_float X)
+{
+ SETFLOAT(&(x->force[3]), X);
+}
+
+void iCircle3D_setY(t_iCircle3D *x, t_float Y)
+{
+ SETFLOAT(&(x->force[4]), Y);
+}
+
+void iCircle3D_setZ(t_iCircle3D *x, t_float Z)
+{
+ SETFLOAT(&(x->force[5]), Z);
+}
+
+void iCircle3D_setRmin(t_iCircle3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[6]), f1);
+}
+
+void iCircle3D_setRmax(t_iCircle3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[7]), f1);
+}
+
+void iCircle3D_setFN(t_iCircle3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[8]), f1);
+}
+
+void iCircle3D_setKN(t_iCircle3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[9]), f1);
+}
+
+void iCircle3D_setD(t_iCircle3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[10]), f1);
+}
+
+void iCircle3D_setPmax(t_iCircle3D *x, t_float X)
+{
+ SETFLOAT(&(x->force[11]), X);
+}
+
+void iCircle3D_setdN(t_iCircle3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[12]), f1);
+}
+
+void iCircle3D_setdKN(t_iCircle3D *x, t_float X)
+{
+ SETFLOAT(&(x->force[13]), X);
+}
+
+void *iCircle3D_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_iCircle3D *x = (t_iCircle3D *)pd_new(iCircle3D_class);
+
+ x->x_sym = atom_getsymbolarg(0, argc, argv);
+
+ x->force_new=outlet_new(&x->x_obj, 0);
+
+
+ if (argc>=15)
+ SETFLOAT(&(x->force[13]), atom_getfloatarg(14, argc, argv));
+ else
+ SETFLOAT(&(x->force[13]), 0);
+
+ if (argc>=14)
+ SETFLOAT(&(x->force[12]), atom_getfloatarg(13, argc, argv));
+ else
+ SETFLOAT(&(x->force[12]), 0);
+
+ if (argc>=13)
+ SETFLOAT(&(x->force[11]), atom_getfloatarg(12, argc, argv));
+ else
+ SETFLOAT(&(x->force[11]), 10000);
+
+ if (argc>=12)
+ SETFLOAT(&(x->force[10]), atom_getfloatarg(11, argc, argv));
+ else
+ SETFLOAT(&(x->force[10]), 0);
+
+ if (argc>=11)
+ SETFLOAT(&(x->force[9]), atom_getfloatarg(10, argc, argv));
+ else
+ SETFLOAT(&(x->force[9]), 0);
+
+ if (argc>=10)
+ SETFLOAT(&(x->force[8]), atom_getfloatarg(9, argc, argv));
+ else
+ SETFLOAT(&(x->force[8]), 0);
+
+ if (argc>=9)
+ SETFLOAT(&(x->force[7]), atom_getfloatarg(8, argc, argv));
+ else
+ SETFLOAT(&(x->force[7]), 1);
+
+ if (argc>=8)
+ SETFLOAT(&(x->force[6]), atom_getfloatarg(7, argc, argv));
+ else
+ SETFLOAT(&(x->force[6]), 0);
+
+ if (argc>=7)
+ SETFLOAT(&(x->force[5]), atom_getfloatarg(6, argc, argv));
+ else
+ SETFLOAT(&(x->force[5]), 0);
+
+ if (argc>=6)
+ SETFLOAT(&(x->force[4]), atom_getfloatarg(5, argc, argv));
+ else
+ SETFLOAT(&(x->force[4]), 0);
+
+ if (argc>=5)
+ SETFLOAT(&(x->force[3]), atom_getfloatarg(4, argc, argv));
+ else
+ SETFLOAT(&(x->force[3]), 0);
+
+ if (argc>=4)
+ SETFLOAT(&(x->force[2]), atom_getfloatarg(3, argc, argv));
+ else
+ SETFLOAT(&(x->force[2]), 0);
+
+ if (argc>=3)
+ SETFLOAT(&(x->force[1]), atom_getfloatarg(2, argc, argv));
+ else
+ SETFLOAT(&(x->force[1]), 0);
+
+ if (argc>=2)
+ SETFLOAT(&(x->force[0]), atom_getfloatarg(1, argc, argv));
+ else
+ SETFLOAT(&(x->force[0]), 1);
+
+ return (x);
+}
+
+void iCircle3D_setup(void)
+{
+ iCircle3D_class = class_new(gensym("iCircle3D"),
+ (t_newmethod)iCircle3D_new,
+ 0, sizeof(t_iCircle3D),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addcreator((t_newmethod)iCircle3D_new, gensym("pmpd.iCircle3D"), A_GIMME, 0);
+
+ class_addbang(iCircle3D_class, iCircle3D_bang);
+ class_addmethod(iCircle3D_class, (t_method)iCircle3D_setVX, gensym("setVX"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle3D_class, (t_method)iCircle3D_setVY, gensym("setVY"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle3D_class, (t_method)iCircle3D_setVZ, gensym("setVZ"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle3D_class, (t_method)iCircle3D_setX, gensym("setX"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle3D_class, (t_method)iCircle3D_setY, gensym("setY"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle3D_class, (t_method)iCircle3D_setZ, gensym("setZ"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle3D_class, (t_method)iCircle3D_setRmin, gensym("setRmin"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle3D_class, (t_method)iCircle3D_setRmax, gensym("setRmax"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle3D_class, (t_method)iCircle3D_setXYZ, gensym("setXYZ"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(iCircle3D_class, (t_method)iCircle3D_setVXYZ, gensym("setVXYZ"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(iCircle3D_class, (t_method)iCircle3D_setPmax, gensym("setPmax"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle3D_class, (t_method)iCircle3D_setFN, gensym("setFN"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle3D_class, (t_method)iCircle3D_setKN, gensym("setKN"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle3D_class, (t_method)iCircle3D_setdN, gensym("setdN"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle3D_class, (t_method)iCircle3D_setdKN, gensym("setdKN"), A_DEFFLOAT, 0);
+ class_addmethod(iCircle3D_class, (t_method)iCircle3D_setD, gensym("setD"), A_DEFFLOAT, 0);
+}
diff --git a/src/iCylinder3D.c b/src/iCylinder3D.c
new file mode 100755
index 0000000..59336bf
--- /dev/null
+++ b/src/iCylinder3D.c
@@ -0,0 +1,292 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *iCylinder3D_class;
+
+typedef struct _iCylinder3D {
+ t_object x_obj;
+ t_atom force[21];
+ t_outlet *force_new; // outlet
+ t_symbol *x_sym; // send
+
+} t_iCylinder3D;
+
+
+
+void iCylinder3D_bang(t_iCylinder3D *x)
+{
+ if (x->x_sym->s_thing) typedmess(x->x_sym->s_thing, gensym("interactor_cylinder_3D"), 21, x->force);
+
+ outlet_anything(x->force_new, gensym("interactor_cylinder_3D"), 21, x->force);
+}
+
+void iCylinder3D_setXYZ(t_iCylinder3D *x, t_float X, t_float Y, t_float Z)
+{
+ SETFLOAT(&(x->force[3]), X);
+ SETFLOAT(&(x->force[4]), Y);
+ SETFLOAT(&(x->force[5]), Z);
+}
+void iCylinder3D_setVXYZ(t_iCylinder3D *x, t_float X, t_float Y, t_float Z)
+{
+ SETFLOAT(&(x->force[0]), X);
+ SETFLOAT(&(x->force[1]), Y);
+ SETFLOAT(&(x->force[2]), Z);
+}
+
+void iCylinder3D_setVX(t_iCylinder3D *x, t_float X)
+{
+ SETFLOAT(&(x->force[0]), X);
+}
+
+void iCylinder3D_setVY(t_iCylinder3D *x, t_float Y)
+{
+ SETFLOAT(&(x->force[1]), Y);
+}
+
+void iCylinder3D_setVZ(t_iCylinder3D *x, t_float Z)
+{
+ SETFLOAT(&(x->force[2]), Z);
+}
+void iCylinder3D_setX(t_iCylinder3D *x, t_float X)
+{
+ SETFLOAT(&(x->force[3]), X);
+}
+
+void iCylinder3D_setY(t_iCylinder3D *x, t_float Y)
+{
+ SETFLOAT(&(x->force[4]), Y);
+}
+
+void iCylinder3D_setZ(t_iCylinder3D *x, t_float Z)
+{
+ SETFLOAT(&(x->force[5]), Z);
+}
+
+void iCylinder3D_setRmin(t_iCylinder3D *x, t_float X)
+{
+ SETFLOAT(&(x->force[6]), X);
+}
+
+void iCylinder3D_setRmax(t_iCylinder3D *x, t_float X)
+{
+ SETFLOAT(&(x->force[7]), X);
+}
+
+void iCylinder3D_setFN(t_iCylinder3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[8]), f1);
+}
+
+void iCylinder3D_setKN(t_iCylinder3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[9]), f1);
+}
+
+void iCylinder3D_setD(t_iCylinder3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[10]), f1);
+}
+
+void iCylinder3D_setRN(t_iCylinder3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[11]), f1);
+}
+
+void iCylinder3D_setG(t_iCylinder3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[12]), f1);
+}
+
+void iCylinder3D_setPmin(t_iCylinder3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[13]), f1);
+}
+
+void iCylinder3D_setPmax(t_iCylinder3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[14]), f1);
+}
+
+void iCylinder3D_setFT(t_iCylinder3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[15]), f1);
+}
+
+void iCylinder3D_setKT(t_iCylinder3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[16]), f1);
+}
+
+void iCylinder3D_setdN(t_iCylinder3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[17]), f1);
+}
+
+void iCylinder3D_setdT(t_iCylinder3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[18]), f1);
+}
+
+void iCylinder3D_setdKN(t_iCylinder3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[19]), f1);
+}
+
+void iCylinder3D_setdKT(t_iCylinder3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[20]), f1);
+}
+
+void *iCylinder3D_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_iCylinder3D *x = (t_iCylinder3D *)pd_new(iCylinder3D_class);
+
+ x->x_sym = atom_getsymbolarg(0, argc, argv);
+
+ x->force_new=outlet_new(&x->x_obj, 0);
+
+
+ if (argc>=22)
+ SETFLOAT(&(x->force[20]), atom_getfloatarg(21, argc, argv));
+ else
+ SETFLOAT(&(x->force[20]), 0);
+
+ if (argc>=21)
+ SETFLOAT(&(x->force[19]), atom_getfloatarg(20, argc, argv));
+ else
+ SETFLOAT(&(x->force[19]), 0);
+
+ if (argc>=20)
+ SETFLOAT(&(x->force[18]), atom_getfloatarg(19, argc, argv));
+ else
+ SETFLOAT(&(x->force[18]), 0);
+
+ if (argc>=19)
+ SETFLOAT(&(x->force[17]), atom_getfloatarg(18, argc, argv));
+ else
+ SETFLOAT(&(x->force[17]), 0);
+
+ if (argc>=18)
+ SETFLOAT(&(x->force[16]), atom_getfloatarg(17, argc, argv));
+ else
+ SETFLOAT(&(x->force[16]), 0);
+
+ if (argc>=17)
+ SETFLOAT(&(x->force[15]), atom_getfloatarg(16, argc, argv));
+ else
+ SETFLOAT(&(x->force[15]), 0);
+
+ if (argc>=16)
+ SETFLOAT(&(x->force[14]), atom_getfloatarg(15, argc, argv));
+ else
+ SETFLOAT(&(x->force[14]), 1000);
+
+ if (argc>=15)
+ SETFLOAT(&(x->force[13]), atom_getfloatarg(14, argc, argv));
+ else
+ SETFLOAT(&(x->force[13]), -1000);
+
+ if (argc>=14)
+ SETFLOAT(&(x->force[12]), atom_getfloatarg(13, argc, argv));
+ else
+ SETFLOAT(&(x->force[12]), 0);
+
+ if (argc>=13)
+ SETFLOAT(&(x->force[11]), atom_getfloatarg(12, argc, argv));
+ else
+ SETFLOAT(&(x->force[11]), 0);
+
+ if (argc>=12)
+ SETFLOAT(&(x->force[10]), atom_getfloatarg(11, argc, argv));
+ else
+ SETFLOAT(&(x->force[10]), 0);
+
+ if (argc>=11)
+ SETFLOAT(&(x->force[9]), atom_getfloatarg(10, argc, argv));
+ else
+ SETFLOAT(&(x->force[9]), 0);
+
+ if (argc>=10)
+ SETFLOAT(&(x->force[8]), atom_getfloatarg(9, argc, argv));
+ else
+ SETFLOAT(&(x->force[8]), 0);
+
+ if (argc>=9)
+ SETFLOAT(&(x->force[7]), atom_getfloatarg(8, argc, argv));
+ else
+ SETFLOAT(&(x->force[7]), 1);
+
+ if (argc>=8)
+ SETFLOAT(&(x->force[6]), atom_getfloatarg(7, argc, argv));
+ else
+ SETFLOAT(&(x->force[6]), 0);
+
+ if (argc>=7)
+ SETFLOAT(&(x->force[5]), atom_getfloatarg(6, argc, argv));
+ else
+ SETFLOAT(&(x->force[5]), 0);
+
+ if (argc>=6)
+ SETFLOAT(&(x->force[4]), atom_getfloatarg(5, argc, argv));
+ else
+ SETFLOAT(&(x->force[4]), 0);
+
+ if (argc>=5)
+ SETFLOAT(&(x->force[3]), atom_getfloatarg(4, argc, argv));
+ else
+ SETFLOAT(&(x->force[3]), 0);
+
+ if (argc>=4)
+ SETFLOAT(&(x->force[2]), atom_getfloatarg(3, argc, argv));
+ else
+ SETFLOAT(&(x->force[2]), 0);
+
+ if (argc>=3)
+ SETFLOAT(&(x->force[1]), atom_getfloatarg(2, argc, argv));
+ else
+ SETFLOAT(&(x->force[1]), 0);
+
+ if (argc>=2)
+ SETFLOAT(&(x->force[0]), atom_getfloatarg(1, argc, argv));
+ else
+ SETFLOAT(&(x->force[0]), 1);
+
+ return (x);
+}
+
+void iCylinder3D_setup(void)
+{
+
+ iCylinder3D_class = class_new(gensym("iCylinder3D"),
+ (t_newmethod)iCylinder3D_new,
+ 0, sizeof(t_iCylinder3D),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addcreator((t_newmethod)iCylinder3D_new, gensym("pmpd.iCylinder3D"), A_GIMME, 0);
+
+ class_addbang(iCylinder3D_class, iCylinder3D_bang);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setVX, gensym("setVX"), A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setVY, gensym("setVY"), A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setVZ, gensym("setVZ"), A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setX, gensym("setX"), A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setY, gensym("setY"), A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setZ, gensym("setZ"), A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setRmin, gensym("setRmin"), A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setRmax, gensym("setRmax"), A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setXYZ, gensym("setXYZ"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setVXYZ, gensym("setVXYZ"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setPmin, gensym("setPmin"), A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setPmax, gensym("setPmax"), A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setFN, gensym("setFN"), A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setKN, gensym("setKN"), A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setRN, gensym("setRN"), A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setG, gensym("setG"), A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setD, gensym("setD"), A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setFT, gensym("setFT"), A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setKT, gensym("setKT"), A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setdN, gensym("setdN"), A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setdT, gensym("setdT"), A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setdKN, gensym("setdKN"), A_DEFFLOAT, 0);
+ class_addmethod(iCylinder3D_class, (t_method)iCylinder3D_setdKT, gensym("setdKT"), A_DEFFLOAT, 0);
+
+}
diff --git a/src/iLine2D.c b/src/iLine2D.c
new file mode 100755
index 0000000..d188d92
--- /dev/null
+++ b/src/iLine2D.c
@@ -0,0 +1,179 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *iLine2D_class;
+
+typedef struct _iLine2D {
+ t_object x_obj;
+ t_atom force[12];
+ t_outlet *force_new;// outlet
+ t_symbol *x_sym; // send
+} t_iLine2D;
+
+
+
+void iLine2D_bang(t_iLine2D *x)
+{
+ if (x->x_sym->s_thing) typedmess(x->x_sym->s_thing, gensym("interactor_line_2D"), 12, x->force);
+
+ outlet_anything(x->force_new, gensym("interactor_line_2D"), 12, x->force);
+}
+
+void iLine2D_X1(t_iLine2D *x, t_float Xmax)
+{
+ SETFLOAT(&(x->force[0]), Xmax);
+}
+
+void iLine2D_Y1(t_iLine2D *x, t_float Ymax)
+{
+ SETFLOAT(&(x->force[1]), Ymax);
+}
+
+void iLine2D_X2(t_iLine2D *x, t_float X)
+{
+ SETFLOAT(&(x->force[2]), X);
+}
+
+void iLine2D_Y2(t_iLine2D *x, t_float X)
+{
+ SETFLOAT(&(x->force[3]), X);
+}
+
+void iLine2D_setPmax(t_iLine2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[4]), f1);
+}
+
+void iLine2D_setFN(t_iLine2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[5]), f1);
+}
+
+void iLine2D_setFT(t_iLine2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[6]), f1);
+}
+
+void iLine2D_setKN(t_iLine2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[7]), f1);
+}
+
+void iLine2D_setDN(t_iLine2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[8]), f1);
+}
+
+void iLine2D_setDT(t_iLine2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[9]), f1);
+}
+
+void iLine2D_setdN(t_iLine2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[10]), f1);
+}
+
+void iLine2D_setdT(t_iLine2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[11]), f1);
+}
+
+void *iLine2D_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_iLine2D *x = (t_iLine2D *)pd_new(iLine2D_class);
+
+ x->x_sym = atom_getsymbolarg(0, argc, argv);
+
+ x->force_new=outlet_new(&x->x_obj, 0);
+
+
+ if (argc>=13)
+ SETFLOAT(&(x->force[11]), atom_getfloatarg(12, argc, argv));
+ else
+ SETFLOAT(&(x->force[11]), 0);
+
+ if (argc>=12)
+ SETFLOAT(&(x->force[10]), atom_getfloatarg(11, argc, argv));
+ else
+ SETFLOAT(&(x->force[10]), 0);
+
+ if (argc>=11)
+ SETFLOAT(&(x->force[9]), atom_getfloatarg(10, argc, argv));
+ else
+ SETFLOAT(&(x->force[9]), 0);
+
+ if (argc>=10)
+ SETFLOAT(&(x->force[8]), atom_getfloatarg(9, argc, argv));
+ else
+ SETFLOAT(&(x->force[8]), 0);
+
+ if (argc>=9)
+ SETFLOAT(&(x->force[7]), atom_getfloatarg(8, argc, argv));
+ else
+ SETFLOAT(&(x->force[7]), 0);
+
+ if (argc>=8)
+ SETFLOAT(&(x->force[6]), atom_getfloatarg(7, argc, argv));
+ else
+ SETFLOAT(&(x->force[6]), 0);
+
+ if (argc>=7)
+ SETFLOAT(&(x->force[5]), atom_getfloatarg(6, argc, argv));
+ else
+ SETFLOAT(&(x->force[5]), 0);
+
+ if (argc>=6)
+ SETFLOAT(&(x->force[4]), atom_getfloatarg(5, argc, argv));
+ else
+ SETFLOAT(&(x->force[4]), 1);
+
+ if (argc>=5)
+ SETFLOAT(&(x->force[3]), atom_getfloatarg(4, argc, argv));
+ else
+ SETFLOAT(&(x->force[3]), 0);
+
+ if (argc>=4)
+ SETFLOAT(&(x->force[2]), atom_getfloatarg(3, argc, argv));
+ else
+ SETFLOAT(&(x->force[2]), 1);
+
+ if (argc>=3)
+ SETFLOAT(&(x->force[1]), atom_getfloatarg(2, argc, argv));
+ else
+ SETFLOAT(&(x->force[1]), 0);
+
+ if (argc>=2)
+ SETFLOAT(&(x->force[0]), atom_getfloatarg(1, argc, argv));
+ else
+ SETFLOAT(&(x->force[0]), -1);
+
+ return (x);
+}
+
+void iLine2D_setup(void)
+{
+
+ iLine2D_class = class_new(gensym("iLine2D"),
+ (t_newmethod)iLine2D_new,
+ 0, sizeof(t_iLine2D),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addcreator((t_newmethod)iLine2D_new, gensym("pmpd.iLine2D"), A_GIMME, 0);
+
+ class_addbang(iLine2D_class, iLine2D_bang);
+ class_addmethod(iLine2D_class, (t_method)iLine2D_setPmax, gensym("setPmax"), A_DEFFLOAT, 0);
+ class_addmethod(iLine2D_class, (t_method)iLine2D_setFN, gensym("setFN"), A_DEFFLOAT, 0);
+ class_addmethod(iLine2D_class, (t_method)iLine2D_setFT, gensym("setFT"), A_DEFFLOAT, 0);
+ class_addmethod(iLine2D_class, (t_method)iLine2D_setKN, gensym("setKN"), A_DEFFLOAT, 0);
+ class_addmethod(iLine2D_class, (t_method)iLine2D_setDN, gensym("setDN"), A_DEFFLOAT, 0);
+ class_addmethod(iLine2D_class, (t_method)iLine2D_setDT, gensym("setDT"), A_DEFFLOAT, 0);
+ class_addmethod(iLine2D_class, (t_method)iLine2D_setdN, gensym("setdN"), A_DEFFLOAT, 0);
+ class_addmethod(iLine2D_class, (t_method)iLine2D_setdT, gensym("setdT"), A_DEFFLOAT, 0);
+ class_addmethod(iLine2D_class, (t_method)iLine2D_X1, gensym("setX1"), A_DEFFLOAT, 0);
+ class_addmethod(iLine2D_class, (t_method)iLine2D_Y1, gensym("setY1"), A_DEFFLOAT, 0);
+ class_addmethod(iLine2D_class, (t_method)iLine2D_X2, gensym("setX2"), A_DEFFLOAT, 0);
+ class_addmethod(iLine2D_class, (t_method)iLine2D_Y2, gensym("setY2"), A_DEFFLOAT, 0);
+
+
+}
diff --git a/src/iPlane3D.c b/src/iPlane3D.c
new file mode 100755
index 0000000..f9be065
--- /dev/null
+++ b/src/iPlane3D.c
@@ -0,0 +1,193 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *iPlane3D_class;
+
+typedef struct _iPlane3D {
+ t_object x_obj;
+ t_atom force[12];
+ t_outlet *force_new; // outlet
+ t_symbol *x_sym; // send
+
+} t_iPlane3D;
+
+
+
+void iPlane3D_bang(t_iPlane3D *x)
+{
+ if (x->x_sym->s_thing) typedmess(x->x_sym->s_thing, gensym("interactor_plane_3D"), 12, x->force);
+
+ outlet_anything(x->force_new, gensym("interactor_plane_3D"), 12, x->force);
+}
+
+void iPlane3D_setXYZ(t_iPlane3D *x, t_float X, t_float Y, t_float Z)
+{
+ SETFLOAT(&(x->force[3]), X);
+ SETFLOAT(&(x->force[4]), Y);
+ SETFLOAT(&(x->force[5]), Z);
+}
+void iPlane3D_setVXYZ(t_iPlane3D *x, t_float X, t_float Y, t_float Z)
+{
+ SETFLOAT(&(x->force[0]), X);
+ SETFLOAT(&(x->force[1]), Y);
+ SETFLOAT(&(x->force[2]), Z);
+}
+
+void iPlane3D_setVX(t_iPlane3D *x, t_float X)
+{
+ SETFLOAT(&(x->force[0]), X);
+}
+
+void iPlane3D_setVY(t_iPlane3D *x, t_float Y)
+{
+ SETFLOAT(&(x->force[1]), Y);
+}
+
+void iPlane3D_setVZ(t_iPlane3D *x, t_float Z)
+{
+ SETFLOAT(&(x->force[2]), Z);
+}
+void iPlane3D_setX(t_iPlane3D *x, t_float X)
+{
+ SETFLOAT(&(x->force[3]), X);
+}
+
+void iPlane3D_setY(t_iPlane3D *x, t_float Y)
+{
+ SETFLOAT(&(x->force[4]), Y);
+}
+
+void iPlane3D_setZ(t_iPlane3D *x, t_float Z)
+{
+ SETFLOAT(&(x->force[5]), Z);
+}
+
+void iPlane3D_setFN(t_iPlane3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[6]), f1);
+}
+
+void iPlane3D_setKN(t_iPlane3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[7]), f1);
+}
+
+void iPlane3D_setD(t_iPlane3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[8]), f1);
+}
+
+void iPlane3D_setP(t_iPlane3D *x, t_float X)
+{
+ SETFLOAT(&(x->force[9]), X);
+}
+
+void iPlane3D_setdN(t_iPlane3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[10]), f1);
+}
+
+void iPlane3D_setdKN(t_iPlane3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[11]), f1);
+}
+
+void *iPlane3D_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_iPlane3D *x = (t_iPlane3D *)pd_new(iPlane3D_class);
+
+ x->x_sym = atom_getsymbolarg(0, argc, argv);
+
+ x->force_new=outlet_new(&x->x_obj, 0);
+
+
+ if (argc>=13)
+ SETFLOAT(&(x->force[11]), atom_getfloatarg(12, argc, argv));
+ else
+ SETFLOAT(&(x->force[11]), 0);
+
+ if (argc>=12)
+ SETFLOAT(&(x->force[10]), atom_getfloatarg(11, argc, argv));
+ else
+ SETFLOAT(&(x->force[10]), 0);
+
+ if (argc>=11)
+ SETFLOAT(&(x->force[9]), atom_getfloatarg(10, argc, argv));
+ else
+ SETFLOAT(&(x->force[9]), 10000);
+
+ if (argc>=10)
+ SETFLOAT(&(x->force[8]), atom_getfloatarg(9, argc, argv));
+ else
+ SETFLOAT(&(x->force[8]), 0);
+
+ if (argc>=9)
+ SETFLOAT(&(x->force[7]), atom_getfloatarg(8, argc, argv));
+ else
+ SETFLOAT(&(x->force[7]), 0);
+
+ if (argc>=8)
+ SETFLOAT(&(x->force[6]), atom_getfloatarg(7, argc, argv));
+ else
+ SETFLOAT(&(x->force[6]), 0);
+
+ if (argc>=7)
+ SETFLOAT(&(x->force[5]), atom_getfloatarg(6, argc, argv));
+ else
+ SETFLOAT(&(x->force[5]), 0);
+
+ if (argc>=6)
+ SETFLOAT(&(x->force[4]), atom_getfloatarg(5, argc, argv));
+ else
+ SETFLOAT(&(x->force[4]), 0);
+
+ if (argc>=5)
+ SETFLOAT(&(x->force[3]), atom_getfloatarg(4, argc, argv));
+ else
+ SETFLOAT(&(x->force[3]), 0);
+
+ if (argc>=4)
+ SETFLOAT(&(x->force[2]), atom_getfloatarg(3, argc, argv));
+ else
+ SETFLOAT(&(x->force[2]), 0);
+
+ if (argc>=3)
+ SETFLOAT(&(x->force[1]), atom_getfloatarg(2, argc, argv));
+ else
+ SETFLOAT(&(x->force[1]), 0);
+
+ if (argc>=2)
+ SETFLOAT(&(x->force[0]), atom_getfloatarg(1, argc, argv));
+ else
+ SETFLOAT(&(x->force[0]), 1);
+
+ return (x);
+}
+
+void iPlane3D_setup(void)
+{
+
+ iPlane3D_class = class_new(gensym("iPlane3D"),
+ (t_newmethod)iPlane3D_new,
+ 0, sizeof(t_iPlane3D),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addcreator((t_newmethod)iPlane3D_new, gensym("pmpd.iPlane3D"), A_GIMME, 0);
+
+ class_addbang(iPlane3D_class, iPlane3D_bang);
+ class_addmethod(iPlane3D_class, (t_method)iPlane3D_setVX, gensym("setVX"), A_DEFFLOAT, 0);
+ class_addmethod(iPlane3D_class, (t_method)iPlane3D_setVY, gensym("setVY"), A_DEFFLOAT, 0);
+ class_addmethod(iPlane3D_class, (t_method)iPlane3D_setVZ, gensym("setVZ"), A_DEFFLOAT, 0);
+ class_addmethod(iPlane3D_class, (t_method)iPlane3D_setX, gensym("setX"), A_DEFFLOAT, 0);
+ class_addmethod(iPlane3D_class, (t_method)iPlane3D_setY, gensym("setY"), A_DEFFLOAT, 0);
+ class_addmethod(iPlane3D_class, (t_method)iPlane3D_setZ, gensym("setZ"), A_DEFFLOAT, 0);
+ class_addmethod(iPlane3D_class, (t_method)iPlane3D_setXYZ, gensym("setXYZ"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(iPlane3D_class, (t_method)iPlane3D_setVXYZ, gensym("setVXYZ"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(iPlane3D_class, (t_method)iPlane3D_setP, gensym("setPmax"), A_DEFFLOAT, 0);
+ class_addmethod(iPlane3D_class, (t_method)iPlane3D_setFN, gensym("setFN"), A_DEFFLOAT, 0);
+ class_addmethod(iPlane3D_class, (t_method)iPlane3D_setKN, gensym("setKN"), A_DEFFLOAT, 0);
+ class_addmethod(iPlane3D_class, (t_method)iPlane3D_setdKN, gensym("setdKN"), A_DEFFLOAT, 0);
+ class_addmethod(iPlane3D_class, (t_method)iPlane3D_setD, gensym("setD"), A_DEFFLOAT, 0);
+ class_addmethod(iPlane3D_class, (t_method)iPlane3D_setdN, gensym("setdN"), A_DEFFLOAT, 0);
+
+}
diff --git a/src/iSeg2D.c b/src/iSeg2D.c
new file mode 100755
index 0000000..77c740b
--- /dev/null
+++ b/src/iSeg2D.c
@@ -0,0 +1,175 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *iSeg2D_class;
+
+typedef struct _iSeg2D {
+ t_object x_obj;
+ t_atom force[12];
+ t_outlet *force_new;// outlet
+ t_symbol *x_sym; // send
+} t_iSeg2D;
+
+void iSeg2D_bang(t_iSeg2D *x)
+{
+ if (x->x_sym->s_thing) typedmess(x->x_sym->s_thing, gensym("interactor_segment_2D"), 12, x->force);
+
+ outlet_anything(x->force_new, gensym("interactor_segment_2D"), 12, x->force);
+}
+
+void iSeg2D_X1(t_iSeg2D *x, t_float Xmax)
+{
+ SETFLOAT(&(x->force[0]), Xmax);
+}
+
+void iSeg2D_Y1(t_iSeg2D *x, t_float Ymax)
+{
+ SETFLOAT(&(x->force[1]), Ymax);
+}
+
+void iSeg2D_X2(t_iSeg2D *x, t_float X)
+{
+ SETFLOAT(&(x->force[2]), X);
+}
+
+void iSeg2D_Y2(t_iSeg2D *x, t_float X)
+{
+ SETFLOAT(&(x->force[3]), X);
+}
+
+void iSeg2D_setPmax(t_iSeg2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[4]), f1);
+}
+
+void iSeg2D_setFN(t_iSeg2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[5]), f1);
+}
+
+void iSeg2D_setFT(t_iSeg2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[6]), f1);
+}
+
+void iSeg2D_setKN(t_iSeg2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[7]), f1);
+}
+
+void iSeg2D_setDN(t_iSeg2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[8]), f1);
+}
+
+void iSeg2D_setDT(t_iSeg2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[9]), f1);
+}
+
+void iSeg2D_setdN(t_iSeg2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[10]), f1);
+}
+
+void iSeg2D_setdT(t_iSeg2D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[11]), f1);
+}
+
+void *iSeg2D_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_iSeg2D *x = (t_iSeg2D *)pd_new(iSeg2D_class);
+
+ x->x_sym = atom_getsymbolarg(0, argc, argv);
+
+ x->force_new=outlet_new(&x->x_obj, 0);
+
+
+ if (argc>=13)
+ SETFLOAT(&(x->force[11]), atom_getfloatarg(12, argc, argv));
+ else
+ SETFLOAT(&(x->force[11]), 0);
+
+ if (argc>=12)
+ SETFLOAT(&(x->force[10]), atom_getfloatarg(11, argc, argv));
+ else
+ SETFLOAT(&(x->force[10]), 0);
+
+ if (argc>=11)
+ SETFLOAT(&(x->force[9]), atom_getfloatarg(10, argc, argv));
+ else
+ SETFLOAT(&(x->force[9]), 0);
+
+ if (argc>=10)
+ SETFLOAT(&(x->force[8]), atom_getfloatarg(9, argc, argv));
+ else
+ SETFLOAT(&(x->force[8]), 0);
+
+ if (argc>=9)
+ SETFLOAT(&(x->force[7]), atom_getfloatarg(8, argc, argv));
+ else
+ SETFLOAT(&(x->force[7]), 0);
+
+ if (argc>=8)
+ SETFLOAT(&(x->force[6]), atom_getfloatarg(7, argc, argv));
+ else
+ SETFLOAT(&(x->force[6]), 0);
+
+ if (argc>=7)
+ SETFLOAT(&(x->force[5]), atom_getfloatarg(6, argc, argv));
+ else
+ SETFLOAT(&(x->force[5]), 0);
+
+ if (argc>=6)
+ SETFLOAT(&(x->force[4]), atom_getfloatarg(5, argc, argv));
+ else
+ SETFLOAT(&(x->force[4]), 1);
+
+ if (argc>=5)
+ SETFLOAT(&(x->force[3]), atom_getfloatarg(4, argc, argv));
+ else
+ SETFLOAT(&(x->force[3]), 0);
+
+ if (argc>=4)
+ SETFLOAT(&(x->force[2]), atom_getfloatarg(3, argc, argv));
+ else
+ SETFLOAT(&(x->force[2]), 1);
+
+ if (argc>=3)
+ SETFLOAT(&(x->force[1]), atom_getfloatarg(2, argc, argv));
+ else
+ SETFLOAT(&(x->force[1]), 0);
+
+ if (argc>=2)
+ SETFLOAT(&(x->force[0]), atom_getfloatarg(1, argc, argv));
+ else
+ SETFLOAT(&(x->force[0]), -1);
+
+ return (x);
+}
+
+void iSeg2D_setup(void)
+{
+
+ iSeg2D_class = class_new(gensym("iSeg2D"),
+ (t_newmethod)iSeg2D_new,
+ 0, sizeof(t_iSeg2D),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addcreator((t_newmethod)iSeg2D_new, gensym("pmpd.iSeg2D"), A_GIMME, 0);
+
+ class_addbang(iSeg2D_class, iSeg2D_bang);
+ class_addmethod(iSeg2D_class, (t_method)iSeg2D_setPmax, gensym("setPmax"), A_DEFFLOAT, 0);
+ class_addmethod(iSeg2D_class, (t_method)iSeg2D_setFN, gensym("setFN"), A_DEFFLOAT, 0);
+ class_addmethod(iSeg2D_class, (t_method)iSeg2D_setFT, gensym("setFT"), A_DEFFLOAT, 0);
+ class_addmethod(iSeg2D_class, (t_method)iSeg2D_setKN, gensym("setKN"), A_DEFFLOAT, 0);
+ class_addmethod(iSeg2D_class, (t_method)iSeg2D_setDN, gensym("setDN"), A_DEFFLOAT, 0);
+ class_addmethod(iSeg2D_class, (t_method)iSeg2D_setDT, gensym("setDT"), A_DEFFLOAT, 0);
+ class_addmethod(iSeg2D_class, (t_method)iSeg2D_setdN, gensym("setdN"), A_DEFFLOAT, 0);
+ class_addmethod(iSeg2D_class, (t_method)iSeg2D_setdT, gensym("setdT"), A_DEFFLOAT, 0);
+ class_addmethod(iSeg2D_class, (t_method)iSeg2D_X1, gensym("setX1"), A_DEFFLOAT, 0);
+ class_addmethod(iSeg2D_class, (t_method)iSeg2D_Y1, gensym("setY1"), A_DEFFLOAT, 0);
+ class_addmethod(iSeg2D_class, (t_method)iSeg2D_X2, gensym("setX2"), A_DEFFLOAT, 0);
+ class_addmethod(iSeg2D_class, (t_method)iSeg2D_Y2, gensym("setY2"), A_DEFFLOAT, 0);
+}
diff --git a/src/iSphere3D.c b/src/iSphere3D.c
new file mode 100755
index 0000000..5b84171
--- /dev/null
+++ b/src/iSphere3D.c
@@ -0,0 +1,253 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *iSphere3D_class;
+
+typedef struct _iSphere3D {
+ t_object x_obj;
+ t_atom force[17];
+ // = Xcentre, Ycentre, .., Rmin, Rmax, Fnormal, K normal, F/R normal, DampNormal, dN, posX_old, posY_old, posZ_old, lia_damp, f/R2
+ t_outlet *force_new; // outlet
+ t_symbol *x_sym; // send
+ t_float posX_old, posY_old, posZ_old, posX, posY, posZ; // anciennes position, pour calculer la vitesse de cette interacteur.
+
+} t_iSphere3D;
+
+
+
+void iSphere3D_bang(t_iSphere3D *x)
+{
+
+ SETFLOAT(&(x->force[10]), x->posX_old); // posX_old
+ SETFLOAT(&(x->force[11]), x->posY_old); // posY_old
+ SETFLOAT(&(x->force[12]), x->posZ_old); // posZ_old
+
+ x->posX_old = x->posX;
+ x->posY_old = x->posY;
+ x->posZ_old = x->posZ;
+
+ if (x->x_sym->s_thing) typedmess(x->x_sym->s_thing, gensym("interactor_sphere_3D"), 17, x->force);
+
+ outlet_anything(x->force_new, gensym("interactor_sphere_3D"), 17, x->force);
+}
+
+void iSphere3D_setXYZ(t_iSphere3D *x, t_float X, t_float Y, t_float Z)
+{
+ SETFLOAT(&(x->force[0]), X);
+ x->posX= X;
+ SETFLOAT(&(x->force[1]), Y);
+ x->posY = Y;
+ SETFLOAT(&(x->force[2]), Z);
+ x->posZ = Z;
+}
+
+void iSphere3D_setX(t_iSphere3D *x, t_float X)
+{
+ SETFLOAT(&(x->force[0]), X);
+ x->posX= X;
+}
+
+void iSphere3D_setY(t_iSphere3D *x, t_float Y)
+{
+ SETFLOAT(&(x->force[1]), Y);
+ x->posY = Y;
+}
+
+void iSphere3D_setZ(t_iSphere3D *x, t_float Z)
+{
+ SETFLOAT(&(x->force[2]), Z);
+ x->posZ = Z;
+}
+
+void iSphere3D_setRmin(t_iSphere3D *x, t_float X)
+{
+ SETFLOAT(&(x->force[3]), X);
+}
+
+void iSphere3D_setRmax(t_iSphere3D *x, t_float X)
+{
+ SETFLOAT(&(x->force[4]), X);
+}
+
+void iSphere3D_setFN(t_iSphere3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[5]), f1);
+}
+
+void iSphere3D_setKN(t_iSphere3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[6]), f1);
+}
+
+void iSphere3D_setFRN(t_iSphere3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[7]), f1);
+}
+
+
+void iSphere3D_setDN(t_iSphere3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[8]), f1);
+}
+
+void iSphere3D_setdN(t_iSphere3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[9]), f1);
+}
+
+void iSphere3D_setG(t_iSphere3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[13]), f1);
+}
+
+void iSphere3D_setdKN(t_iSphere3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[14]), f1);
+}
+
+void iSphere3D_setdRN(t_iSphere3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[15]), f1);
+}
+
+void iSphere3D_setdGN(t_iSphere3D *x, t_floatarg f1)
+{
+ SETFLOAT(&(x->force[16]), f1);
+}
+
+void *iSphere3D_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_iSphere3D *x = (t_iSphere3D *)pd_new(iSphere3D_class);
+
+ x->x_sym = atom_getsymbolarg(0, argc, argv);
+
+ x->force_new=outlet_new(&x->x_obj, 0);
+
+ if (argc>=15)
+ SETFLOAT(&(x->force[16]), atom_getfloatarg(14, argc, argv));
+ else
+ SETFLOAT(&(x->force[16]), 0);
+
+ if (argc>=14)
+ SETFLOAT(&(x->force[15]), atom_getfloatarg(13, argc, argv));
+ else
+ SETFLOAT(&(x->force[15]), 0);
+
+ if (argc>=13)
+ SETFLOAT(&(x->force[14]), atom_getfloatarg(12, argc, argv));
+ else
+ SETFLOAT(&(x->force[14]), 0);
+
+ if (argc>=12)
+ SETFLOAT(&(x->force[13]), atom_getfloatarg(11, argc, argv));
+ else
+ SETFLOAT(&(x->force[13]), 0);
+
+ if (argc>=11)
+ SETFLOAT(&(x->force[9]), atom_getfloatarg(10, argc, argv));
+ else
+ SETFLOAT(&(x->force[9]), 0);
+
+ if (argc>=10)
+ SETFLOAT(&(x->force[8]), atom_getfloatarg(9, argc, argv));
+ else
+ SETFLOAT(&(x->force[8]), 0);
+
+ if (argc>=9)
+ SETFLOAT(&(x->force[7]), atom_getfloatarg(8, argc, argv));
+ else
+ SETFLOAT(&(x->force[7]), 0);
+
+ if (argc>=8)
+ SETFLOAT(&(x->force[6]), atom_getfloatarg(7, argc, argv));
+ else
+ SETFLOAT(&(x->force[6]), 0);
+
+ if (argc>=7)
+ SETFLOAT(&(x->force[5]), atom_getfloatarg(6, argc, argv));
+ else
+ SETFLOAT(&(x->force[5]), 0);
+
+ if (argc>=6)
+ SETFLOAT(&(x->force[4]), atom_getfloatarg(5, argc, argv));
+ else
+ SETFLOAT(&(x->force[4]), 1);
+
+ if (argc>=5)
+ SETFLOAT(&(x->force[3]), atom_getfloatarg(4, argc, argv));
+ else
+ SETFLOAT(&(x->force[3]), 0);
+
+ if (argc>=4)
+ {
+ SETFLOAT(&(x->force[12]), atom_getfloatarg(3, argc, argv));
+ SETFLOAT(&(x->force[2]), atom_getfloatarg(3, argc, argv));
+ x->posZ_old = atom_getfloatarg(3, argc, argv);
+ }
+ else
+ {
+ SETFLOAT(&(x->force[12]), 0);
+ SETFLOAT(&(x->force[2]), 0);
+ x->posZ_old = 0;
+ }
+
+ if (argc>=3)
+ {
+ SETFLOAT(&(x->force[11]), atom_getfloatarg(2, argc, argv));
+ SETFLOAT(&(x->force[1]), atom_getfloatarg(2, argc, argv));
+ x->posY_old = atom_getfloatarg(2, argc, argv);
+
+ }
+ else
+ {
+ SETFLOAT(&(x->force[1]), 0);
+ SETFLOAT(&(x->force[11]), 0);
+ x->posY_old = 0;
+ }
+
+ if (argc>=2)
+ {
+ SETFLOAT(&(x->force[10]), atom_getfloatarg(1, argc, argv));
+ SETFLOAT(&(x->force[0]), atom_getfloatarg(1, argc, argv));
+ x->posX_old = atom_getfloatarg(1, argc, argv);
+ }
+ else
+ {
+ SETFLOAT(&(x->force[10]), 0);
+ SETFLOAT(&(x->force[0]), 0);
+ x->posX_old = 0;
+ }
+
+ return (x);
+}
+
+void iSphere3D_setup(void)
+{
+
+ iSphere3D_class = class_new(gensym("iSphere3D"),
+ (t_newmethod)iSphere3D_new,
+ 0, sizeof(t_iSphere3D),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addcreator((t_newmethod)iSphere3D_new, gensym("pmpd.iSphere3D"), A_GIMME, 0);
+
+ class_addbang(iSphere3D_class, iSphere3D_bang);
+ class_addmethod(iSphere3D_class, (t_method)iSphere3D_setFN, gensym("setFN"), A_DEFFLOAT, 0);
+ class_addmethod(iSphere3D_class, (t_method)iSphere3D_setKN, gensym("setKN"), A_DEFFLOAT, 0);
+ class_addmethod(iSphere3D_class, (t_method)iSphere3D_setDN, gensym("setDN"), A_DEFFLOAT, 0);
+ class_addmethod(iSphere3D_class, (t_method)iSphere3D_setX, gensym("setX"), A_DEFFLOAT, 0);
+ class_addmethod(iSphere3D_class, (t_method)iSphere3D_setY, gensym("setY"), A_DEFFLOAT, 0);
+ class_addmethod(iSphere3D_class, (t_method)iSphere3D_setZ, gensym("setZ"), A_DEFFLOAT, 0);
+ class_addmethod(iSphere3D_class, (t_method)iSphere3D_setXYZ, gensym("setXYZ"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(iSphere3D_class, (t_method)iSphere3D_setRmin, gensym("setRmin"), A_DEFFLOAT, 0);
+ class_addmethod(iSphere3D_class, (t_method)iSphere3D_setRmax, gensym("setRmax"), A_DEFFLOAT, 0);
+ class_addmethod(iSphere3D_class, (t_method)iSphere3D_setFRN, gensym("setFRN"), A_DEFFLOAT, 0);
+ class_addmethod(iSphere3D_class, (t_method)iSphere3D_setdN, gensym("setdN"), A_DEFFLOAT, 0);
+ class_addmethod(iSphere3D_class, (t_method)iSphere3D_setdRN, gensym("setdRN"), A_DEFFLOAT, 0);
+ class_addmethod(iSphere3D_class, (t_method)iSphere3D_setG, gensym("setG"), A_DEFFLOAT, 0);
+ class_addmethod(iSphere3D_class, (t_method)iSphere3D_setdKN, gensym("setdKN"), A_DEFFLOAT, 0);
+ class_addmethod(iSphere3D_class, (t_method)iSphere3D_setdGN, gensym("setdGN"), A_DEFFLOAT, 0);
+
+}
+
+
diff --git a/src/lia.c b/src/lia.c
new file mode 100755
index 0000000..1293cac
--- /dev/null
+++ b/src/lia.c
@@ -0,0 +1,162 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *liaKD_class;
+
+typedef struct _liaKD {
+ t_object x_obj;
+ t_float raideur, viscosite, D2, longueur, distance_old, position1, position2, position_old1, position_old2;
+ t_outlet *force1;
+ t_outlet *force2;
+ t_float Lmin, Lmax;
+ t_symbol *x_sym; // receive
+} t_liaKD;
+
+void liaKD_float(t_liaKD *x, t_floatarg f1)
+{
+ x->position1 = f1;
+}
+
+void liaKD_bang(t_liaKD *x)
+{
+ t_float force1, force2, distance;
+
+ distance = (x->position2 - x->position1);
+//distance = abs(x->position2 - x->position1);
+ if (distance<0) distance = -distance;
+
+ force1 = x->raideur*(distance-(x->longueur)) + x->viscosite*(distance - x->distance_old) ;
+
+ x->distance_old = distance;
+
+ if (distance > x->Lmax) force1=0;
+ if (distance < x->Lmin) force1=0;
+
+ if (distance != 0)
+ {
+ force1 = force1 * (x->position2 - x->position1) / distance;
+ }
+
+ force2 = -force1 + (x->position_old2 - x->position2)*x->D2;
+ force1 += (x->position_old1 - x->position1)*x->D2;
+ // masse damping
+
+ outlet_float(x->force1, force1);
+ outlet_float(x->force2, force2);
+
+
+ x->position_old1 = x->position1;
+ x->position_old2 = x->position2;
+
+}
+
+void liaKD_reset(t_liaKD *x)
+{
+ x->position1 = 0;
+ x->position2 = 0;
+
+ x->position_old1 = 0;
+ x->position_old2 = 0;
+
+ x->distance_old = x->longueur;
+}
+
+void liaKD_resetF(t_liaKD *x)
+{
+ x->position_old1 = x->position1;
+ x->position_old2 = x->position2;
+
+ x->distance_old = x->longueur;
+}
+
+void liaKD_resetl(t_liaKD *x)
+{
+ x->longueur = (x->position1 - x->position2);
+}
+
+void liaKD_setL(t_liaKD *x, t_float L)
+{
+ x->longueur = L;
+}
+
+void liaKD_setK(t_liaKD *x, t_float K)
+{
+ x->raideur = K;
+}
+
+void liaKD_setD(t_liaKD *x, t_float D)
+{
+ x->viscosite = D;
+}
+
+void liaKD_setD2(t_liaKD *x, t_float D2)
+{
+ x->D2 = D2;
+}
+
+void liaKD_Lmin(t_liaKD *x, t_float Lmin)
+{
+ x->Lmin = Lmin;
+}
+
+void liaKD_Lmax(t_liaKD *x, t_float Lmax)
+{
+ x->Lmax = Lmax;
+}
+
+static void liaKD_free(t_liaKD *x)
+{
+ pd_unbind(&x->x_obj.ob_pd, x->x_sym);
+}
+
+void *liaKD_new(t_symbol *s, t_floatarg L, t_floatarg K, t_floatarg D, t_floatarg D2 )
+{
+
+ t_liaKD *x = (t_liaKD *)pd_new(liaKD_class);
+
+ x->x_sym = s;
+ pd_bind(&x->x_obj.ob_pd, s);
+
+ floatinlet_new(&x->x_obj, &x->position2);
+
+ x->force1=outlet_new(&x->x_obj, 0);
+ x->force2=outlet_new(&x->x_obj, 0);
+
+ x->position1 = 0;
+ x->position2 = 0;
+
+ x->raideur=K;
+ x->viscosite=D;
+ x->D2=D2;
+
+ x->Lmin= 0;
+ x->Lmax= 10000;
+
+ x->longueur=L;
+
+ return (void *)x;
+}
+
+void lia_setup(void)
+{
+ liaKD_class = class_new(gensym("lia"),
+ (t_newmethod)liaKD_new,
+ (t_method)liaKD_free,
+ sizeof(t_liaKD),
+ CLASS_DEFAULT, A_DEFSYM, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+
+ class_addcreator((t_newmethod)liaKD_new, gensym("link"), A_DEFSYM, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)liaKD_new, gensym("pmpd.link"), A_DEFSYM, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+
+ class_addfloat(liaKD_class, liaKD_float);
+ class_addbang(liaKD_class, liaKD_bang);
+ class_addmethod(liaKD_class, (t_method)liaKD_reset, gensym("reset"), 0);
+ class_addmethod(liaKD_class, (t_method)liaKD_resetl, gensym("resetL"), 0);
+ class_addmethod(liaKD_class, (t_method)liaKD_resetF, gensym("resetF"), 0);
+ class_addmethod(liaKD_class, (t_method)liaKD_setD, gensym("setD"), A_DEFFLOAT, 0);
+ class_addmethod(liaKD_class, (t_method)liaKD_setD2, gensym("setD2"), A_DEFFLOAT, 0);
+ class_addmethod(liaKD_class, (t_method)liaKD_setK, gensym("setK"), A_DEFFLOAT, 0);
+ class_addmethod(liaKD_class, (t_method)liaKD_setL, gensym("setL"), A_DEFFLOAT, 0);
+ class_addmethod(liaKD_class, (t_method)liaKD_Lmin, gensym("setLmin"), A_DEFFLOAT, 0);
+ class_addmethod(liaKD_class, (t_method)liaKD_Lmax, gensym("setLmax"), A_DEFFLOAT, 0);
+}
diff --git a/src/lia2D.c b/src/lia2D.c
new file mode 100755
index 0000000..ff5e0aa
--- /dev/null
+++ b/src/lia2D.c
@@ -0,0 +1,213 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *lia2D_class;
+
+typedef struct _lia2D {
+ t_object x_obj;
+ t_float raideur, viscosite, D2, longueur, distance_old;
+ t_float position2Dx1, position2Dx2, posx_old1, posx_old2;
+ t_float position2Dy1, position2Dy2, posy_old1, posy_old2;
+ t_float Lmin, Lmax, muscle;
+ t_outlet *force1;
+ t_outlet *force2;
+ t_symbol *x_sym; // receive
+} t_lia2D;
+
+void lia2D_position2D(t_lia2D *x, t_floatarg f1, t_floatarg f2)
+{
+ x->position2Dx1 = f1;
+ x->position2Dy1 = f2;
+}
+
+void lia2D_position2D2(t_lia2D *x, t_floatarg f1, t_floatarg f2)
+{
+ x->position2Dx2 = f1;
+ x->position2Dy2 = f2;
+}
+
+void lia2D_bang(t_lia2D *x)
+{
+ t_float force, force2, forcex1, forcey1, forcex2, forcey2, distance;
+ t_atom force1[2];
+
+ distance = sqrt ( pow((x->position2Dx2-x->position2Dx1), 2) + pow((x->position2Dy2-x->position2Dy1), 2) );
+
+ force = ( x->raideur*(distance-(x->longueur * x->muscle)) ) + ( x->viscosite*(distance-x->distance_old) );
+
+ if (distance > x->Lmax) force=0;
+ if (distance < x->Lmin) force=0;
+
+ if (distance != 0)
+ {
+ forcex1 = force * (x->position2Dx2 - x->position2Dx1) / distance;
+ forcey1 = force * (x->position2Dy2 - x->position2Dy1) / distance;
+ }
+ else
+ {
+ forcex1 = 0;
+ forcey1 = 0 ;
+ }
+
+ forcex2 = -forcex1;
+ forcey2 = -forcey1;
+
+ forcex1 += (x->posx_old1 - x->position2Dx1)*x->D2;
+ forcey1 += (x->posy_old1 - x->position2Dy1)*x->D2;
+
+ forcex2 += (x->posx_old2 - x->position2Dx2)*x->D2;
+ forcey2 += (x->posy_old2 - x->position2Dy2)*x->D2;
+
+ SETFLOAT(&(force1[0]), forcex2 );
+ SETFLOAT(&(force1[1]), forcey2 );
+
+ outlet_anything(x->force2, gensym("force2D"), 2, force1);
+
+ SETFLOAT(&(force1[0]), forcex1 );
+ SETFLOAT(&(force1[1]), forcey1 );
+
+ outlet_anything(x->force1, gensym("force2D"), 2, force1);
+
+ x->posx_old2 = x->position2Dx2;
+ x->posx_old1 = x->position2Dx1;
+
+ x->posy_old2 = x->position2Dy2;
+ x->posy_old1 = x->position2Dy1;
+
+ x->distance_old = distance;
+}
+
+void lia2D_reset(t_lia2D *x)
+{
+ x->position2Dx1 = 0;
+ x->position2Dx2 = 0;
+ x->posx_old1 = 0;
+ x->posx_old2 = 0;
+
+ x->position2Dy1 = 0;
+ x->position2Dy2 = 0;
+ x->posy_old1 = 0;
+ x->posy_old2 = 0;
+
+ x->distance_old = x->longueur;
+}
+
+void lia2D_resetF(t_lia2D *x)
+{
+
+ x->posx_old1 = x->position2Dx1;
+ x->posx_old2 = x->position2Dx2;
+
+ x->posy_old1 = x->position2Dy1;
+ x->posy_old2 = x->position2Dy2;
+
+ x->distance_old = x->longueur;
+
+}
+
+void lia2D_resetL(t_lia2D *x)
+{
+ x->longueur = sqrt ( pow((x->position2Dx2-x->position2Dx1), 2) + pow((x->position2Dy2-x->position2Dy1), 2) );
+}
+
+
+void lia2D_setK(t_lia2D *x, t_float K)
+{
+ x->raideur = K;
+}
+
+void lia2D_setL(t_lia2D *x, t_float L)
+{
+ x->longueur = L;
+}
+
+void lia2D_setD(t_lia2D *x, t_float D)
+{
+ x->viscosite = D;
+}
+
+void lia2D_setD2(t_lia2D *x, t_float D)
+{
+ x->D2 = D;
+}
+
+void lia2D_Lmin(t_lia2D *x, t_float Lmin)
+{
+ x->Lmin = Lmin;
+}
+
+void lia2D_Lmax(t_lia2D *x, t_float Lmax)
+{
+ x->Lmax = Lmax;
+}
+
+void lia2D_muscle(t_lia2D *x, t_float muscle)
+{
+ x->muscle = muscle;
+}
+
+static void lia2D_free(t_lia2D *x)
+{
+ pd_unbind(&x->x_obj.ob_pd, x->x_sym);
+}
+
+void *lia2D_new(t_symbol *s, t_floatarg l, t_floatarg K, t_floatarg D, t_floatarg D2)
+{
+
+ t_lia2D *x = (t_lia2D *)pd_new(lia2D_class);
+
+ x->x_sym = s;
+ pd_bind(&x->x_obj.ob_pd, s);
+
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("position2D"), gensym("position2D2"));
+
+ x->force1=outlet_new(&x->x_obj, 0);
+ x->force2=outlet_new(&x->x_obj, 0);
+
+ x->position2Dx1 = 0;
+ x->position2Dx2 = 0;
+ x->position2Dy1 = 0;
+ x->position2Dy2 = 0;
+
+ x->raideur=K;
+ x->viscosite=D;
+ x->longueur = l;
+
+ x->D2=D2;
+
+ x->Lmin= 0;
+ x->Lmax= 10000;
+ x->muscle= 1;
+
+ x->distance_old = x->longueur;
+
+ return (x);
+}
+
+void lia2D_setup(void)
+{
+
+ lia2D_class = class_new(gensym("lia2D"),
+ (t_newmethod)lia2D_new,
+ (t_method)lia2D_free,
+ sizeof(t_lia2D),
+ CLASS_DEFAULT, A_DEFSYM, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+
+ class_addcreator((t_newmethod)lia2D_new, gensym("link2D"), A_DEFSYM, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)lia2D_new, gensym("pmpd.link2D"), A_DEFSYM, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+
+ class_addbang(lia2D_class, lia2D_bang);
+ class_addmethod(lia2D_class, (t_method)lia2D_reset, gensym("reset"), 0);
+ class_addmethod(lia2D_class, (t_method)lia2D_resetL, gensym("resetL"), 0);
+ class_addmethod(lia2D_class, (t_method)lia2D_resetF, gensym("resetF"), 0);
+ class_addmethod(lia2D_class, (t_method)lia2D_setD, gensym("setD"), A_DEFFLOAT, 0);
+ class_addmethod(lia2D_class, (t_method)lia2D_setD2, gensym("setD2"), A_DEFFLOAT, 0);
+ class_addmethod(lia2D_class, (t_method)lia2D_setK, gensym("setK"), A_DEFFLOAT, 0);
+ class_addmethod(lia2D_class, (t_method)lia2D_setL, gensym("setL"), A_DEFFLOAT, 0);
+ class_addmethod(lia2D_class, (t_method)lia2D_Lmin, gensym("setLmin"), A_DEFFLOAT, 0);
+ class_addmethod(lia2D_class, (t_method)lia2D_Lmax, gensym("setLmax"), A_DEFFLOAT, 0);
+ class_addmethod(lia2D_class, (t_method)lia2D_muscle, gensym("setM"), A_DEFFLOAT, 0);
+ class_addmethod(lia2D_class, (t_method)lia2D_position2D, gensym("position2D"), A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(lia2D_class, (t_method)lia2D_position2D2, gensym("position2D2"), A_DEFFLOAT, A_DEFFLOAT, 0);
+
+}
diff --git a/src/lia3D.c b/src/lia3D.c
new file mode 100755
index 0000000..4621516
--- /dev/null
+++ b/src/lia3D.c
@@ -0,0 +1,238 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *lia3D_class;
+
+typedef struct _lia3D {
+ t_object x_obj;
+ t_float raideur, viscosite, D2, longueur, distance_old;
+ t_float position3Dx1, position3Dx2, posx_old1, posx_old2;
+ t_float position3Dy1, position3Dy2, posy_old1, posy_old2;
+ t_float position3Dz1, position3Dz2, posz_old1, posz_old2;
+ t_float Lmin, Lmax, muscle;
+ t_outlet *force1;
+ t_outlet *force2;
+ t_symbol *x_sym; // receive
+} t_lia3D;
+
+void lia3D_position3D(t_lia3D *x, t_floatarg f1, t_floatarg f2, t_floatarg f3)
+{
+ x->position3Dx1 = f1;
+ x->position3Dy1 = f2;
+ x->position3Dz1 = f3;
+
+}
+
+void lia3D_position3D2(t_lia3D *x, t_floatarg f1, t_floatarg f2, t_floatarg f3)
+{
+ x->position3Dx2 = f1;
+ x->position3Dy2 = f2;
+ x->position3Dz2 = f3;
+}
+
+void lia3D_bang(t_lia3D *x)
+{
+ t_float force, force2, forcex1, forcey1, forcez1, forcex2, forcey2, forcez2, distance;
+ t_atom force1[3];
+
+ distance = sqrt ( pow((x->position3Dx2-x->position3Dx1), 2) + pow((x->position3Dy2-x->position3Dy1),2) + pow((x->position3Dz2-x->position3Dz1), 2) );
+
+ force = ( x->raideur*(distance-(x->longueur * x->muscle)) ) + ( x->viscosite*(distance-x->distance_old) );
+
+ if (distance > x->Lmax) force=0;
+ if (distance < x->Lmin) force=0;
+
+ if (distance != 0)
+ {
+ forcex1 = force * (x->position3Dx2 - x->position3Dx1) / distance;
+ forcey1 = force * (x->position3Dy2 - x->position3Dy1) / distance;
+ forcez1 = force * (x->position3Dz2 - x->position3Dz1) / distance;
+ }
+ else
+ {
+ forcex1 = 0;
+ forcey1 = 0;
+ forcez1 = 0;
+ }
+
+ forcex2 = -forcex1;
+ forcey2 = -forcey1;
+ forcez2 = -forcez1;
+
+ forcex1 += (x->posx_old1 - x->position3Dx1)*x->D2;
+ forcey1 += (x->posy_old1 - x->position3Dy1)*x->D2;
+ forcez1 += (x->posz_old1 - x->position3Dz1)*x->D2;
+
+ forcex2 += (x->posx_old2 - x->position3Dx2)*x->D2;
+ forcey2 += (x->posy_old2 - x->position3Dy2)*x->D2;
+ forcez2 += (x->posz_old2 - x->position3Dz2)*x->D2;
+
+
+ SETFLOAT(&(force1[0]), forcex1 );
+ SETFLOAT(&(force1[1]), forcey1 );
+ SETFLOAT(&(force1[2]), forcez1 );
+ outlet_anything(x->force1, gensym("force3D"), 3, force1);
+
+ SETFLOAT(&(force1[0]), forcex2 );
+ SETFLOAT(&(force1[1]), forcey2 );
+ SETFLOAT(&(force1[2]), forcez2 );
+
+ outlet_anything(x->force2, gensym("force3D"), 3, force1);
+
+ x->posx_old2 = x->position3Dx2;
+ x->posx_old1 = x->position3Dx1;
+
+ x->posy_old2 = x->position3Dy2;
+ x->posy_old1 = x->position3Dy1;
+
+ x->posz_old2 = x->position3Dz2;
+ x->posz_old1 = x->position3Dz1;
+
+ x->distance_old = distance;
+}
+
+void lia3D_reset(t_lia3D *x)
+{
+ x->position3Dx1 = 0;
+ x->position3Dx2 = 0;
+ x->posx_old1 = 0;
+ x->posx_old2 = 0;
+
+ x->position3Dy1 = 0;
+ x->position3Dy2 = 0;
+ x->posy_old1 = 0;
+ x->posy_old2 = 0;
+
+ x->position3Dz1 = 0;
+ x->position3Dz2 = 0;
+ x->posz_old1 = 0;
+ x->posz_old2 = 0;
+
+ x->distance_old = x->longueur;
+
+}
+
+void lia3D_resetF(t_lia3D *x)
+{
+
+ x->posx_old1 = x->position3Dx1;
+ x->posx_old2 = x->position3Dx2;
+
+ x->posy_old1 = x->position3Dy1;
+ x->posy_old2 = x->position3Dy2;
+
+ x->posz_old1 = x->position3Dz1;
+ x->posz_old2 = x->position3Dz2;
+
+ x->distance_old = x->longueur;
+
+}
+
+void lia3D_resetL(t_lia3D *x)
+{
+ x->longueur = sqrt ( pow((x->position3Dx2-x->position3Dx1), 2) + pow((x->position3Dy2-x->position3Dy1),2) + pow((x->position3Dz2-x->position3Dz1), 2) );
+}
+
+void lia3D_setK(t_lia3D *x, t_float K)
+{
+ x->raideur = K;
+}
+
+void lia3D_setL(t_lia3D *x, t_float L)
+{
+ x->longueur = L;
+}
+
+void lia3D_setD(t_lia3D *x, t_float D)
+{
+ x->viscosite = D;
+}
+
+void lia3D_setD2(t_lia3D *x, t_float D2)
+{
+ x->D2 = D2;
+}
+
+void lia3D_Lmin(t_lia3D *x, t_float Lmin)
+{
+ x->Lmin = Lmin;
+}
+
+void lia3D_Lmax(t_lia3D *x, t_float Lmax)
+{
+ x->Lmax = Lmax;
+}
+
+void lia3D_muscle(t_lia3D *x, t_float muscle)
+{
+ x->muscle = muscle;
+}
+
+static void lia3D_free(t_lia3D *x)
+{
+ pd_unbind(&x->x_obj.ob_pd, x->x_sym);
+}
+
+void *lia3D_new(t_symbol *s, t_floatarg l, t_floatarg K, t_floatarg D, t_floatarg D2)
+{
+
+ t_lia3D *x = (t_lia3D *)pd_new(lia3D_class);
+
+ x->x_sym = s;
+ pd_bind(&x->x_obj.ob_pd, s);
+
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("position3D"), gensym("position3D2"));
+
+ x->force1=outlet_new(&x->x_obj, 0);
+ x->force2=outlet_new(&x->x_obj, 0);
+
+ x->position3Dx1 = 0;
+ x->position3Dx2 = 0;
+ x->position3Dy1 = 0;
+ x->position3Dy2 = 0;
+ x->position3Dz1 = 0;
+ x->position3Dz2 = 0;
+
+ x->raideur = K;
+ x->viscosite = D;
+ x->longueur = l;
+
+ x->D2 = D2;
+
+ x->Lmin= 0;
+ x->Lmax= 10000;
+
+ x->distance_old = x->longueur;
+
+ x->muscle = 1;
+
+ return (void *)x;
+}
+
+void lia3D_setup(void)
+{
+
+ lia3D_class = class_new(gensym("lia3D"),
+ (t_newmethod)lia3D_new,
+ (t_method)lia3D_free,
+ sizeof(t_lia3D),
+ CLASS_DEFAULT, A_DEFSYM, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+
+ class_addcreator((t_newmethod)lia3D_new, gensym("link3D"), A_DEFSYM, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)lia3D_new, gensym("pmpd.link3D"), A_DEFSYM, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+
+ class_addbang(lia3D_class, lia3D_bang);
+ class_addmethod(lia3D_class, (t_method)lia3D_reset, gensym("reset"), 0);
+ class_addmethod(lia3D_class, (t_method)lia3D_resetL, gensym("resetL"), 0);
+ class_addmethod(lia3D_class, (t_method)lia3D_resetF, gensym("resetF"), 0);
+ class_addmethod(lia3D_class, (t_method)lia3D_setD, gensym("setD"), A_DEFFLOAT, 0);
+ class_addmethod(lia3D_class, (t_method)lia3D_setD2, gensym("setD2"), A_DEFFLOAT, 0);
+ class_addmethod(lia3D_class, (t_method)lia3D_setK, gensym("setK"), A_DEFFLOAT, 0);
+ class_addmethod(lia3D_class, (t_method)lia3D_setL, gensym("setL"), A_DEFFLOAT, 0);
+ class_addmethod(lia3D_class, (t_method)lia3D_Lmin, gensym("setLmin"), A_DEFFLOAT, 0);
+ class_addmethod(lia3D_class, (t_method)lia3D_Lmax, gensym("setLmax"), A_DEFFLOAT, 0);
+ class_addmethod(lia3D_class, (t_method)lia3D_muscle, gensym("setM"), A_DEFFLOAT, 0);
+ class_addmethod(lia3D_class, (t_method)lia3D_position3D, gensym("position3D"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(lia3D_class, (t_method)lia3D_position3D2, gensym("position3D2"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+
+}
diff --git a/src/makefile b/src/makefile
new file mode 100755
index 0000000..32ef4e0
--- /dev/null
+++ b/src/makefile
@@ -0,0 +1,95 @@
+current:
+ echo make pd_linux, pd_nt, pd_darwin
+
+clean: ; rm -f *.pd_linux *.o
+
+# ----------------------- NT -----------------------
+
+pd_nt: pmpd.dll
+
+.SUFFIXES: .dll
+
+PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo
+VC="C:\Program Files\Microsoft Visual Studio\Vc98"
+
+PDNTINCLUDE = /I. /I\tcl\include /I\pds\win32\pd36\src /I$(VC)\include
+
+PDNTLDIR = $(VC)\lib
+PDNTLIB = $(PDNTLDIR)\libc.lib \
+ $(PDNTLDIR)\oldnames.lib \
+ $(PDNTLDIR)\kernel32.lib \
+ \pds\win32\pd37\bin\pd.lib
+
+.c.dll:
+ cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c
+ link /dll /export:$*_setup $*.obj $(PDNTLIB)
+
+# ----------------------- IRIX 5.x -----------------------
+
+pd_irix5: foo1.pd_irix5 foo2.pd_irix5 dspobj~.pd_irix5
+
+.SUFFIXES: .pd_irix5
+
+SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2
+
+
+SGIINCLUDE = -I../../src/
+
+.c.pd_irix5:
+ cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c
+ ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o
+ rm $*.o
+
+# ----------------------- IRIX 6.x -----------------------
+
+pd_irix6: foo1.pd_irix6 foo2.pd_irix6 dspobj~.pd_irix6
+
+.SUFFIXES: .pd_irix6
+
+SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \
+ -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \
+ -Ofast=ip32
+
+.c.pd_irix6:
+ cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c
+ ld -IPA -n32 -shared -rdata_shared -o $*.pd_irix6 $*.o
+ rm $*.o
+
+# ----------------------- LINUX i386 -----------------------
+
+pd_linux: pmpd.pd_linux
+
+.SUFFIXES: .pd_linux
+
+LINUXCFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer \
+ -Wall -W -Wshadow -Wstrict-prototypes -Werror \
+ -Wno-unused -Wno-parentheses -Wno-switch
+
+LINUXINCLUDE = -I../../src
+
+.c.pd_linux:
+ cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c
+ ld -export_dynamic -shared -o $*.pd_linux $*.o -lc -lm
+ strip --strip-unneeded $*.pd_linux
+ rm $*.o
+
+# ----------------------- Mac OS X (Darwin) -----------------------
+
+pd_darwin: pmpd.pd_darwin
+
+.SUFFIXES: .pd_darwin
+
+DARWINCFLAGS = -DPD -DUNIX -DMACOSX -O2 \
+ -Wall -W -Wshadow -Wstrict-prototypes \
+ -Wno-unused -Wno-parentheses -Wno-switch
+
+# where is your m_pd.h ???
+DARWININCLUDE = -I/. -I../pd/src -I../pd/obj
+
+.c.pd_darwin:
+ cc $(DARWINCFLAGS) $(DARWININCLUDE) -o $*.o -c $*.c
+ cc -bundle -undefined suppress -flat_namespace -o $*.pd_darwin $*.o
+ rm -f $*.o ../$*.pd_darwin
+ ln -s $*/$*.pd_darwin ..
+
+
diff --git a/src/masse.c b/src/masse.c
new file mode 100755
index 0000000..8241854
--- /dev/null
+++ b/src/masse.c
@@ -0,0 +1,153 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *masse_class;
+
+typedef struct _masse {
+ t_object x_obj;
+ t_float pos_old_1, pos_old_2, Xinit;
+ t_float force, masse, dX;
+ t_float minX, maxX;
+ t_outlet *position_new, *vitesse_out, *force_out;
+ t_symbol *x_sym; // receive
+} t_masse;
+
+extern t_float max(t_float, t_float);
+extern t_float min(t_float, t_float);
+
+
+void masse_minX(t_masse *x, t_floatarg f1)
+{
+ x->minX = f1;
+}
+
+void masse_maxX(t_masse *x, t_floatarg f1)
+{
+ x->maxX = f1;
+}
+
+void masse_float(t_masse *x, t_floatarg f1)
+{
+ x->force += f1;
+}
+
+void masse_bang(t_masse *x)
+{
+ t_float pos_new;
+
+ if (x->masse > 0)
+ pos_new = x->force/x->masse + 2*x->pos_old_1 - x->pos_old_2;
+ else pos_new = x->pos_old_1;
+
+ pos_new = max(min(x->maxX, pos_new), x->minX);
+
+ pos_new += x->dX;
+
+ x->pos_old_1 += x->dX; // pour ne pas avoir d'inertie suplementaire du a ce deplacement
+
+ outlet_float(x->vitesse_out, x->pos_old_1 - x->pos_old_2);
+ outlet_float(x->force_out, x->force);
+ outlet_float(x->position_new, pos_new);
+
+ x->pos_old_2 = x->pos_old_1;
+ x->pos_old_1 = pos_new;
+
+ x->force = 0;
+ x->dX = 0;
+
+}
+
+void masse_reset(t_masse *x)
+{
+ x->pos_old_2 = x->Xinit;
+ x->pos_old_1 = x->Xinit;
+
+ x->force=0;
+
+ outlet_float(x->position_new, x->Xinit);
+}
+
+void masse_resetF(t_masse *x)
+{
+ x->force=0;
+}
+
+void masse_dX(t_masse *x, t_float posX)
+{
+ x->dX += posX;
+}
+
+void masse_setX(t_masse *x, t_float posX)
+{
+ x->pos_old_2 = posX; // clear hystory for stability (instability) problem
+ x->pos_old_1 = posX;
+
+ x->force=0;
+
+ outlet_float(x->position_new, posX);
+}
+
+void masse_loadbang(t_masse *x)
+{
+ outlet_float(x->position_new, x->Xinit);
+}
+
+void masse_set_masse(t_masse *x, t_float mass)
+{
+ x->masse=mass;
+}
+
+static void masse_free(t_masse *x)
+{
+ pd_unbind(&x->x_obj.ob_pd, x->x_sym);
+}
+
+void *masse_new(t_symbol *s, t_floatarg M, t_floatarg X)
+{
+
+ t_masse *x = (t_masse *)pd_new(masse_class);
+
+ x->x_sym = s;
+ pd_bind(&x->x_obj.ob_pd, s);
+
+ x->position_new=outlet_new(&x->x_obj, 0);
+ x->force_out=outlet_new(&x->x_obj, 0);
+ x->vitesse_out=outlet_new(&x->x_obj, 0);
+
+ x->Xinit=X;
+
+ x->pos_old_1 = X;
+ x->pos_old_2 = X;
+ x->force=0;
+ x->masse=M;
+
+ x->minX = -100000;
+ x->maxX = 100000;
+
+ if (x->masse<=0) x->masse=1;
+
+ return (void *)x;
+}
+
+void masse_setup(void)
+{
+
+ masse_class = class_new(gensym("masse"),
+ (t_newmethod)masse_new,
+ (t_method)masse_free,
+ sizeof(t_masse),
+ CLASS_DEFAULT, A_DEFSYM, A_DEFFLOAT, A_DEFFLOAT,0);
+ class_addcreator((t_newmethod)masse_new, gensym("mass"), A_DEFSYM, A_DEFFLOAT, A_DEFFLOAT,0);
+ class_addcreator((t_newmethod)masse_new, gensym("pmpd.mass"), A_DEFSYM, A_DEFFLOAT, A_DEFFLOAT,0);
+ class_addfloat(masse_class, masse_float);
+ class_addbang(masse_class, masse_bang);
+ class_addmethod(masse_class, (t_method)masse_set_masse, gensym("setM"), A_DEFFLOAT, 0);
+ class_addmethod(masse_class, (t_method)masse_setX, gensym("setX"), A_DEFFLOAT, 0);
+ class_addmethod(masse_class, (t_method)masse_dX, gensym("dX"), A_DEFFLOAT, 0);
+ class_addmethod(masse_class, (t_method)masse_reset, gensym("reset"), 0);
+ class_addmethod(masse_class, (t_method)masse_resetF, gensym("resetF"), 0);
+ class_addmethod(masse_class, (t_method)masse_minX, gensym("setXmin"), A_DEFFLOAT, 0);
+ class_addmethod(masse_class, (t_method)masse_maxX, gensym("setXmax"), A_DEFFLOAT, 0);
+ class_addmethod(masse_class, (t_method)masse_loadbang, gensym("loadbang"), 0);
+}
+
diff --git a/src/masse2D.c b/src/masse2D.c
new file mode 100755
index 0000000..067a69b
--- /dev/null
+++ b/src/masse2D.c
@@ -0,0 +1,810 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *masse2D_class;
+
+typedef struct _masse2D {
+ t_object x_obj;
+ t_float posX_old_1, posX_old_2, posY_old_1, posY_old_2, Xinit, Yinit;
+ t_float forceX, forceY, VX, VY, dX, dY, onoff;
+ t_float masse2D, seuil, damp;
+ t_float minX, maxX, minY, maxY;
+ t_atom pos_new[2], vitesse[3], force[3];
+ t_outlet *position2D_new, *vitesse_out, *force_out;
+ t_symbol *x_sym; // receive
+ unsigned int x_state; // random
+ t_float x_f; // random
+} t_masse2D;
+
+extern t_float max(t_float, t_float);
+extern t_float min(t_float, t_float);
+
+
+static int makeseed(void)
+{
+ static unsigned int random_nextseed = 1489853723;
+ random_nextseed = random_nextseed * 435898247 + 938284287;
+ return (random_nextseed & 0x7fffffff);
+}
+
+static float random_bang(t_masse2D *x)
+{
+ int nval;
+ int range = 2000000;
+ float rnd;
+ unsigned int randval = x->x_state;
+ x->x_state = randval = randval * 472940017 + 832416023;
+ nval = ((double)range) * ((double)randval)
+ * (1./4294967296.);
+ if (nval >= range) nval = range-1;
+
+ rnd=nval;
+
+ rnd-=1000000;
+ rnd=rnd/1000000.; //pour mettre entre -1 et 1;
+ return (rnd);
+}
+
+void masse2D_seuil(t_masse2D *x, t_floatarg f1)
+{
+ x->seuil = f1;
+}
+
+void masse2D_on(t_masse2D *x)
+{
+ x->onoff = 1;
+}
+
+void masse2D_off(t_masse2D *x)
+{
+ x->onoff = 0;
+}
+
+void masse2D_minX(t_masse2D *x, t_floatarg f1)
+{
+ x->minX = f1;
+}
+
+void masse2D_maxX(t_masse2D *x, t_floatarg f1)
+{
+ x->maxX = f1;
+}
+
+void masse2D_minY(t_masse2D *x, t_floatarg f1)
+{
+ x->minY = f1;
+}
+
+void masse2D_maxY(t_masse2D *x, t_floatarg f1)
+{
+ x->maxY = f1;
+}
+
+void masse2D_force(t_masse2D *x, t_floatarg f1, t_floatarg f2)
+{
+ x->forceX = x->forceX+f1;
+ x->forceY = x->forceY+f2;
+}
+
+void masse2D_displace(t_masse2D *x, t_floatarg f1, t_floatarg f2)
+{
+ x->dX += f1;
+ x->dY += f2;
+}
+
+void masse2D_damp(t_masse2D *x, t_floatarg f1)
+{
+ x->damp = f1;
+}
+
+void masse2D_dX(t_masse2D *x, t_floatarg f1)
+{
+ x->dX += f1;
+}
+
+void masse2D_dY(t_masse2D *x, t_floatarg f1)
+{
+ x->dY += f1;
+}
+
+void masse2D_bang(t_masse2D *x)
+{
+ t_float posX_new, posY_new, vX=1, vY=1;
+ if (x->onoff != 0)
+ {
+
+ if (x->seuil > 0)
+ {
+ if (x->posY_old_1 == x->minY) // si on est en dehors de la structure -> frottement sec sur les bords
+ {
+ if (fabs(x->forceX)<=(x->seuil * -(x->forceY)))
+ vX = 0; // on est a l'interieur du cone de frotement,
+ }
+
+ if (x->posY_old_1 == x->maxY) // si on est en dehors de la structure -> frottement sec sur les bords
+ {
+ if (fabs(x->forceX)<=(x->seuil * (x->forceY)))
+ vX = 0; // on est a l'interieur du cone de frotement,
+ }
+
+ if (x->posX_old_1 == x->minX) // si on est en dehors de la structure -> frottement sec sur les bords
+ {
+ if (fabs(x->forceX)<=(x->seuil * -(x->forceY)))
+ vY = 0; // on est a l'interieur du cone de frotement,
+ }
+
+ if (x->posX_old_1 == x->maxX) // si on est en dehors de la structure -> frottement sec sur les bords
+ {
+ if (fabs(x->forceX)<=(x->seuil * (x->forceY)))
+ vY = 0; // on est a l'interieur du cone de frotement,
+ }
+ }
+
+ x->forceX += x->damp * ((x->posX_old_2)-(x->posX_old_1));
+ x->forceY += x->damp * ((x->posY_old_2)-(x->posY_old_1)); // damping
+
+
+ if (x->masse2D != 0)
+ {
+ posX_new = x->forceX/x->masse2D + 2*x->posX_old_1 - x->posX_old_2;
+ posY_new = x->forceY/x->masse2D + 2*x->posY_old_1 - x->posY_old_2;
+ }
+ else
+ {
+ posX_new = x->posX_old_1;
+ posY_new = x->posY_old_1;
+ }
+
+ if (vX==0)
+ posX_new = x->posX_old_1; // on n'a pas de mv qd on est a l'interieur du cone de frotement
+ if (vY==0)
+ posY_new = x->posY_old_1;
+
+ posX_new = max(min(posX_new, x->maxX), x->minX);
+ posY_new = max(min(posY_new, x->maxY), x->minY);
+
+ posX_new += x->dX;
+ posY_new += x->dY;
+
+ x->posX_old_1 += x->dX; // pour eviter l'inertie
+ x->posY_old_1 += x->dY;
+
+ SETFLOAT(&(x->pos_new[0]), posX_new );
+ SETFLOAT(&(x->pos_new[1]), posY_new );
+
+ x->posX_old_2 = x->posX_old_1;
+ x->posX_old_1 = posX_new;
+
+ x->posY_old_2 = x->posY_old_1;
+ x->posY_old_1 = posY_new;
+
+ SETFLOAT(&(x->force[0]), x->forceX );
+ SETFLOAT(&(x->force[1]), x->forceY );
+ SETFLOAT(&(x->force[2]), sqrt( (x->forceX * x->forceX) + (x->forceY * x->forceY) ));
+
+ x->forceX=0;
+ x->forceY=0;
+
+ x->dX=0;
+ x->dY=0;
+
+ x->VX = x->posX_old_1 - x->posX_old_2;
+ x->VY = x->posY_old_1 - x->posY_old_2;
+
+ SETFLOAT(&(x->vitesse[0]), x->VX );
+ SETFLOAT(&(x->vitesse[1]), x->VY );
+ SETFLOAT(&(x->vitesse[2]), sqrt( (x->VX * x->VX) + (x->VY * x->VY) ));
+
+ outlet_anything(x->vitesse_out, gensym("velocity2D"), 3, x->vitesse);
+ outlet_anything(x->force_out, gensym("force2D"), 3, x->force);
+ outlet_anything(x->position2D_new, gensym("position2D"), 2, x->pos_new);
+ }
+}
+
+void masse2D_reset(t_masse2D *x)
+{
+ x->posX_old_2 = x->Xinit;
+ x->posX_old_1 = x->Xinit;
+ x->forceX=0;
+
+ x->posY_old_2 = x->Yinit;
+ x->posY_old_1 = x->Yinit;
+ x->forceY=0;
+
+ x->VX = 0;
+ x->VY = 0;
+
+ x->dX=0;
+ x->dY=0;
+
+ x->seuil=0;
+
+ x->onoff = 1;
+
+ SETFLOAT(&(x->pos_new[0]), x->Xinit );
+ SETFLOAT(&(x->pos_new[1]), x->Yinit );
+
+ SETFLOAT(&(x->force[0]), 0 );
+ SETFLOAT(&(x->force[1]), 0 );
+ SETFLOAT(&(x->force[2]), 0 );
+
+ SETFLOAT(&(x->vitesse[0]), 0 );
+ SETFLOAT(&(x->vitesse[1]), 0 );
+ SETFLOAT(&(x->vitesse[2]), 0 );
+
+ outlet_anything(x->vitesse_out, gensym("velocity2D"), 3, x->vitesse);
+ outlet_anything(x->force_out, gensym("force2D"), 3, x->force);
+ outlet_anything(x->position2D_new, gensym("position2D"), 2, x->pos_new);
+}
+
+void masse2D_resetf(t_masse2D *x)
+{
+ x->dX=0;
+ x->dY=0;
+
+ x->forceX=0;
+ x->forceY=0;
+}
+
+void masse2D_setXY(t_masse2D *x, t_float posX, t_float posY)
+{
+ x->posX_old_2 = posX;
+ x->posX_old_1 = posX;
+ x->forceX=0;
+
+ x->posY_old_2 = posY;
+ x->posY_old_1 = posY;
+ x->forceY=0;
+
+ SETFLOAT(&(x->pos_new[0]), posX );
+ SETFLOAT(&(x->pos_new[1]), posY );
+
+ outlet_anything(x->position2D_new, gensym("position2D"), 2, x->pos_new);
+}
+
+void masse2D_setX(t_masse2D *x, t_float posX)
+{
+ x->posX_old_2 = posX;
+ x->posX_old_1 = posX;
+ x->forceX=0;
+
+ SETFLOAT(&(x->pos_new[0]), posX );
+
+ outlet_anything(x->position2D_new, gensym("position2D"), 2, x->pos_new);
+}
+
+void masse2D_setY(t_masse2D *x, t_float posY)
+{
+ x->posY_old_2 = posY;
+ x->posY_old_1 = posY;
+ x->forceY=0;
+
+ SETFLOAT(&(x->pos_new[1]), posY );
+
+ outlet_anything(x->position2D_new, gensym("position2D"), 2, x->pos_new);
+}
+
+void masse2D_loadbang(t_masse2D *x)
+{
+ outlet_anything(x->position2D_new, gensym("position2D"), 2, x->pos_new);
+}
+
+
+void masse2D_set_masse2D(t_masse2D *x, t_float mass)
+{
+ x->masse2D=mass;
+}
+
+void masse2D_inter_ambient(t_masse2D *x, t_symbol *s, int argc, t_atom *argv)
+{
+ if (argc == 12)
+ // 0 : FX
+ // 1 : FY
+ // 2 : RndX
+ // 3 : RndY
+ // 4 : D2
+ // 5 : rien
+ // 6 : Xmin
+ // 7 : Xmax
+ // 8 : Ymin
+ // 9 : Ymax
+ // 10 : dX
+ // 11 : dY
+ {
+ if (x->posX_old_1 > atom_getfloatarg(6, argc, argv))
+ {
+ if (x->posX_old_1 < atom_getfloatarg(7, argc, argv))
+ {
+ if (x->posY_old_1 > atom_getfloatarg(8, argc, argv))
+ {
+ if (x->posY_old_1 < atom_getfloatarg(9, argc, argv))
+ {
+ x->forceX += atom_getfloatarg(0, argc, argv);
+ x->forceY += atom_getfloatarg(1, argc, argv); // constant
+
+ x->forceX += random_bang(x)*atom_getfloatarg(2, argc, argv);
+ x->forceY += random_bang(x)*atom_getfloatarg(3, argc, argv); // random
+
+ x->forceX += atom_getfloatarg(4, argc, argv) * ((x->posX_old_2)-(x->posX_old_1));
+ x->forceY += atom_getfloatarg(4, argc, argv) * ((x->posY_old_2)-(x->posY_old_1)); // damping
+
+ x->dX += atom_getfloatarg(10, argc, argv);
+ x->dY += atom_getfloatarg(11, argc, argv); // constant
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ error("bad ambient interraction message");
+ }
+}
+
+void masse2D_inter_seg(t_masse2D *x, t_symbol *s, int argc, t_atom *argv)
+{
+t_float a1, b1, c1, a2, b2, c2, a3, b3, c3, tmp;
+t_float posx1, posx2, posy1, posy2;
+t_float profondeur, prof_max;
+
+ if (argc == 12)
+ // 0 : posx1
+ // 1 : posy1
+ // 2 : posx2
+ // 3 : posy2
+ // 4 : profondeur max
+ // 5 : F CT Normal
+ // 6 : F CT Tengentiel
+ // 7 : K normal
+ // 8 : Damp2 normal
+ // 9 : Damp2 tan
+ // 10 : displacement Normal
+ // 11 : d Tan
+
+ {
+ posx1 = atom_getfloatarg(0, argc, argv);
+ posy1 = atom_getfloatarg(1, argc, argv);
+ posx2 = atom_getfloatarg(2, argc, argv);
+ posy2 = atom_getfloatarg(3, argc, argv);
+
+ b1 = posx2 - posx1;
+ a1 = -posy2 + posy1;
+
+ if (!((a1==0) & (b1==0)))
+ {
+
+ tmp = sqrt((a1*a1)+(b1*b1)); // = longueur du vecteur pour renormalisation
+ if (tmp !=0)
+ {
+ a1 = a1/tmp;
+ b1 = b1/tmp;
+ }
+ else
+ {
+ a1 = 0;
+ b1 = 0;
+ }
+
+ c1 = a1*posx1+b1*posy1;
+
+ profondeur = ( (a1 * x->posX_old_1) + (b1 * x->posY_old_1) ) - c1;
+
+ if ( ( profondeur < 0) & (profondeur > - atom_getfloatarg(4, argc, argv)) )
+ {
+ a2 = b1;
+ b2 = -a1;
+ c2 = a2*posx1+b2*posy1;
+ if (( (a2 * x->posX_old_1) + (b2 * x->posY_old_1) ) > c2)
+ {
+ a3 = a2;
+ b3 = b2;
+ c3 = a3*posx2+b3*posy2;
+ if (( (a3 * x->posX_old_1) + (b3 * x->posY_old_1) ) < c3)
+ {
+ tmp = atom_getfloatarg(5, argc, argv); // force ct normal
+ x->forceX += tmp * a1;
+ x->forceY += tmp * b1;
+
+ tmp = atom_getfloatarg(6, argc, argv); // force ct normal
+ x->forceX -= tmp * b1;
+ x->forceY -= tmp * -a1;
+
+ tmp = atom_getfloatarg(7, argc, argv); // force K normal
+ tmp *= profondeur;
+ x->forceX -= tmp * a1;
+ x->forceY -= tmp * b1;
+
+ tmp = atom_getfloatarg(8, argc, argv); // damping2 normal
+ tmp *= ( x->VX * a1 + x->VY * b1 );
+ x->forceX -= tmp * a1 ;
+ x->forceY -= tmp * b1 ;
+
+ tmp = atom_getfloatarg(9, argc, argv); // damping2 tangentiel
+ tmp *= ( x->VX * b1 - x->VY * a1 );
+ x->forceX -= tmp * b1 ;
+ x->forceY -= tmp * -a1 ;
+
+ tmp = atom_getfloatarg(10, argc, argv); // displacement normal
+ x->dX += tmp * a1 ;
+ x->dY += tmp * b1 ;
+
+ tmp = atom_getfloatarg(11, argc, argv); // displacement tengentiel
+ x->dX -= tmp * b1 ;
+ x->dY -= tmp * -a1 ;
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ error("bad interact_2D_segment message");
+ }
+}
+
+void masse2D_inter_line(t_masse2D *x, t_symbol *s, int argc, t_atom *argv)
+{
+t_float a1, b1, c1, tmp;
+t_float posx1, posx2, posy1, posy2;
+t_float profondeur, prof_max;
+
+ if (argc == 12)
+ // 0 : posx1
+ // 1 : posy1
+ // 2 : posx2
+ // 3 : posy2
+ // 4 : profondeur max
+ // 5 : F CT Normal
+ // 6 : F CT Tengentiel
+ // 7 : K normal
+ // 8 : Damp2 normal
+ // 9 : Damp2 tan
+ // 10 : d normal
+ // 11 : d tengential
+ {
+ posx1 = atom_getfloatarg(0, argc, argv);
+ posy1 = atom_getfloatarg(1, argc, argv);
+ posx2 = atom_getfloatarg(2, argc, argv);
+ posy2 = atom_getfloatarg(3, argc, argv);
+
+ b1 = posx2 - posx1;
+ a1 = -posy2 + posy1;
+
+ if (!((a1==0) & (b1==0)))
+ {
+ tmp = sqrt((a1*a1)+(b1*b1)); // = longueur du vecteur pour renormalisation
+ a1 = a1/tmp; // composante X de la normal
+ b1 = b1/tmp; // composante Y de la normal
+ c1 = a1*posx1+b1*posy1; //
+
+ profondeur = ( (a1 * x->posX_old_1) + (b1 * x->posY_old_1) ) - c1;
+ if ( ( profondeur < 0) & (profondeur > - atom_getfloatarg(4, argc, argv)) )
+ {
+ tmp = atom_getfloatarg(5, argc, argv); // force ct normal
+ x->forceX += tmp * a1;
+ x->forceY += tmp * b1;
+
+ tmp = atom_getfloatarg(6, argc, argv); // force ct tengentiel
+ x->forceX -= tmp * b1;
+ x->forceY -= tmp * -a1;
+
+ tmp = atom_getfloatarg(7, argc, argv); // force K normal
+ tmp *= profondeur ;
+ x->forceX -= tmp * a1;
+ x->forceY -= tmp * b1;
+
+ tmp = atom_getfloatarg(8, argc, argv); // damping2 normal
+ tmp *= ( x->VX * a1 + x->VY * b1 ) ;
+ x->forceX -= tmp * a1 ;
+ x->forceY -= tmp * b1 ;
+
+ tmp = atom_getfloatarg(9, argc, argv); // damping2 tangentiel
+ tmp *= ( x->VX * b1 - x->VY * a1 );
+ x->forceX -= tmp * b1 ;
+ x->forceY -= tmp * -a1 ;
+
+ tmp = atom_getfloatarg(10, argc, argv); // d normal
+ x->dX += tmp * a1;
+ x->dY += tmp * b1;
+
+ tmp = atom_getfloatarg(11, argc, argv); // d tangentiel
+ x->dX -= tmp * b1;
+ x->dY -= tmp * -a1;
+ }
+ }
+ }
+ else
+ {
+ error("bad interact_2D_line message");
+ }
+}
+
+void masse2D_inter_circle(t_masse2D *x, t_symbol *s, int argc, t_atom *argv)
+{
+t_float posx1, posy1, Nx, Ny, dx, dy, distance, Dmax, tmp;
+t_float deltaX_old, deltaY_old, distance_old ;
+t_float fnx=0, fny=0;
+t_float ftx=0, fty=0;
+
+ if (argc == 20)
+ // 0 : Xcentre
+ // 1 : Ycendre
+ // 2 : Rmin
+ // 3 : Rmax
+ // 4 : F normal
+ // 5 : F tangentiel
+ // 6 : K normal
+ // 7 : K tengentiel
+ // 8 : F normal proportionel a 1/R
+ // 9 : F tengentiel proportionel a 1/R
+ // 10 : Damp2 normal
+ // 11 : Damp2 tan
+ // 12 : deplacement N proportionel a 1/R
+ // 13 : deplacement tengentiel proportionel a 1/R
+ // 14 : position ancienne de l'interacteur en X
+ // 15 : position abcienne de l'interacteur en Y
+ // 16 : damping de liaison
+ // 17 : F normal proportionel a 1/R*R
+ // 18 : normal displacement
+ // 19 : tengential displacement
+
+ {
+ posx1 = atom_getfloatarg(0, argc, argv);
+ posy1 = atom_getfloatarg(1, argc, argv);
+ Nx = (x->posX_old_1)-posx1; // vecteur deplacement X
+ Ny = (x->posY_old_1)-posy1; // vecteur deplacement Y
+
+ distance = sqrt((Nx * Nx)+(Ny * Ny)); // distance entre le centre de l'interaction, et le pts
+
+ Dmax= atom_getfloatarg(3, argc, argv); // distance max de l'interaction
+ if ( (distance > atom_getfloatarg(2, argc, argv)) & (distance < Dmax) )
+ {
+ Nx = Nx/distance; // composante X de la normal (normalisé)
+ Ny = Ny/distance; // composante Y de la normal.
+
+ tmp = atom_getfloatarg(4, argc, argv); // force constante normal
+// x->forceX += tmp * Nx;
+// x->forceY += tmp * Ny;
+ fnx +=tmp;
+// fny +=tmp;
+
+ tmp = atom_getfloatarg(5, argc, argv); // force constante tengentiel
+// x->forceX += tmp * Ny;
+// x->forceY += tmp * -Nx;
+ ftx +=tmp;
+// fty +=tmp;
+
+ tmp = atom_getfloatarg(6, argc, argv); // force variable (K) normal
+ tmp *= ( Dmax-distance );
+// x->forceX += tmp * Nx ;
+// x->forceY += tmp * Ny ;
+ fnx +=tmp;
+// fny +=tmp;
+
+ tmp = atom_getfloatarg(7, argc, argv); // force variable (K) tengentiel
+ tmp *= ( Dmax-distance );
+// x->forceX += tmp * Ny ;
+// x->forceY += tmp * -Nx ;
+ ftx +=tmp;
+// fty +=tmp;
+
+ tmp = atom_getfloatarg(8, argc, argv); // force normal proportionel a 1/r
+ if (distance != 0)
+ {
+ tmp /= distance;
+// x->forceX += tmp * Nx ;
+// x->forceY += tmp * Ny ;
+ fnx +=tmp;
+// fny +=tmp;
+ }
+
+ tmp = atom_getfloatarg(9, argc, argv); // force tengentiel proportionel a 1/r
+ if (distance != 0)
+ {
+ tmp /= distance;
+// x->forceX -= tmp * Ny ;
+// x->forceY -= tmp * -Nx ;
+ ftx -=tmp;
+// fty -=tmp;
+ }
+
+ tmp = atom_getfloatarg(10, argc, argv); // damping2 normal
+ tmp *= ( x->VX * Nx + x->VY * Ny );
+// x->forceX -= tmp * Nx ;
+// x->forceY -= tmp * Ny ;
+ fnx -=tmp;
+// fny -=tmp;
+
+ tmp = atom_getfloatarg(11, argc, argv); // damping2 tangentiel
+ tmp *= ( x->VX * Ny - x->VY * Nx );
+// x->forceX -= tmp * Ny ;
+// x->forceY -= tmp * -Ny ;
+ ftx -=tmp;
+// fty -=tmp;
+
+ tmp = atom_getfloatarg(12, argc, argv); // d normal
+ if (distance != 0)
+ {
+ tmp /= distance;
+ x->dX += tmp * Nx ;
+ x->dY += tmp * Ny ;
+ }
+
+ tmp = atom_getfloatarg(13, argc, argv); // d tangentiel
+ if (distance != 0)
+ {
+ tmp /= distance;
+
+ x->dX -= tmp * Ny ;
+ x->dY -= tmp * -Nx ;
+ }
+
+ tmp = atom_getfloatarg(16, argc, argv); // damping de liaison
+ if (tmp!= 0)
+ {
+ deltaX_old = atom_getfloatarg(14, argc, argv) - x->posX_old_2;
+ deltaY_old = atom_getfloatarg(15, argc, argv) - x->posY_old_2;
+ distance_old = sqrt( (deltaX_old * deltaX_old) + (deltaY_old * deltaY_old));
+
+// x->forceX -= Nx * tmp * (distance - distance_old);
+// x->forceY -= Ny * tmp * (distance - distance_old);
+
+ tmp *= (distance - distance_old);
+ fnx -=tmp;
+// fny -=tmp;
+ }
+
+ tmp = atom_getfloatarg(17, argc, argv); // force normal proportionel a 1/r2
+ if (distance != 0)
+ {
+ tmp /= (distance*distance);
+// x->forceX -= tmp * Nx;
+// x->forceY -= tmp * Ny;
+ fnx +=tmp;
+// fny +=tmp;
+ }
+
+ tmp = atom_getfloatarg(18, argc, argv); // deplacement constante normal
+ x->dX += tmp * Nx;
+ x->dY += tmp * Ny;
+
+ tmp = atom_getfloatarg(19, argc, argv); // deplacement constante tengentiel
+ x->dX -= tmp * Ny;
+ x->dY -= tmp * -Nx;
+
+ x->forceX += fnx * Nx + ftx * Ny; // optimisation, but does not change anything...
+ x->forceY += fnx * Ny - ftx * Nx;
+ }
+ }
+ else
+ {
+ error("bad interact_2D_circle message");
+ }
+}
+
+void *masse2D_new(t_symbol *s, int argc, t_atom *argv)
+{
+
+ t_masse2D *x = (t_masse2D *)pd_new(masse2D_class);
+
+ x->x_sym = atom_getsymbolarg(0, argc, argv);
+ x->x_state = makeseed();
+
+ pd_bind(&x->x_obj.ob_pd, atom_getsymbolarg(0, argc, argv));
+
+ x->position2D_new=outlet_new(&x->x_obj, 0);
+ x->force_out=outlet_new(&x->x_obj, 0);
+ x->vitesse_out=outlet_new(&x->x_obj, 0);
+
+ x->forceX=0;
+ x->forceY=0;
+
+ if (argc >= 2)
+ x->masse2D = atom_getfloatarg(1, argc, argv) ;
+ else
+ x->masse2D = 1;
+
+ x->onoff = 1;
+
+ x->VX = 0;
+ x->VY = 0;
+
+ x->dX=0;
+ x->dY=0;
+
+ if (argc >= 3)
+ x->Xinit = atom_getfloatarg(2, argc, argv);
+ else
+ x->Xinit = 0 ;
+
+ x->posX_old_1 = x->Xinit ;
+ x->posX_old_2 = x->Xinit;
+ SETFLOAT(&(x->pos_new[0]), x->Xinit);
+
+ if (argc >= 4)
+ x->Yinit = atom_getfloatarg(3, argc, argv);
+ else
+ x->Yinit = 0 ;
+
+ x->posY_old_1 = x->Yinit ;
+ x->posY_old_2 = x->Yinit;
+ SETFLOAT(&(x->pos_new[1]), x->Yinit);
+
+ if (argc >= 5)
+ x->minX = atom_getfloatarg(4, argc, argv) ;
+ else
+ x->minX = -100000;
+
+ if (argc >= 6)
+ x->maxX = atom_getfloatarg(5, argc, argv) ;
+ else
+ x->maxX = 100000;
+
+ if (argc >= 7)
+ x->minY = atom_getfloatarg(6, argc, argv) ;
+ else
+ x->minY = -100000;
+
+ if (argc >= 8)
+ x->maxY = atom_getfloatarg(7, argc, argv) ;
+ else
+ x->maxY = 100000;
+
+ if (argc >= 9)
+ x->seuil = atom_getfloatarg(8, argc, argv) ;
+ else
+ x->seuil = 0;
+
+ if (argc >= 10)
+ x->damp = atom_getfloatarg(9, argc, argv) ;
+ else
+ x->damp = 0;
+
+ return (x);
+}
+
+static void masse2D_free(t_masse2D *x)
+{
+ pd_unbind(&x->x_obj.ob_pd, x->x_sym);
+}
+
+void masse2D_setup(void)
+{
+
+ masse2D_class = class_new(gensym("masse2D"),
+ (t_newmethod)masse2D_new,
+ (t_method)masse2D_free, sizeof(t_masse2D),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addcreator((t_newmethod)masse2D_new, gensym("mass2D"), A_GIMME, 0);
+ class_addcreator((t_newmethod)masse2D_new, gensym("pmpd.mass2D"), A_GIMME, 0);
+
+ class_addbang(masse2D_class, masse2D_bang);
+
+ class_addmethod(masse2D_class, (t_method)masse2D_force, gensym("force2D"),A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(masse2D_class, (t_method)masse2D_displace, gensym("dXY"),A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(masse2D_class, (t_method)masse2D_dX, gensym("dX"),A_DEFFLOAT, 0);
+ class_addmethod(masse2D_class, (t_method)masse2D_dY, gensym("dY"),A_DEFFLOAT, 0);
+
+ class_addmethod(masse2D_class, (t_method)masse2D_inter_ambient, gensym("interactor_ambient_2D"), A_GIMME, 0);
+ class_addmethod(masse2D_class, (t_method)masse2D_inter_line, gensym("interactor_line_2D"), A_GIMME, 0);
+ class_addmethod(masse2D_class, (t_method)masse2D_inter_seg, gensym("interactor_segment_2D"), A_GIMME, 0);
+ class_addmethod(masse2D_class, (t_method)masse2D_inter_circle, gensym("interactor_circle_2D"), A_GIMME, 0);
+
+ class_addmethod(masse2D_class, (t_method)masse2D_seuil, gensym("setT"), A_DEFFLOAT, 0);
+ class_addmethod(masse2D_class, (t_method)masse2D_set_masse2D, gensym("setM"), A_DEFFLOAT, 0);
+ class_addmethod(masse2D_class, (t_method)masse2D_setX, gensym("setX"), A_DEFFLOAT, 0);
+ class_addmethod(masse2D_class, (t_method)masse2D_setY, gensym("setY"), A_DEFFLOAT, 0);
+ class_addmethod(masse2D_class, (t_method)masse2D_minX, gensym("setXmin"), A_DEFFLOAT, 0);
+ class_addmethod(masse2D_class, (t_method)masse2D_minY, gensym("setYmin"), A_DEFFLOAT, 0);
+ class_addmethod(masse2D_class, (t_method)masse2D_maxX, gensym("setXmax"), A_DEFFLOAT, 0);
+ class_addmethod(masse2D_class, (t_method)masse2D_maxY, gensym("setYmax"), A_DEFFLOAT, 0);
+ class_addmethod(masse2D_class, (t_method)masse2D_setXY, gensym("setXY"), A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(masse2D_class, (t_method)masse2D_damp, gensym("setD"), A_DEFFLOAT, 0);
+ class_addmethod(masse2D_class, (t_method)masse2D_on, gensym("on"), 0);
+ class_addmethod(masse2D_class, (t_method)masse2D_off, gensym("off"), 0);
+ class_addmethod(masse2D_class, (t_method)masse2D_reset, gensym("reset"), 0);
+ class_addmethod(masse2D_class, (t_method)masse2D_resetf, gensym("resetF"), 0);
+ class_addmethod(masse2D_class, (t_method)masse2D_loadbang, gensym("loadbang"), 0);
+
+}
diff --git a/src/masse3D.c b/src/masse3D.c
new file mode 100755
index 0000000..68dda3b
--- /dev/null
+++ b/src/masse3D.c
@@ -0,0 +1,1093 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *masse3D_class;
+
+extern t_float max(t_float, t_float);
+extern t_float min(t_float, t_float);
+
+
+typedef struct _masse3D {
+ t_object x_obj;
+ t_float posX_old_1, posX_old_2, posY_old_1, posY_old_2, posZ_old_1, posZ_old_2;
+ t_float Xinit, Yinit, Zinit, forceX, forceY, forceZ, VX, VY, VZ, dX, dY, dZ;
+ t_float masse3D, seuil, onoff, damp;
+ t_atom pos_new[3], vitesse[4], force[4];
+ t_float minX, maxX, minY, maxY, minZ, maxZ;
+ t_outlet *position3D_new, *vitesse_out, *force_out;
+ t_symbol *x_sym; // receive
+ unsigned int x_state; // random
+ t_float x_f; // random
+} t_masse3D;
+
+void masse3D_on(t_masse3D *x)
+{
+ x->onoff = 1;
+}
+
+void masse3D_off(t_masse3D *x)
+{
+ x->onoff = 0;
+}
+
+void masse3D_minX(t_masse3D *x, t_floatarg f1)
+{
+ x->minX = f1;
+}
+
+void masse3D_maxX(t_masse3D *x, t_floatarg f1)
+{
+ x->maxX = f1;
+}
+
+void masse3D_minY(t_masse3D *x, t_floatarg f1)
+{
+ x->minY = f1;
+}
+
+void masse3D_maxY(t_masse3D *x, t_floatarg f1)
+{
+ x->maxY = f1;
+}
+
+void masse3D_minZ(t_masse3D *x, t_floatarg f1)
+{
+ x->minZ = f1;
+}
+
+void masse3D_maxZ(t_masse3D *x, t_floatarg f1)
+{
+ x->maxZ = f1;
+}
+
+void masse3D_seuil(t_masse3D *x, t_floatarg f1)
+{
+ x->seuil = f1;
+}
+
+void masse3D_damp(t_masse3D *x, t_floatarg f1)
+{
+ x->damp = f1;
+}
+
+void masse3D_loadbang(t_masse3D *x, t_float posZ)
+{
+ outlet_anything(x->position3D_new, gensym("position3D"), 3, x->pos_new);
+}
+
+void masse3D_setX(t_masse3D *x, t_float posX)
+{
+
+ x->posX_old_2 = posX;
+ x->posX_old_1 = posX;
+ x->forceX=0;
+
+ SETFLOAT(&(x->pos_new[0]), posX);
+
+ outlet_anything(x->position3D_new, gensym("position3D"), 3, x->pos_new);
+
+}
+
+void masse3D_setY(t_masse3D *x, t_float posY)
+{
+ x->posY_old_2 = posY;
+ x->posY_old_1 = posY;
+ x->forceY=0;
+
+ SETFLOAT(&(x->pos_new[1]), posY);
+
+ outlet_anything(x->position3D_new, gensym("position3D"), 3, x->pos_new);
+
+}
+
+void masse3D_setZ(t_masse3D *x, t_float posZ)
+{
+ x->posZ_old_2 = posZ;
+ x->posZ_old_1 = posZ;
+ x->forceZ=0;
+
+ SETFLOAT(&(x->pos_new[2]), posZ);
+
+ outlet_anything(x->position3D_new, gensym("position3D"), 3, x->pos_new);
+
+}
+
+void masse3D_setXYZ(t_masse3D *x, t_float posX, t_float posY, t_float posZ)
+{
+
+ x->posX_old_2 = posX;
+ x->posX_old_1 = posX;
+ x->forceX=0;
+
+ x->posY_old_2 = posY;
+ x->posY_old_1 = posY;
+ x->forceY=0;
+
+ x->posZ_old_2 = posZ;
+ x->posZ_old_1 = posZ;
+ x->forceZ=0;
+
+ SETFLOAT(&(x->pos_new[0]), posX);
+ SETFLOAT(&(x->pos_new[1]), posY);
+ SETFLOAT(&(x->pos_new[2]), posZ);
+
+ outlet_anything(x->position3D_new, gensym("position3D"), 3, x->pos_new);
+}
+
+void masse3D_set_masse3D(t_masse3D *x, t_float mass)
+{
+ x->masse3D=mass;
+}
+
+
+void masse3D_force(t_masse3D *x, t_floatarg f1, t_floatarg f2, t_floatarg f3)
+{
+ x->forceX = x->forceX+f1;
+ x->forceY = x->forceY+f2;
+ x->forceZ = x->forceZ+f3;
+}
+
+void masse3D_dXYZ(t_masse3D *x, t_floatarg f1, t_floatarg f2, t_floatarg f3)
+{
+ x->dX += f1;
+ x->dY += f2;
+ x->dZ += f3;
+}
+
+void masse3D_dX(t_masse3D *x, t_floatarg f1 )
+{
+ x->dX += f1;
+}
+
+void masse3D_dY(t_masse3D *x, t_floatarg f1 )
+{
+ x->dY += f1;
+}
+
+void masse3D_dZ(t_masse3D *x, t_floatarg f1 )
+{
+ x->dZ += f1;
+}
+
+void masse3D_bang(t_masse3D *x)
+{
+ t_float posX_new, posY_new, posZ_new, vX=1, vY=1, vZ=1;
+ if (x->onoff != 0)
+ {
+
+ if (x->seuil > 0)
+ {
+ if (x->posZ_old_1 == x->minZ) // si on est en dehors de la structure -> frottement sec sur les bords
+ {
+ if (sqrt(x->forceX*x->forceX + x->forceY*x->forceY)<=(x->seuil * -(x->forceZ)))
+ {
+ vX = 0; // on est a l'interieur du cone de frotement,
+ vY = 0; // on est a l'interieur du cone de frotement,
+ }
+ }
+
+ if (x->posZ_old_1 == x->maxZ) // si on est en dehors de la structure -> frottement sec sur les bords
+ {
+ if (sqrt(x->forceX*x->forceX + x->forceY*x->forceY)<=(x->seuil * (x->forceZ)))
+ {
+ vX = 0; // on est a l'interieur du cone de frotement,
+ vY = 0; // on est a l'interieur du cone de frotement,
+ }
+ }
+
+ if (x->posY_old_1 == x->minY) // si on est en dehors de la structure -> frottement sec sur les bords
+ {
+ if (sqrt(x->forceX*x->forceX + x->forceZ*x->forceZ)<=(x->seuil * -(x->forceY)))
+ {
+ vX = 0; // on est a l'interieur du cone de frotement,
+ vZ = 0; // on est a l'interieur du cone de frotement,
+ }
+ }
+
+ if (x->posY_old_1 == x->maxY) // si on est en dehors de la structure -> frottement sec sur les bords
+ {
+ if (sqrt(x->forceX*x->forceX + x->forceZ*x->forceZ)<=(x->seuil * (x->forceY)))
+ {
+ vX = 0; // on est a l'interieur du cone de frotement,
+ vZ = 0; // on est a l'interieur du cone de frotement,
+ }
+ }
+
+ if (x->posX_old_1 == x->minX) // si on est en dehors de la structure -> frottement sec sur les bords
+ {
+ if (sqrt(x->forceY*x->forceY + x->forceZ*x->forceZ)<=(x->seuil * -(x->forceX)))
+ {
+ vY = 0; // on est a l'interieur du cone de frotement,
+ vZ = 0; // on est a l'interieur du cone de frotement,
+ }
+ }
+
+ if (x->posX_old_1 == x->maxX) // si on est en dehors de la structure -> frottement sec sur les bords
+ {
+ if (sqrt(x->forceY*x->forceY + x->forceZ*x->forceZ)<=(x->seuil * (x->forceX)))
+ {
+ vY = 0; // on est a l'interieur du cone de frotement,
+ vZ = 0; // on est a l'interieur du cone de frotement,
+ }
+ }
+ }
+
+ x->forceX += x->damp * ((x->posX_old_2)-(x->posX_old_1));
+ x->forceY += x->damp * ((x->posY_old_2)-(x->posY_old_1)); // damping
+ x->forceZ += x->damp * ((x->posZ_old_2)-(x->posZ_old_1)); // damping
+
+ if (!(x->masse3D == 0))
+ {
+ posX_new = x->forceX/x->masse3D + 2*x->posX_old_1 - x->posX_old_2;
+ posY_new = x->forceY/x->masse3D + 2*x->posY_old_1 - x->posY_old_2;
+ posZ_new = x->forceZ/x->masse3D + 2*x->posZ_old_1 - x->posZ_old_2;
+ }
+ else
+ {
+ posX_new = x->posX_old_1;
+ posY_new = x->posY_old_1;
+ posZ_new = x->posY_old_1;
+ }
+
+
+ if (vX==0)
+ posX_new = x->posX_old_1; // on n'a pas de mv qd on est a l'interieur du cone de frotement
+ if (vY==0)
+ posY_new = x->posY_old_1;
+ if (vZ==0)
+ posZ_new = x->posZ_old_1;
+
+ posX_new = max(min(x->maxX, posX_new), x->minX);
+ posY_new = max(min(x->maxY, posY_new), x->minY);
+ posZ_new = max(min(x->maxZ, posZ_new), x->minZ);
+
+
+ posX_new += x->dX;
+ posY_new += x->dY;
+ posZ_new += x->dZ;
+
+ x->posX_old_1 += x->dX;
+ x->posY_old_1 += x->dY;
+ x->posZ_old_1 += x->dZ;
+
+ SETFLOAT(&(x->pos_new[0]), posX_new );
+ SETFLOAT(&(x->pos_new[1]), posY_new );
+ SETFLOAT(&(x->pos_new[2]), posZ_new );
+
+ x->posX_old_2 = x->posX_old_1;
+ x->posX_old_1 = posX_new;
+
+ x->posY_old_2 = x->posY_old_1;
+ x->posY_old_1 = posY_new;
+
+ x->posZ_old_2 = x->posZ_old_1;
+ x->posZ_old_1 = posZ_new;
+
+ SETFLOAT(&(x->force[0]), x->forceX );
+ SETFLOAT(&(x->force[1]), x->forceY );
+ SETFLOAT(&(x->force[2]), x->forceZ );
+ SETFLOAT(&(x->force[3]), sqrt( (x->forceX * x->forceX) + (x->forceY * x->forceY) + (x->forceZ * x->forceZ) ));
+
+ x->forceX=0;
+ x->forceY=0;
+ x->forceZ=0;
+
+ x->dX=0;
+ x->dY=0;
+ x->dZ=0;
+
+ x->VX = x->posX_old_1 - x->posX_old_2;
+ x->VY = x->posY_old_1 - x->posY_old_2;
+ x->VZ = x->posZ_old_1 - x->posZ_old_2;
+
+ SETFLOAT(&(x->vitesse[0]), x->VX );
+ SETFLOAT(&(x->vitesse[1]), x->VY );
+ SETFLOAT(&(x->vitesse[2]), x->VZ );
+ SETFLOAT(&(x->vitesse[3]), sqrt( (x->VX * x->VX) + (x->VY * x->VY) + (x->VZ * x->VZ) ));
+
+ outlet_anything(x->vitesse_out, gensym("velocity3D"), 4, x->vitesse);
+ outlet_anything(x->force_out, gensym("force3D"), 4, x->force);
+ outlet_anything(x->position3D_new, gensym("position3D"), 3, x->pos_new);
+ }
+}
+
+void masse3D_reset(t_masse3D *x)
+{
+
+ x->posX_old_2 = x->Xinit;
+ x->posX_old_1 = x->Xinit;
+ x->forceX=0;
+
+ x->posY_old_2 = x->Yinit;
+ x->posY_old_1 = x->Yinit;
+ x->forceY=0;
+
+ x->posZ_old_2 = x->Zinit;
+ x->posZ_old_1 = x->Zinit;
+ x->forceZ=0;
+
+ x->VX = 0;
+ x->VY = 0;
+ x->VZ = 0;
+
+ x->dX=0;
+ x->dY=0;
+ x->dZ=0;
+
+ x->seuil=0;
+
+ x->onoff = 1;
+
+ SETFLOAT(&(x->pos_new[0]), x->Xinit );
+ SETFLOAT(&(x->pos_new[1]), x->Yinit );
+ SETFLOAT(&(x->pos_new[2]), x->Zinit );
+
+ SETFLOAT(&(x->force[0]), 0 );
+ SETFLOAT(&(x->force[1]), 0 );
+ SETFLOAT(&(x->force[2]), 0 );
+ SETFLOAT(&(x->force[3]), 0 );
+
+ SETFLOAT(&(x->vitesse[0]), 0 );
+ SETFLOAT(&(x->vitesse[1]), 0 );
+ SETFLOAT(&(x->vitesse[2]), 0 );
+ SETFLOAT(&(x->vitesse[3]), 0 );
+
+ outlet_anything(x->vitesse_out, gensym("velocity3D"), 4, x->vitesse);
+ outlet_anything(x->force_out, gensym("force3D"), 4, x->force);
+ outlet_anything(x->position3D_new, gensym("position3D"), 3, x->pos_new);
+
+}
+
+
+void masse3D_resetf(t_masse3D *x)
+{
+ x->forceX=0;
+ x->forceY=0;
+ x->forceZ=0;
+
+ x->dX=0;
+ x->dY=0;
+ x->dZ=0;
+}
+
+static int makeseed3D(void)
+{
+ static unsigned int random_nextseed = 1489853723;
+ random_nextseed = random_nextseed * 435898247 + 938284287;
+ return (random_nextseed & 0x7fffffff);
+}
+
+static float random_bang3D(t_masse3D *x)
+{
+ int nval;
+ int range = 2000000;
+ float rnd;
+ unsigned int randval = x->x_state;
+ x->x_state = randval = randval * 472940017 + 832416023;
+ nval = ((double)range) * ((double)randval)
+ * (1./4294967296.);
+ if (nval >= range) nval = range-1;
+
+ rnd=nval;
+
+ rnd-=1000000;
+ rnd=rnd/1000000.; //pour mettre entre -1 et 1;
+ return (rnd);
+}
+
+
+void masse3D_inter_ambient(t_masse3D *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_float tmp;
+
+ if (argc == 17)
+ // 0 : FX
+ // 1 : FY
+ // 2 : FZ
+ // 3 : RndX
+ // 4 : RndY
+ // 5 : RndZ
+ // 6 : D2
+ // 7 : rien
+ // 8 : Xmin
+ // 9 : Xmax
+ // 10 : Ymin
+ // 11 : Ymax
+ // 12 : Zmin
+ // 13 : Zmax
+ // 14 : dX
+ // 15 : dY
+ // 16 : dZ
+ {
+ if (x->posX_old_1 > atom_getfloatarg(8, argc, argv))
+ {
+ if (x->posX_old_1 < atom_getfloatarg(9, argc, argv))
+ {
+ if (x->posY_old_1 > atom_getfloatarg(10, argc, argv))
+ {
+ if (x->posY_old_1 < atom_getfloatarg(11, argc, argv))
+ {
+ if (x->posZ_old_1 > atom_getfloatarg(12, argc, argv))
+ {
+ if (x->posZ_old_1 < atom_getfloatarg(13, argc, argv))
+ {
+ x->forceX += atom_getfloatarg(0, argc, argv);
+ x->forceY += atom_getfloatarg(1, argc, argv); // constant
+ x->forceZ += atom_getfloatarg(2, argc, argv); // constant
+
+ x->forceX += random_bang3D(x)*atom_getfloatarg(3, argc, argv);
+ x->forceY += random_bang3D(x)*atom_getfloatarg(4, argc, argv); // random
+ x->forceZ += random_bang3D(x)*atom_getfloatarg(5, argc, argv); // random
+
+ tmp = atom_getfloatarg(6, argc, argv);
+ if (tmp != 0)
+ {
+ x->forceX += tmp * ((x->posX_old_2)-(x->posX_old_1));
+ x->forceY += tmp * ((x->posY_old_2)-(x->posY_old_1)); // damping
+ x->forceZ += tmp * ((x->posZ_old_2)-(x->posZ_old_1)); // damping
+ }
+
+ x->dX += atom_getfloatarg(14, argc, argv);
+ x->dY += atom_getfloatarg(15, argc, argv); // constant
+ x->dZ += atom_getfloatarg(16, argc, argv); // constant
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ error("bad ambient interraction message");
+ }
+}
+
+void masse3D_inter_plane(t_masse3D *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_float a, b, c, d, profondeur, distance, tmp, profondeur_old;
+
+ if (argc == 12)
+ // 0 : Xvector
+ // 1 : Yvector
+ // 2 : Zvector
+ // 3 : Xcenter
+ // 4 : Ycenter
+ // 5 : Zcenter
+ // 6 : FNCt
+ // 7 : KN
+ // 8 : damping de liaison (profondeur)
+ // 9 : Profondeur maximum
+ // 10 : deplacement normal X
+ // 11 : deplacement proportionel a P
+
+ {
+
+// ax+by+cz-d=0
+// a = Xvector / |V|
+// b = Yvector ...
+// d est tel que aXcenter +bYcenter + cYcenter = d
+
+ a = atom_getfloatarg(0, argc, argv);
+ b = atom_getfloatarg(1, argc, argv);
+ c = atom_getfloatarg(2, argc, argv);
+
+ tmp = sqrt (a*a + b*b + c*c);
+ if (tmp != 0)
+ {
+ a /= tmp;
+ b /= tmp;
+ c /= tmp;
+
+ }
+ else
+ {
+ a=1;
+ b=0;
+ c=0;
+ }
+
+ d = a * atom_getfloatarg(3, argc, argv) + b * atom_getfloatarg(4, argc, argv) + c * atom_getfloatarg(5, argc, argv);
+//C a optimiser : envoyer directement les coef directeur et l'offset
+//C a faire pour les autres obj aussi
+
+ profondeur = a * x->posX_old_1 + b * x->posY_old_1 + c * x->posZ_old_1 - d;
+
+ if ( (profondeur < 0) & (profondeur > -atom_getfloatarg(9, argc, argv)) )
+ {
+
+ tmp = atom_getfloatarg(6, argc, argv); // force normal constante
+
+ x->forceX += tmp * a;
+ x->forceY += tmp * b;
+ x->forceZ += tmp * c;
+
+ tmp = atom_getfloatarg(7, argc, argv); // force normal proportionelle a la profondeur
+ tmp *= profondeur;
+ x->forceX -= tmp * a;
+ x->forceY -= tmp * b;
+ x->forceZ -= tmp * c;
+
+ tmp = atom_getfloatarg(8, argc, argv); // force normal proportionelle a la profondeur
+
+ profondeur_old = a * x->posX_old_2 + b * x->posY_old_2 + c * x->posZ_old_2 - d;
+ tmp *= (profondeur - profondeur_old);
+ x->forceX -= tmp * a;
+ x->forceY -= tmp * b;
+ x->forceZ -= tmp * c;
+
+
+ tmp = atom_getfloatarg(10, argc, argv); // deplacement normal constant
+
+ x->dX += tmp * a;
+ x->dY += tmp * b;
+ x->dZ += tmp * c;
+
+ tmp = atom_getfloatarg(11, argc, argv); // deplacement normal proportionel
+ tmp *= profondeur;
+
+ x->dX -= tmp * a;
+ x->dY -= tmp * b;
+ x->dZ -= tmp * c;
+ }
+
+ }
+ else
+ {
+ error("bad plane interraction message");
+ }
+}
+
+
+void masse3D_inter_sphere(t_masse3D *x, t_symbol *s, int argc, t_atom *argv)
+{
+t_float posx1, posy1, posz1, Nx, Ny, Nz, dx, dy, dz, distance, Dmax, tmp;
+t_float deltaX_old, deltaY_old, deltaZ_old, distance_old ;
+
+ if (argc == 17)
+ // 0 : Xcentre
+ // 1 : Ycendre
+ // 2 : Zcentre
+ // 3 : Rmin
+ // 4 : Rmax
+ // 5 : F normal
+ // 6 : K normal
+ // 7 : F normal proportionel a 1/R
+ // 8 : Damp de liason normal
+ // 9 : deplacement N Ct
+ // 10 : position ancienne de l'interacteur en X
+ // 11 : position abcienne de l'interacteur en Y
+ // 12 : position abcienne de l'interacteur en Z
+ // 13 : d dormal proportionel a R
+ // 14 : force normal proportionel a 1/R2
+ // 15 : d dormal proportionel a 1/R
+ // 16 : d dormal proportionel a 1/R*R
+
+ {
+ posx1 = atom_getfloatarg(0, argc, argv);
+ posy1 = atom_getfloatarg(1, argc, argv);
+ posz1 = atom_getfloatarg(2, argc, argv);
+ Nx = (x->posX_old_1)-posx1; // vecteur deplacement X
+ Ny = (x->posY_old_1)-posy1; // vecteur deplacement Y
+ Nz = (x->posZ_old_1)-posz1; // vecteur deplacement Y
+
+ distance = sqrt((Nx * Nx)+(Ny * Ny)+(Nz * Nz)); // distance entre le centre de l'interaction, et le pts
+
+ Nx = Nx/distance; // composante X de la normal (normalisé)
+ Ny = Ny/distance; // composante Y de la normal.
+ Nz = Nz/distance; // composante Y de la normal.
+
+ Dmax= atom_getfloatarg(4, argc, argv); // distance max de l'interaction
+ if ( (distance > atom_getfloatarg(3, argc, argv)) & (distance < Dmax) )
+ {
+ tmp = atom_getfloatarg(5, argc, argv); // force constante normal
+ x->forceX += tmp * Nx;
+ x->forceY += tmp * Ny;
+ x->forceZ += tmp * Nz;
+
+ tmp = atom_getfloatarg(6, argc, argv); // force variable (K) normal
+ tmp *= ( Dmax-distance );
+ x->forceX += tmp * Nx ;
+ x->forceY += tmp * Ny ;
+ x->forceZ += tmp * Nz ;
+
+ tmp = atom_getfloatarg(7, argc, argv); // force normal proportionel a 1/r
+ if ( (distance != 0) & (tmp != 0) )
+ {
+ tmp /= distance;
+ x->forceX += tmp * Nx;
+ x->forceY += tmp * Ny;
+ x->forceZ += tmp * Nz ;
+ }
+
+ tmp = atom_getfloatarg(8, argc, argv); // damping2 normal
+ tmp *= ( x->VX * Nx + x->VY * Ny + x->VZ * Nz );
+ x->forceX -= tmp * Nx ;
+ x->forceY -= tmp * Ny ;
+ x->forceZ -= tmp * Nz ;
+
+ tmp = atom_getfloatarg(9, argc, argv); // d normal
+ x->dX += tmp * Nx ;
+ x->dY += tmp * Ny ;
+ x->dZ += tmp * Nz ;
+
+ tmp = atom_getfloatarg(13, argc, argv); // force normal proportionel a 1/r2
+ if ( (distance != 0) & (tmp != 0) )
+ {
+ tmp /= (distance * distance);
+ x->forceX += tmp * Nx ;
+ x->forceY += tmp * Ny ;
+ x->forceZ += tmp * Nz ;
+ }
+
+ tmp = atom_getfloatarg(14, argc, argv); // deplacement variable (K) normal
+ tmp *= ( Dmax-distance );
+ x->dX += tmp * Nx ;
+ x->dY += tmp * Ny ;
+ x->dZ += tmp * Nz ;
+
+ tmp = atom_getfloatarg(15, argc, argv); // deplacement normal proportionel a 1/r
+ if ( (distance != 0) & (tmp != 0) )
+ {
+ tmp /= distance;
+ x->dX += tmp * Nx ;
+ x->dY += tmp * Ny ;
+ x->dZ += tmp * Nz ;
+ }
+
+ tmp = atom_getfloatarg(16, argc, argv); // deplacement normal proportionel a 1/r2
+ if ( (distance != 0) & (tmp != 0) )
+ {
+ tmp /= (distance * distance);
+ x->dX += tmp * Nx;
+ x->dY += tmp * Ny;
+ x->dZ += tmp * Nz;
+ }
+
+ }
+ }
+ else
+ {
+ error("bad interact_3D_sphere message");
+ }
+}
+
+
+void masse3D_inter_circle(t_masse3D *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_float a, b, c, d, profondeur, distance, tmp, profondeur_old, rayon, rayon_old;
+
+ if (argc == 14)
+ // 0 : Xvector
+ // 1 : Yvector
+ // 2 : Zvector
+ // 3 : Xcenter
+ // 4 : Ycenter
+ // 5 : Zcenter
+ // 6 : Rmin
+ // 7 : RMax
+ // 8 : FNCt
+ // 9 : KN
+ // 10 : damping de liaison (profondeur)
+ // 11 : Profondeur maximum
+ // 12 : dN
+ // 13 : dKN
+
+ {
+// ax+by+cz-d=0
+// a = Xvector / |V|
+// b = Yvector ...
+// d est tel que aXcenter +bYcenter + cYcenter = d
+
+ a = atom_getfloatarg(0, argc, argv);
+ b = atom_getfloatarg(1, argc, argv);
+ c = atom_getfloatarg(2, argc, argv);
+
+ tmp = sqrt (a*a + b*b + c*c);
+ if (tmp != 0)
+ {
+ a /= tmp;
+ b /= tmp;
+ c /= tmp;
+ }
+ else
+ {
+ a=1;
+ b=0;
+ c=0;
+ }
+
+ d = a * atom_getfloatarg(3, argc, argv) + b * atom_getfloatarg(4, argc, argv) + c * atom_getfloatarg(5, argc, argv);
+
+ profondeur = a * x->posX_old_1 + b * x->posY_old_1 + c * x->posZ_old_1 - d;
+
+ rayon = sqrt ( pow(x->posX_old_1-atom_getfloatarg(3, argc, argv), 2) +pow(x->posY_old_1-atom_getfloatarg(4, argc, argv) , 2) + pow(x->posZ_old_1 - atom_getfloatarg(5, argc, argv) , 2) - profondeur*profondeur );
+
+ if ( (profondeur < 0) & (profondeur > - atom_getfloatarg(11, argc, argv)) & (rayon > atom_getfloatarg(6, argc, argv)) & (rayon < atom_getfloatarg(7, argc, argv)))
+ {
+
+ tmp = atom_getfloatarg(8, argc, argv); // force normal constante
+
+ x->forceX += tmp * a;
+ x->forceY += tmp * b;
+ x->forceZ += tmp * c;
+
+ tmp = atom_getfloatarg(9, argc, argv); // force normal proportionelle a la profondeur
+ tmp *= profondeur;
+ x->forceX -= tmp * a;
+ x->forceY -= tmp * b;
+ x->forceZ -= tmp * c;
+
+ tmp = atom_getfloatarg(10, argc, argv); // force normal proportionelle a la profondeur
+
+ profondeur_old = a * x->posX_old_2 + b * x->posY_old_2 + c * x->posZ_old_2 - d;
+ tmp *= (profondeur - profondeur_old);
+
+ x->forceX -= tmp * a;
+ x->forceY -= tmp * b;
+ x->forceZ -= tmp * c;
+
+ tmp = atom_getfloatarg(12, argc, argv); // deplacement normal constante
+ x->dX += tmp * a;
+ x->dY += tmp * b;
+ x->dZ += tmp * c;
+
+ tmp = atom_getfloatarg(13, argc, argv); // deplacement normal proportionelle a la profondeur
+ tmp *= profondeur;
+ x->dX -= tmp * a;
+ x->dY -= tmp * b;
+ x->dZ -= tmp * c;
+ }
+ }
+ else
+ {
+ error("bad circle interraction message");
+ }
+}
+
+
+void masse3D_inter_cylinder(t_masse3D *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_float a, b, c, d, profondeur, profondeur_old, distance, tmp, rayon_old, rayon;
+ t_float Xb, Yb, Zb, Ta, Tb, Tc, Xb_old, Yb_old, Zb_old;
+
+ if (argc == 21)
+ // 0 : Xvector
+ // 1 : Yvector
+ // 2 : Zvector
+ // 3 : Xcenter
+ // 4 : Ycenter
+ // 5 : Zcenter
+ // 6 : Rmin
+ // 7 : Rmax
+ // 8 : FNCt
+ // 9 : KN
+ // 10 : damping de liaison (rayon)
+ // 11 : FN 1/R
+ // 12 : FN 1/R2
+ // 13 : Pmin
+ // 14 : Pmax
+ // 15 : FTct
+ // 16 : KT
+ // 17 : dNct
+ // 18 : dTct
+ // 19 : dKN
+ // 20 : dKT
+
+ {
+
+// ax+by+cz-d=0
+// a = Xvector / |V|
+// b = Yvector ...
+// d est tel que aXcenter +bYcenter + cYcenter = d
+
+ a = atom_getfloatarg(0, argc, argv);
+ b = atom_getfloatarg(1, argc, argv);
+ c = atom_getfloatarg(2, argc, argv);
+
+ tmp = sqrt (a*a + b*b + c*c);
+ if (tmp != 0)
+ {
+ a /= tmp;
+ b /= tmp;
+ c /= tmp;
+ }
+ else
+ {
+ a=1;
+ b=0;
+ c=0;
+ }
+
+ d = a * atom_getfloatarg(3, argc, argv) + b * atom_getfloatarg(4, argc, argv) + c * atom_getfloatarg(5, argc, argv);
+
+ profondeur = a * x->posX_old_1 + b * x->posY_old_1 + c * x->posZ_old_1 - d;
+
+ Xb = x->posX_old_1 - atom_getfloatarg(3, argc, argv) - profondeur * a;
+ Yb = x->posY_old_1 - atom_getfloatarg(4, argc, argv) - profondeur * b;
+ Zb = x->posZ_old_1 - atom_getfloatarg(5, argc, argv) - profondeur * c;
+
+ rayon = sqrt ( pow(Xb, 2) + pow(Yb, 2) + pow(Zb, 2) );
+
+ if (rayon != 0)
+ {
+ Xb /= rayon; // normalisation
+ Yb /= rayon;
+ Zb /= rayon;
+ }
+ else
+ {
+ Xb = 0; // normalisation
+ Yb = 0;
+ Zb = 0;
+ }
+
+
+ Ta = b*Zb - c*Yb; // vecteur tengentiel = vecteur vectoriel rayon
+ Tb = c*Xb - a*Zb;
+ Tc = a*Yb - b*Xb;
+
+ if ( (profondeur < atom_getfloatarg(14, argc, argv)) & (profondeur > atom_getfloatarg(13, argc, argv)) & (rayon < atom_getfloatarg(7, argc, argv)) & (rayon > atom_getfloatarg(6, argc, argv)) )
+ {
+
+ tmp = atom_getfloatarg(8, argc, argv); // force normal constante
+
+ x->forceX += tmp * Xb;
+ x->forceY += tmp * Yb;
+ x->forceZ += tmp * Zb;
+
+ tmp = atom_getfloatarg(9, argc, argv); // rigidité normal proportionelle
+ tmp *= ( atom_getfloatarg(7, argc, argv) - rayon ) ;
+ x->forceX += tmp * Xb;
+ x->forceY += tmp * Yb;
+ x->forceZ += tmp * Zb;
+
+ tmp = atom_getfloatarg(10, argc, argv); // damping normal proportionelle a la profondeur
+
+ profondeur_old = a * x->posX_old_2 + b * x->posY_old_2 + c * x->posZ_old_2 - d;
+
+ Xb_old = x->posX_old_2 - atom_getfloatarg(3, argc, argv) - profondeur_old * a;
+ Yb_old = x->posY_old_2 - atom_getfloatarg(4, argc, argv) - profondeur_old * b;
+ Zb_old = x->posZ_old_2 - atom_getfloatarg(5, argc, argv) - profondeur_old * c;
+
+ rayon_old = sqrt ( pow(Xb_old, 2) + pow(Yb_old, 2) + pow(Zb_old, 2) );
+
+ tmp *= (rayon - rayon_old);
+
+ x->forceX -= tmp * Xb;
+ x->forceY -= tmp * Yb;
+ x->forceZ -= tmp * Zb;
+
+ tmp = atom_getfloatarg(11, argc, argv); // force normal proportionne a 1/R
+ if (rayon != 0)
+ {
+ tmp /= rayon;
+ x->forceX += tmp * Xb;
+ x->forceY += tmp * Yb;
+ x->forceZ += tmp * Zb;
+ }
+
+ tmp = atom_getfloatarg(12, argc, argv); // force normal proportionne a 1/R*R
+ if (rayon != 0)
+ {
+ tmp /= (rayon*rayon);
+ x->forceX += tmp * Xb;
+ x->forceY += tmp * Yb;
+ x->forceZ += tmp * Zb;
+ }
+
+ tmp = atom_getfloatarg(15, argc, argv); // force tengente constante
+ x->forceX -= tmp * Ta;
+ x->forceY -= tmp * Tb;
+ x->forceZ -= tmp * Tc;
+
+ tmp = atom_getfloatarg(16, argc, argv); // rigidité tengentiel proportionelle
+ tmp *= ( atom_getfloatarg(7, argc, argv) - rayon ) ;
+ x->forceX += tmp * Ta;
+ x->forceY += tmp * Tb;
+ x->forceZ += tmp * Tc;
+
+ tmp = atom_getfloatarg(17, argc, argv); // deplacement normal constante
+
+ x->dX += tmp * Xb;
+ x->dY += tmp * Yb;
+ x->dZ += tmp * Zb;
+
+ tmp = atom_getfloatarg(19, argc, argv); // deplacement normal proportionelle
+ tmp *= ( atom_getfloatarg(7, argc, argv) - rayon ) ;
+ x->dX += tmp * Xb;
+ x->dY += tmp * Yb;
+ x->dZ += tmp * Zb;
+
+ tmp = atom_getfloatarg(18, argc, argv); // deplacement tengente constante
+ x->dX += tmp * Ta;
+ x->dY += tmp * Tb;
+ x->dZ += tmp * Tc;
+
+ tmp = atom_getfloatarg(20, argc, argv); // deplacement tengentiel proportionelle
+ tmp *= ( atom_getfloatarg(7, argc, argv) - rayon ) ;
+ x->dX += tmp * Ta;
+ x->dY += tmp * Tb;
+ x->dZ += tmp * Tc;
+ }
+ }
+ else
+ {
+ error("bad cylinder interraction message");
+ }
+}
+
+void *masse3D_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_masse3D *x = (t_masse3D *)pd_new(masse3D_class);
+
+ x->x_sym = atom_getsymbolarg(0, argc, argv);
+ x->x_state = makeseed();
+
+ pd_bind(&x->x_obj.ob_pd, atom_getsymbolarg(0, argc, argv));
+
+ x->position3D_new=outlet_new(&x->x_obj, 0);
+ x->force_out=outlet_new(&x->x_obj, 0);
+ x->vitesse_out=outlet_new(&x->x_obj, 0);
+
+ x->forceX=0;
+ x->forceY=0;
+ x->forceZ=0;
+
+ if (argc >= 2)
+ x->masse3D = atom_getfloatarg(1, argc, argv) ;
+ else
+ x->masse3D = 1;
+
+ x->onoff = 1;
+
+ x->VX = 0;
+ x->VY = 0;
+ x->VZ = 0;
+
+ x->dX=0;
+ x->dY=0;
+ x->dZ=0;
+
+ if (argc >= 3)
+ x->Xinit = atom_getfloatarg(2, argc, argv);
+ else
+ x->Xinit = 0 ;
+
+ x->posX_old_1 = x->Xinit ;
+ x->posX_old_2 = x->Xinit;
+ SETFLOAT(&(x->pos_new[0]), x->Xinit);
+
+ if (argc >= 4)
+ x->Yinit = atom_getfloatarg(3, argc, argv);
+ else
+ x->Yinit = 0 ;
+
+ x->posY_old_1 = x->Yinit ;
+ x->posY_old_2 = x->Yinit;
+ SETFLOAT(&(x->pos_new[1]), x->Yinit);
+
+ if (argc >= 5)
+ x->Zinit = atom_getfloatarg(4, argc, argv);
+ else
+ x->Zinit = 0 ;
+
+ x->posZ_old_1 = x->Zinit ;
+ x->posZ_old_2 = x->Zinit;
+ SETFLOAT(&(x->pos_new[2]), x->Zinit);
+
+
+ if (argc >= 6)
+ x->minX = atom_getfloatarg(5, argc, argv) ;
+ else
+ x->minX = -100000;
+
+ if (argc >= 7)
+ x->maxX = atom_getfloatarg(6, argc, argv) ;
+ else
+ x->maxX = 100000;
+
+ if (argc >= 8)
+ x->minY = atom_getfloatarg(7, argc, argv) ;
+ else
+ x->minY = -100000;
+
+ if (argc >= 9)
+ x->maxY = atom_getfloatarg(8, argc, argv) ;
+ else
+ x->maxY = 100000;
+
+ if (argc >= 10)
+ x->minZ = atom_getfloatarg(9, argc, argv) ;
+ else
+ x->minZ = -100000;
+
+ if (argc >= 11)
+ x->maxZ = atom_getfloatarg(10, argc, argv) ;
+ else
+ x->maxZ = 100000;
+
+ if (argc >= 12)
+ x->seuil = atom_getfloatarg(11, argc, argv) ;
+ else
+ x->seuil = 0;
+
+ if (argc >= 13)
+ x->damp = atom_getfloatarg(12, argc, argv) ;
+ else
+ x->damp = 0;
+
+ return (void *)x;
+}
+
+static void masse3D_free(t_masse3D *x)
+{
+ pd_unbind(&x->x_obj.ob_pd, x->x_sym);
+}
+
+
+void masse3D_setup(void)
+{
+
+ masse3D_class = class_new(gensym("masse3D"),
+ (t_newmethod)masse3D_new,
+ (t_method)masse3D_free,
+ sizeof(t_masse3D),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addcreator((t_newmethod)masse3D_new, gensym("mass3D"), A_GIMME, 0);
+ class_addcreator((t_newmethod)masse3D_new, gensym("pmpd.mass3D"), A_GIMME, 0);
+
+ class_addmethod(masse3D_class, (t_method)masse3D_force, gensym("force3D"),A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addbang(masse3D_class, masse3D_bang);
+
+ class_addmethod(masse3D_class, (t_method)masse3D_dX, gensym("dX"), A_DEFFLOAT, 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_dY, gensym("dY"), A_DEFFLOAT, 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_dZ, gensym("dZ"), A_DEFFLOAT, 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_dXYZ, gensym("dXYZ"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_setX, gensym("setX"), A_DEFFLOAT, 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_setY, gensym("setY"), A_DEFFLOAT, 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_setZ, gensym("setZ"), A_DEFFLOAT, 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_setXYZ, gensym("setXYZ"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_minX, gensym("setXmin"), A_DEFFLOAT, 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_minY, gensym("setYmin"), A_DEFFLOAT, 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_maxX, gensym("setXmax"), A_DEFFLOAT, 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_maxY, gensym("setYmax"), A_DEFFLOAT, 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_minZ, gensym("setZmin"), A_DEFFLOAT, 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_maxZ, gensym("setZmax"), A_DEFFLOAT, 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_set_masse3D, gensym("setM"), A_DEFFLOAT, 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_reset, gensym("reset"), 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_resetf, gensym("resetF"), 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_reset, gensym("loadbang"), 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_on, gensym("on"), 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_off, gensym("off"), 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_seuil, gensym("setT"), A_DEFFLOAT, 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_damp, gensym("setD"), A_DEFFLOAT, 0);
+
+ class_addmethod(masse3D_class, (t_method)masse3D_inter_ambient, gensym("interactor_ambient_3D"), A_GIMME, 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_inter_sphere, gensym("interactor_sphere_3D"), A_GIMME, 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_inter_plane, gensym("interactor_plane_3D"), A_GIMME, 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_inter_circle, gensym("interactor_circle_3D"), A_GIMME, 0);
+ class_addmethod(masse3D_class, (t_method)masse3D_inter_cylinder, gensym("interactor_cylinder_3D"), A_GIMME, 0);
+
+}
diff --git a/src/pmpd.c b/src/pmpd.c
new file mode 100755
index 0000000..9d21d64
--- /dev/null
+++ b/src/pmpd.c
@@ -0,0 +1,146 @@
+/*
+-------------------------- pmpd ----------------------------------------
+
+ pmpd = physical modeling for pure data
+ Written by Cyrille Henry (cyrille.henry@la-kitchen.fr)
+
+ Get sources at http://drpichon.free.fr/pure-data/physical-modeling/
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Based on PureData by Miller Puckette and others.
+
+
+----------------------------------------------------------------------------
+*/
+
+#ifndef VERSION
+#define VERSION "0.05"
+#endif
+
+#include "m_pd.h"
+
+#ifndef __DATE__
+#define __DATE__ ""
+#endif
+
+#include "masse.c"
+#include "lia.c"
+#include "masse2D.c"
+#include "lia2D.c"
+#include "masse3D.c"
+#include "lia3D.c"
+
+#include "iAmbient2D.c"
+#include "iLine2D.c"
+#include "iSeg2D.c"
+#include "iCircle2D.c"
+
+#include "tSquare2D.c"
+#include "tLine2D.c"
+#include "tSeg2D.c"
+#include "tCircle2D.c"
+#include "tLia2D.c"
+
+#include "iAmbient3D.c"
+#include "iSphere3D.c"
+#include "iPlane3D.c"
+#include "iCircle3D.c"
+#include "iCylinder3D.c"
+
+
+#include "tCube3D.c"
+#include "tSphere3D.c"
+#include "tPlane3D.c"
+#include "tCircle3D.c"
+#include "tCylinder3D.c"
+#include "tLia3D.c"
+
+static t_class *pmpd_class;
+
+typedef struct _pmpd
+{
+ t_object x_obj;
+} t_pmpd;
+
+t_float max(t_float x, t_float y)
+{
+ if (x >= y)
+ {
+ return x;
+ }
+ return y;
+}
+
+t_float min(t_float x, t_float y)
+{
+ if (x <= y)
+ {
+ return x;
+ }
+ return y;
+}
+
+void *pmpd_new(void)
+{
+ t_pmpd *x = (t_pmpd *)pd_new(pmpd_class);
+ return (void *)x;
+}
+
+void pmpd_setup(void)
+{
+ pmpd_class = class_new(gensym("pmpd"),
+ (t_newmethod)pmpd_new,
+ 0, sizeof(t_pmpd),0,0);
+
+ post("");
+ post(" pmpd = Physical Modeling for Pure Data");
+ post(" version "VERSION);
+ post(" compiled "__DATE__);
+ post(" Contact : cyrille.henry@la-kitchen.fr");
+ post("");
+
+masse_setup() ;
+lia_setup() ;
+masse2D_setup() ;
+lia2D_setup() ;
+masse3D_setup() ;
+lia3D_setup() ;
+
+iAmbient2D_setup();
+iLine2D_setup();
+iSeg2D_setup();
+iCircle2D_setup();
+
+tSquare2D_setup();
+tCircle2D_setup();
+tLine2D_setup();
+tSeg2D_setup();
+tLia2D_setup();
+
+iAmbient3D_setup();
+iSphere3D_setup();
+iPlane3D_setup();
+iCircle3D_setup();
+iCylinder3D_setup();
+
+tLia3D_setup();
+tCube3D_setup();
+tPlane3D_setup();
+tSphere3D_setup();
+tCylinder3D_setup();
+tCircle3D_setup();
+
+}
diff --git a/src/tCircle2D.c b/src/tCircle2D.c
new file mode 100755
index 0000000..e4ba448
--- /dev/null
+++ b/src/tCircle2D.c
@@ -0,0 +1,113 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *tCircle2D_class;
+
+typedef struct _tCircle2D {
+ t_object x_obj;
+ t_float X, Y, Rmin, Rmax, distance_old;
+ t_outlet *force_new, *distance, *vitesse; // outlet
+} t_tCircle2D;
+
+
+void tCircle2D_position2D(t_tCircle2D *x, t_float X, t_float Y)
+{
+
+ t_float tmp, vitesse;
+
+ tmp = sqrt((X-x->X)*(X-x->X) + (Y-x->Y)*(Y-x->Y));
+
+ vitesse = tmp - x->distance_old ;
+
+ x->distance_old = tmp;
+
+ outlet_float(x->vitesse, vitesse);
+
+ outlet_float(x->distance, tmp);
+
+ if ( (tmp < x->Rmax) & (tmp >= x->Rmin))
+ {
+ outlet_float(x->force_new, 1);
+ }
+ else
+ {
+ outlet_float(x->force_new, 0);
+ }
+}
+
+void tCircle2D_XY(t_tCircle2D *x, t_float X, t_float Y)
+{
+ x->X= X;
+ x->Y= Y;
+}
+
+void tCircle2D_X(t_tCircle2D *x, t_float X)
+{
+ x->X= X;
+}
+
+void tCircle2D_Y(t_tCircle2D *x, t_float X)
+{
+ x->Y= X;
+}
+
+void tCircle2D_Rmin(t_tCircle2D *x, t_float X)
+{
+ x->Rmin= X;
+}
+
+void tCircle2D_Rmax(t_tCircle2D *x, t_float X)
+{
+ x->Rmax= X;
+}
+
+void *tCircle2D_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_tCircle2D *x = (t_tCircle2D *)pd_new(tCircle2D_class);
+ x->force_new=outlet_new(&x->x_obj, 0);
+ x->distance=outlet_new(&x->x_obj, 0);
+ x->vitesse=outlet_new(&x->x_obj, 0);
+
+ x->distance_old = 0;
+
+ if (argc>=4)
+ x->Rmax = atom_getfloatarg(3, argc, argv);
+ else
+ x->Rmax = 1;
+
+ if (argc>=3)
+ x->Rmin = atom_getfloatarg(2, argc, argv);
+ else
+ x->Rmin = 0;
+
+ if (argc>=2)
+ x->Y = atom_getfloatarg(1, argc, argv);
+ else
+ x->Y = 0;
+
+ if (argc>=1)
+ x->X = atom_getfloatarg(0, argc, argv);
+ else
+ x->X = 0;
+
+ return (x);
+}
+
+void tCircle2D_setup(void)
+{
+
+ tCircle2D_class = class_new(gensym("tCircle2D"),
+ (t_newmethod)tCircle2D_new,
+ 0, sizeof(t_tCircle2D),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addcreator((t_newmethod)tCircle2D_new, gensym("pmpd.tCircle2D"), A_GIMME, 0);
+
+ class_addmethod(tCircle2D_class, (t_method)tCircle2D_position2D, gensym("position2D"), A_DEFFLOAT, A_DEFFLOAT, 0);
+
+ class_addmethod(tCircle2D_class, (t_method)tCircle2D_XY, gensym("setXY"), A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(tCircle2D_class, (t_method)tCircle2D_X, gensym("setX"), A_DEFFLOAT, 0);
+ class_addmethod(tCircle2D_class, (t_method)tCircle2D_Y, gensym("setY"), A_DEFFLOAT, 0);
+ class_addmethod(tCircle2D_class, (t_method)tCircle2D_Rmin, gensym("setRmin"), A_DEFFLOAT, 0);
+ class_addmethod(tCircle2D_class, (t_method)tCircle2D_Rmax, gensym("setRmax"), A_DEFFLOAT, 0);
+}
diff --git a/src/tCircle3D.c b/src/tCircle3D.c
new file mode 100755
index 0000000..6664d39
--- /dev/null
+++ b/src/tCircle3D.c
@@ -0,0 +1,195 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *tCircle3D_class;
+
+typedef struct _tCircle3D {
+ t_object x_obj;
+ t_float X, Y, Z, VX, VY, VZ, P, Rmin, Rmax, distance_old;
+ t_outlet *force_new, *distance, *vitesse;// outlet
+} t_tCircle3D;
+
+void tCircle3D_position3D(t_tCircle3D *x, t_float X, t_float Y, t_float Z)
+{
+t_float d, tmp, profondeur, vitesse;
+
+
+
+ tmp = sqrt (x->VX*x->VX + x->VY*x->VY + x->VZ*x->VZ);
+ if (tmp != 0)
+ {
+ x->VX /= tmp;
+ x->VY /= tmp;
+ x->VZ /= tmp;
+ }
+ else
+ {
+ x->VX=1;
+ x->VY=0;
+ x->VZ=0;
+ }
+
+ d = x->VX * x->X + x->VY * x->Y + x->VZ * x->Z;
+
+ profondeur = x->VX * X + x->VY * Y + x->VZ * Z - d;
+
+ vitesse = profondeur - x->distance_old;
+ x->distance_old = profondeur;
+
+ outlet_float(x->vitesse, vitesse);
+
+ outlet_float(x->distance, profondeur);
+
+ if ( (profondeur < 0) & (profondeur > - x->P) )
+ {
+ outlet_float(x->force_new, 1);
+ }
+ else
+ {
+ outlet_float(x->force_new, 0);
+ }
+
+}
+
+void tCircle3D_setXYZ(t_tCircle3D *x, t_float X, t_float Y, t_float Z)
+{
+ x->X= X;
+ x->Y= Y;
+ x->Z= Z;
+}
+void tCircle3D_setVXYZ(t_tCircle3D *x, t_float X, t_float Y, t_float Z)
+{
+ x->VX= X;
+ x->VY= Y;
+ x->VZ= Z;
+}
+
+void tCircle3D_setVX(t_tCircle3D *x, t_float X)
+{
+ x->VX= X;
+}
+
+void tCircle3D_setVY(t_tCircle3D *x, t_float Y)
+{
+ x->VY= Y;
+}
+
+void tCircle3D_setVZ(t_tCircle3D *x, t_float Z)
+{
+ x->VZ= Z;
+}
+void tCircle3D_setX(t_tCircle3D *x, t_float X)
+{
+ x->X= X;
+}
+
+void tCircle3D_setY(t_tCircle3D *x, t_float Y)
+{
+ x->Y= Y;
+}
+
+void tCircle3D_setZ(t_tCircle3D *x, t_float Z)
+{
+ x->Z= Z;
+}
+
+void tCircle3D_setP(t_tCircle3D *x, t_float X)
+{
+ x->P= X;
+}
+
+void tCircle3D_setRmin(t_tCircle3D *x, t_float R)
+{
+ x->Rmin = R;
+}
+
+void tCircle3D_setRmax(t_tCircle3D *x, t_float R)
+{
+ x->Rmax = R;
+}
+
+
+void *tCircle3D_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_tCircle3D *x = (t_tCircle3D *)pd_new(tCircle3D_class);
+
+ x->force_new=outlet_new(&x->x_obj, 0);
+ x->distance=outlet_new(&x->x_obj, 0);
+ x->vitesse=outlet_new(&x->x_obj, 0);
+
+ x->distance_old = 0;
+
+ if (argc>=9)
+ x->P= atom_getfloatarg(8, argc, argv);
+ else
+ x->P= 10000;
+
+ if (argc>=8)
+ x->Z= atom_getfloatarg(7, argc, argv);
+ else
+ x->Rmax= 1;
+
+ if (argc>=7)
+ x->P= atom_getfloatarg(6, argc, argv);
+ else
+ x->Rmin= 0;
+
+ if (argc>=6)
+ x->Z= atom_getfloatarg(5, argc, argv);
+ else
+ x->Z= 0;
+
+ if (argc>=5)
+ x->Y= atom_getfloatarg(4, argc, argv);
+ else
+ x->Y= 0;
+
+ if (argc>=4)
+ x->X= atom_getfloatarg(3, argc, argv);
+ else
+ x->X= 0;
+
+ if (argc>=3)
+ x->VZ= atom_getfloatarg(2, argc, argv);
+ else
+ x->VZ= 0;
+
+ if (argc>=2)
+ x->VY= atom_getfloatarg(1, argc, argv);
+ else
+ x->VY= 0;
+
+ if (argc>=1)
+ x->VX= atom_getfloatarg(0, argc, argv);
+ else
+ x->VX= 1;
+
+ return (x);
+}
+
+void tCircle3D_setup(void)
+{
+
+ tCircle3D_class = class_new(gensym("tCircle3D"),
+ (t_newmethod)tCircle3D_new,
+ 0, sizeof(t_tCircle3D),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addcreator((t_newmethod)tCircle3D_new, gensym("pmpd.tCircle3D"), A_GIMME, 0);
+
+ class_addmethod(tCircle3D_class, (t_method)tCircle3D_position3D, gensym("position3D"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+
+ class_addmethod(tCircle3D_class, (t_method)tCircle3D_setVX, gensym("setVX"), A_DEFFLOAT, 0);
+ class_addmethod(tCircle3D_class, (t_method)tCircle3D_setVY, gensym("setVY"), A_DEFFLOAT, 0);
+ class_addmethod(tCircle3D_class, (t_method)tCircle3D_setVZ, gensym("setVZ"), A_DEFFLOAT, 0);
+ class_addmethod(tCircle3D_class, (t_method)tCircle3D_setX, gensym("setX"), A_DEFFLOAT, 0);
+ class_addmethod(tCircle3D_class, (t_method)tCircle3D_setY, gensym("setY"), A_DEFFLOAT, 0);
+ class_addmethod(tCircle3D_class, (t_method)tCircle3D_setZ, gensym("setZ"), A_DEFFLOAT, 0);
+ class_addmethod(tCircle3D_class, (t_method)tCircle3D_setRmin, gensym("setRmin"), A_DEFFLOAT, 0);
+ class_addmethod(tCircle3D_class, (t_method)tCircle3D_setRmax, gensym("setRmax"), A_DEFFLOAT, 0);
+ class_addmethod(tCircle3D_class, (t_method)tCircle3D_setXYZ, gensym("setXYZ"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(tCircle3D_class, (t_method)tCircle3D_setVXYZ, gensym("setVXYZ"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(tCircle3D_class, (t_method)tCircle3D_setP, gensym("setPmax"), A_DEFFLOAT, 0);
+
+
+}
diff --git a/src/tCube3D.c b/src/tCube3D.c
new file mode 100755
index 0000000..ce0c434
--- /dev/null
+++ b/src/tCube3D.c
@@ -0,0 +1,114 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *tCube3D_class;
+
+typedef struct _tCube3D {
+ t_object x_obj;
+ t_float Xmin, Xmax, Ymin, Ymax, Zmin, Zmax;
+ //extrem = Xmin, Ymin, Xmax, Ymax;
+ t_outlet *force_new;// outlet
+} t_tCube3D;
+
+void tCube3D_position3D(t_tCube3D *x, t_float X, t_float Y, t_float Z)
+{
+
+ if ((X > x->Xmin) & (X < x->Xmax) & (Y > x->Ymin) & (Y < x->Ymax) & (Z > x->Zmin) & (Z < x->Zmax) )
+ {
+ outlet_float(x->force_new, 1);
+ }
+ else
+ {
+ outlet_float(x->force_new, 0);
+ }
+}
+
+void tCube3D_Xmin(t_tCube3D *x, t_float X)
+{
+ x->Xmin= X;
+}
+
+void tCube3D_Xmax(t_tCube3D *x, t_float X)
+{
+ x->Xmax= X;
+}
+
+void tCube3D_Ymin(t_tCube3D *x, t_float X)
+{
+ x->Ymin= X;
+}
+
+void tCube3D_Ymax(t_tCube3D *x, t_float X)
+{
+ x->Ymax= X;
+}
+
+void tCube3D_Zmin(t_tCube3D *x, t_float X)
+{
+ x->Zmin= X;
+}
+
+void tCube3D_Zmax(t_tCube3D *x, t_float X)
+{
+ x->Zmax= X;
+}
+
+void *tCube3D_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_tCube3D *x = (t_tCube3D *)pd_new(tCube3D_class);
+ x->force_new=outlet_new(&x->x_obj, 0);
+
+ if (argc>=6)
+ x->Zmax = atom_getfloatarg(5, argc, argv);
+ else
+ x->Zmax = 1;
+
+ if (argc>=5)
+ x->Zmin = atom_getfloatarg(4, argc, argv);
+ else
+ x->Zmin = -1;
+
+ if (argc>=4)
+ x->Ymax = atom_getfloatarg(3, argc, argv);
+ else
+ x->Ymax = 1;
+
+ if (argc>=3)
+ x->Ymin = atom_getfloatarg(2, argc, argv);
+ else
+ x->Ymin = -1;
+
+ if (argc>=2)
+ x->Xmax = atom_getfloatarg(1, argc, argv);
+ else
+ x->Xmax = 1;
+
+ if (argc>=1)
+ x->Xmin = atom_getfloatarg(0, argc, argv);
+ else
+ x->Xmin = -1;
+
+ return (x);
+}
+
+void tCube3D_setup(void)
+{
+
+ tCube3D_class = class_new(gensym("tCube3D"),
+ (t_newmethod)tCube3D_new,
+ 0, sizeof(t_tCube3D),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addcreator((t_newmethod)tCube3D_new, gensym("pmpd.tCube3D"), A_GIMME, 0);
+
+ class_addmethod(tCube3D_class, (t_method)tCube3D_position3D, gensym("position3D"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+
+ class_addmethod(tCube3D_class, (t_method)tCube3D_Xmin, gensym("setXmin"), A_DEFFLOAT, 0);
+ class_addmethod(tCube3D_class, (t_method)tCube3D_Ymin, gensym("setYmin"), A_DEFFLOAT, 0);
+ class_addmethod(tCube3D_class, (t_method)tCube3D_Ymin, gensym("setZmin"), A_DEFFLOAT, 0);
+ class_addmethod(tCube3D_class, (t_method)tCube3D_Xmax, gensym("setXmax"), A_DEFFLOAT, 0);
+ class_addmethod(tCube3D_class, (t_method)tCube3D_Ymax, gensym("setYmax"), A_DEFFLOAT, 0);
+ class_addmethod(tCube3D_class, (t_method)tCube3D_Ymax, gensym("setZmax"), A_DEFFLOAT, 0);
+
+
+}
diff --git a/src/tCylinder3D.c b/src/tCylinder3D.c
new file mode 100755
index 0000000..1ccf832
--- /dev/null
+++ b/src/tCylinder3D.c
@@ -0,0 +1,218 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *tCylinder3D_class;
+
+typedef struct _tCylinder3D {
+ t_object x_obj;
+ t_float X, Y, Z, VX, VY, VZ, Pmin, Pmax, Rmin, Rmax, position_old;
+ t_outlet *force_new, *profondeur, *vitesse;// outlet
+} t_tCylinder3D;
+
+void tCylinder3D_position3D(t_tCylinder3D *x, t_float X, t_float Y, t_float Z)
+{
+ t_float d, tmp, profondeur, Xb, Yb, Zb, rayon, vitesse;
+
+ tmp = sqrt (x->VX*x->VX + x->VY*x->VY + x->VZ*x->VZ);
+ if (tmp != 0)
+ {
+ x->VX /= tmp;
+ x->VY /= tmp;
+ x->VZ /= tmp;
+ }
+ else
+ {
+ x->VX=1;
+ x->VY=0;
+ x->VZ=0;
+ }
+
+ d = x->VX * x->X + x->VY * x->Y + x->VZ * x->Z;
+
+ profondeur = x->VX * X + x->VY * Y + x->VZ * Z - d;
+
+ Xb = X - x->X - profondeur * x->VX;
+ Yb = Y - x->Y - profondeur * x->VY;
+ Zb = Z - x->Z - profondeur * x->VZ;
+
+ rayon = sqrt ( pow(Xb, 2) + pow(Yb, 2) + pow(Zb, 2) );
+
+ if ( rayon != 0 )
+ {
+ Xb /= rayon; // normalisation
+ Yb /= rayon;
+ Zb /= rayon;
+ }
+
+ vitesse = rayon - x->position_old;
+ x->position_old = rayon;
+
+ outlet_float(x->vitesse, vitesse);
+
+ outlet_float(x->profondeur, rayon);
+
+ if ( (profondeur < x->Pmin) & (profondeur > x->Pmax) & (rayon < x->Rmax) & (rayon > x->Rmin) )
+ {
+ outlet_float(x->force_new, 1);
+ }
+ else
+ {
+ outlet_float(x->force_new, 0);
+ }
+//C optimiser ca : pas faire le calcul de l'orientation du cylindre a chaques fois...
+
+}
+
+void tCylinder3D_setXYZ(t_tCylinder3D *x, t_float X, t_float Y, t_float Z)
+{
+ x->X= X;
+ x->Y= Y;
+ x->Z= Z;
+}
+void tCylinder3D_setVXYZ(t_tCylinder3D *x, t_float X, t_float Y, t_float Z)
+{
+ x->VX= X;
+ x->VY= Y;
+ x->VZ= Z;
+}
+
+void tCylinder3D_setVX(t_tCylinder3D *x, t_float X)
+{
+ x->VX= X;
+}
+
+void tCylinder3D_setVY(t_tCylinder3D *x, t_float Y)
+{
+ x->VY= Y;
+}
+
+void tCylinder3D_setVZ(t_tCylinder3D *x, t_float Z)
+{
+ x->VZ= Z;
+}
+void tCylinder3D_setX(t_tCylinder3D *x, t_float X)
+{
+ x->X= X;
+}
+
+void tCylinder3D_setY(t_tCylinder3D *x, t_float Y)
+{
+ x->Y= Y;
+}
+
+void tCylinder3D_setZ(t_tCylinder3D *x, t_float Z)
+{
+ x->Z= Z;
+}
+
+void tCylinder3D_setPmin(t_tCylinder3D *x, t_float X)
+{
+ x->Pmin= X;
+}
+
+void tCylinder3D_setPmax(t_tCylinder3D *x, t_float X)
+{
+ x->Pmax= X;
+}
+
+void tCylinder3D_setRmin(t_tCylinder3D *x, t_float R)
+{
+ x->Rmin = R;
+}
+
+void tCylinder3D_setRmax(t_tCylinder3D *x, t_float R)
+{
+ x->Rmax = R;
+}
+
+
+void *tCylinder3D_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_tCylinder3D *x = (t_tCylinder3D *)pd_new(tCylinder3D_class);
+
+ x->force_new=outlet_new(&x->x_obj, 0);
+ x->profondeur=outlet_new(&x->x_obj, 0);
+ x->vitesse=outlet_new(&x->x_obj, 0);
+
+ x->position_old = 0;
+
+ if (argc>=10)
+ x->Pmax= atom_getfloatarg(9, argc, argv);
+ else
+ x->Pmax= 1000;
+
+ if (argc>=9)
+ x->Pmin= atom_getfloatarg(8, argc, argv);
+ else
+ x->Pmin= -1000;
+
+ if (argc>=8)
+ x->Z= atom_getfloatarg(7, argc, argv);
+ else
+ x->Rmax= 1;
+
+ if (argc>=7)
+ x->Rmin= atom_getfloatarg(6, argc, argv);
+ else
+ x->Rmin= 0;
+
+ if (argc>=6)
+ x->Z= atom_getfloatarg(5, argc, argv);
+ else
+ x->Z= 0;
+
+ if (argc>=5)
+ x->Y= atom_getfloatarg(4, argc, argv);
+ else
+ x->Y= 0;
+
+ if (argc>=4)
+ x->X= atom_getfloatarg(3, argc, argv);
+ else
+ x->X= 0;
+
+ if (argc>=3)
+ x->VZ= atom_getfloatarg(2, argc, argv);
+ else
+ x->VZ= 0;
+
+ if (argc>=2)
+ x->VY= atom_getfloatarg(1, argc, argv);
+ else
+ x->VY= 0;
+
+ if (argc>=1)
+ x->VX= atom_getfloatarg(0, argc, argv);
+ else
+ x->VX= 1;
+
+ return (x);
+}
+
+void tCylinder3D_setup(void)
+{
+
+ tCylinder3D_class = class_new(gensym("tCylinder3D"),
+ (t_newmethod)tCylinder3D_new,
+ 0, sizeof(t_tCylinder3D),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addcreator((t_newmethod)tCylinder3D_new, gensym("pmpd.tCylinder3D"), A_GIMME, 0);
+
+ class_addmethod(tCylinder3D_class, (t_method)tCylinder3D_position3D, gensym("position3D"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+
+ class_addmethod(tCylinder3D_class, (t_method)tCylinder3D_setVX, gensym("setVX"), A_DEFFLOAT, 0);
+ class_addmethod(tCylinder3D_class, (t_method)tCylinder3D_setVY, gensym("setVY"), A_DEFFLOAT, 0);
+ class_addmethod(tCylinder3D_class, (t_method)tCylinder3D_setVZ, gensym("setVZ"), A_DEFFLOAT, 0);
+ class_addmethod(tCylinder3D_class, (t_method)tCylinder3D_setX, gensym("setX"), A_DEFFLOAT, 0);
+ class_addmethod(tCylinder3D_class, (t_method)tCylinder3D_setY, gensym("setY"), A_DEFFLOAT, 0);
+ class_addmethod(tCylinder3D_class, (t_method)tCylinder3D_setZ, gensym("setZ"), A_DEFFLOAT, 0);
+ class_addmethod(tCylinder3D_class, (t_method)tCylinder3D_setRmin, gensym("setRmin"), A_DEFFLOAT, 0);
+ class_addmethod(tCylinder3D_class, (t_method)tCylinder3D_setRmax, gensym("setRmax"), A_DEFFLOAT, 0);
+ class_addmethod(tCylinder3D_class, (t_method)tCylinder3D_setXYZ, gensym("setXYZ"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(tCylinder3D_class, (t_method)tCylinder3D_setVXYZ, gensym("setVXYZ"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(tCylinder3D_class, (t_method)tCylinder3D_setPmin, gensym("setPmin"), A_DEFFLOAT, 0);
+ class_addmethod(tCylinder3D_class, (t_method)tCylinder3D_setPmax, gensym("setPmax"), A_DEFFLOAT, 0);
+
+
+}
diff --git a/src/tLia2D.c b/src/tLia2D.c
new file mode 100755
index 0000000..968e5de
--- /dev/null
+++ b/src/tLia2D.c
@@ -0,0 +1,157 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *tLia2D_class;
+
+typedef struct _tLia2D {
+ t_object x_obj;
+ t_float distance_old, position2Dx1, position2Dy1, position2Dx2, position2Dy2;
+ t_outlet *force1;
+ t_outlet *force2;
+ t_outlet *force3;
+ t_outlet *force4;
+ t_symbol *x_sym; // receive
+} t_tLia2D;
+
+void tLia2D_reset(t_tLia2D *x)
+{
+}
+
+void tLia2D_resetF(t_tLia2D *x)
+{
+}
+
+void tLia2D_resetL(t_tLia2D *x)
+{
+}
+
+void tLia2D_setK(t_tLia2D *x, t_float K)
+{
+}
+
+void tLia2D_setL(t_tLia2D *x, t_float L)
+{
+}
+
+void tLia2D_setD(t_tLia2D *x, t_float D)
+{
+}
+
+void tLia2D_setD2(t_tLia2D *x, t_float D)
+{
+}
+
+void tLia2D_Lmin(t_tLia2D *x, t_float Lmin)
+{
+}
+
+void tLia2D_Lmax(t_tLia2D *x, t_float Lmax)
+{
+}
+
+void tLia2D_position2D(t_tLia2D *x, t_floatarg f1, t_floatarg f2)
+{
+ x->position2Dx1 = f1;
+ x->position2Dy1 = f2;
+}
+
+void tLia2D_position2D2(t_tLia2D *x, t_floatarg f1, t_floatarg f2)
+{
+ x->position2Dx2 = f1;
+ x->position2Dy2 = f2;
+}
+
+void tLia2D_bang(t_tLia2D *x)
+{
+ t_float vitesse, distance, orientation;
+ t_atom force1[2];
+
+ distance = sqrt ( pow((x->position2Dx2-x->position2Dx1), 2) + pow((x->position2Dy2-x->position2Dy1), 2) );
+
+ vitesse = x->distance_old - distance;
+
+ SETFLOAT(&(force1[0]), (x->position2Dx2 + x->position2Dx1)/ 2);
+ SETFLOAT(&(force1[1]), (x->position2Dy2 + x->position2Dy1)/ 2);
+
+ outlet_anything(x->force4, gensym("position2D"), 2, force1);
+
+ if ((x->position2Dx2-x->position2Dx1) != 0)
+ {
+ orientation = 180/3.14159 * atan((float)(x->position2Dy2 - x->position2Dy1)/(x->position2Dx2 - x->position2Dx1));
+ if ((x->position2Dx2 - x->position2Dx1)<0)
+ orientation +=180;
+ if (orientation<0)
+ orientation +=360;
+
+ outlet_float(x->force3, orientation);
+ }
+ else
+ {
+ if ((x->position2Dy2 - x->position2Dy1)<0)
+ outlet_float(x->force3,270);
+ else
+ outlet_float(x->force3,90);
+ }
+
+ outlet_float(x->force2, vitesse);
+
+ outlet_float(x->force1, distance);
+
+ x->distance_old = distance;
+
+}
+
+
+static void tLia2D_free(t_tLia2D *x)
+{
+ pd_unbind(&x->x_obj.ob_pd, x->x_sym);
+}
+
+void *tLia2D_new(t_symbol *s)
+{
+ t_tLia2D *x = (t_tLia2D *)pd_new(tLia2D_class);
+
+ x->x_sym = s;
+ pd_bind(&x->x_obj.ob_pd, s);
+
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("position2D"), gensym("position2D2"));
+
+ x->force1=outlet_new(&x->x_obj, 0);
+ x->force2=outlet_new(&x->x_obj, 0);
+ x->force3=outlet_new(&x->x_obj, 0);
+ x->force4=outlet_new(&x->x_obj, 0);
+
+ x->distance_old = 0;
+
+ return (x);
+}
+
+void tLia2D_setup(void)
+{
+
+ tLia2D_class = class_new(gensym("tLia2D"),
+ (t_newmethod)tLia2D_new,
+ (t_method)tLia2D_free,
+ sizeof(t_tLia2D),
+ CLASS_DEFAULT, A_DEFSYM, 0);
+
+ class_addcreator((t_newmethod)tLia2D_new, gensym("tLink2D"), A_DEFSYM, 0);
+ class_addcreator((t_newmethod)tLia2D_new, gensym("pmpd.tLink2D"), A_DEFSYM, 0);
+
+ class_addbang(tLia2D_class, tLia2D_bang);
+
+ class_addmethod(tLia2D_class, (t_method)tLia2D_position2D, gensym("position2D"), A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(tLia2D_class, (t_method)tLia2D_position2D2, gensym("position2D2"), A_DEFFLOAT, A_DEFFLOAT, 0);
+
+ // only for the object not to output erreor when having the same name as the link
+ class_addmethod(tLia2D_class, (t_method)tLia2D_reset, gensym("reset"), 0);
+ class_addmethod(tLia2D_class, (t_method)tLia2D_resetL, gensym("resetL"), 0);
+ class_addmethod(tLia2D_class, (t_method)tLia2D_resetF, gensym("resetF"), 0);
+ class_addmethod(tLia2D_class, (t_method)tLia2D_setD, gensym("setD"), A_DEFFLOAT, 0);
+ class_addmethod(tLia2D_class, (t_method)tLia2D_setD2, gensym("setD2"), A_DEFFLOAT, 0);
+ class_addmethod(tLia2D_class, (t_method)tLia2D_setK, gensym("setK"), A_DEFFLOAT, 0);
+ class_addmethod(tLia2D_class, (t_method)tLia2D_setL, gensym("setL"), A_DEFFLOAT, 0);
+ class_addmethod(tLia2D_class, (t_method)tLia2D_Lmin, gensym("setLmin"), A_DEFFLOAT, 0);
+ class_addmethod(tLia2D_class, (t_method)tLia2D_Lmax, gensym("setLmax"), A_DEFFLOAT, 0);
+
+}
diff --git a/src/tLia3D.c b/src/tLia3D.c
new file mode 100755
index 0000000..507d113
--- /dev/null
+++ b/src/tLia3D.c
@@ -0,0 +1,153 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *tLia3D_class;
+
+typedef struct _tLia3D {
+ t_object x_obj;
+ t_float distance_old, position2Dx1, position2Dy1, position2Dz1, position2Dx2, position2Dy2, position2Dz2;
+ t_outlet *force1;
+ t_outlet *force2;
+ t_outlet *force3;
+ t_outlet *force4;
+ t_symbol *x_sym; // receive
+} t_tLia3D;
+
+void tLia3D_reset(t_tLia3D *x)
+{
+}
+
+void tLia3D_resetF(t_tLia3D *x)
+{
+}
+
+void tLia3D_resetL(t_tLia3D *x)
+{
+}
+
+
+void tLia3D_setK(t_tLia3D *x, t_float K)
+{
+}
+
+void tLia3D_setL(t_tLia3D *x, t_float L)
+{
+}
+
+void tLia3D_setD(t_tLia3D *x, t_float D)
+{
+}
+
+void tLia3D_setD2(t_tLia3D *x, t_float D)
+{
+}
+
+void tLia3D_Lmin(t_tLia3D *x, t_float Lmin)
+{
+}
+
+void tLia3D_Lmax(t_tLia3D *x, t_float Lmax)
+{
+}
+
+
+void tLia3D_position3D(t_tLia3D *x, t_floatarg f1, t_floatarg f2, t_floatarg f3)
+{
+ x->position2Dx1 = f1;
+ x->position2Dy1 = f2;
+ x->position2Dz1 = f3;
+}
+
+void tLia3D_position3D2(t_tLia3D *x, t_floatarg f1, t_floatarg f2, t_floatarg f3)
+{
+ x->position2Dx2 = f1;
+ x->position2Dy2 = f2;
+ x->position2Dz2 = f3;
+}
+
+void tLia3D_bang(t_tLia3D *x)
+{
+ t_float vitesse, distance, orientation;
+ t_atom force1[3];
+
+ distance = sqrt ( pow((x->position2Dx2-x->position2Dx1), 2) + pow((x->position2Dy2-x->position2Dy1), 2) + pow((x->position2Dz2-x->position2Dz1), 2) );
+
+ vitesse = x->distance_old - distance;
+
+
+ SETFLOAT(&(force1[0]), (x->position2Dx2 + x->position2Dx1)/ 2);
+ SETFLOAT(&(force1[1]), (x->position2Dy2 + x->position2Dy1)/ 2);
+ SETFLOAT(&(force1[2]), (x->position2Dz2 + x->position2Dz1)/ 2);
+
+ outlet_anything(x->force4, gensym("position3D"), 3, force1);
+
+
+ SETFLOAT(&(force1[0]), (x->position2Dx2 - x->position2Dx1)/ distance);
+ SETFLOAT(&(force1[1]), (x->position2Dy2 - x->position2Dy1)/ distance);
+ SETFLOAT(&(force1[2]), (x->position2Dz2 - x->position2Dz1)/ distance);
+
+ outlet_anything(x->force3, gensym("vector3D"), 3, force1);
+
+ outlet_float(x->force2, vitesse);
+
+ outlet_float(x->force1, distance);
+
+ x->distance_old = distance;
+
+}
+
+
+static void tLia3D_free(t_tLia3D *x)
+{
+ pd_unbind(&x->x_obj.ob_pd, x->x_sym);
+}
+
+void *tLia3D_new(t_symbol *s)
+{
+
+ t_tLia3D *x = (t_tLia3D *)pd_new(tLia3D_class);
+
+ x->x_sym = s;
+ pd_bind(&x->x_obj.ob_pd, s);
+
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("position3D"), gensym("position3D2"));
+
+ x->force1=outlet_new(&x->x_obj, 0);
+ x->force2=outlet_new(&x->x_obj, 0);
+ x->force3=outlet_new(&x->x_obj, 0);
+ x->force4=outlet_new(&x->x_obj, 0);
+
+ x->distance_old = 0;
+
+ return (x);
+}
+
+void tLia3D_setup(void)
+{
+
+ tLia3D_class = class_new(gensym("tLia3D"),
+ (t_newmethod)tLia3D_new,
+ (t_method)tLia3D_free,
+ sizeof(t_tLia3D),
+ CLASS_DEFAULT, A_DEFSYM, 0);
+
+ class_addcreator((t_newmethod)tLia3D_new, gensym("tLink3D"), A_DEFSYM, 0);
+ class_addcreator((t_newmethod)tLia3D_new, gensym("pmpd.tLink3D"), A_DEFSYM, 0);
+
+ class_addbang(tLia3D_class, tLia3D_bang);
+
+ class_addmethod(tLia3D_class, (t_method)tLia3D_position3D, gensym("position3D"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(tLia3D_class, (t_method)tLia3D_position3D2, gensym("position3D2"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+
+ // only for the object not to output erreor when having the same name as the link
+ class_addmethod(tLia3D_class, (t_method)tLia3D_reset, gensym("reset"), 0);
+ class_addmethod(tLia3D_class, (t_method)tLia3D_resetL, gensym("resetL"), 0);
+ class_addmethod(tLia3D_class, (t_method)tLia3D_resetF, gensym("resetF"), 0);
+ class_addmethod(tLia3D_class, (t_method)tLia3D_setD, gensym("setD"), A_DEFFLOAT, 0);
+ class_addmethod(tLia3D_class, (t_method)tLia3D_setD2, gensym("setD2"), A_DEFFLOAT, 0);
+ class_addmethod(tLia3D_class, (t_method)tLia3D_setK, gensym("setK"), A_DEFFLOAT, 0);
+ class_addmethod(tLia3D_class, (t_method)tLia3D_setL, gensym("setL"), A_DEFFLOAT, 0);
+ class_addmethod(tLia3D_class, (t_method)tLia3D_Lmin, gensym("setLmin"), A_DEFFLOAT, 0);
+ class_addmethod(tLia3D_class, (t_method)tLia3D_Lmax, gensym("setLmax"), A_DEFFLOAT, 0);
+
+}
diff --git a/src/tLine2D.c b/src/tLine2D.c
new file mode 100755
index 0000000..f440bfd
--- /dev/null
+++ b/src/tLine2D.c
@@ -0,0 +1,137 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *tLine2D_class;
+
+typedef struct _tLine2D {
+ t_object x_obj;
+ t_float X1, X2, Y1, Y2, P, P_old;
+ //extrem = Xmin, Ymin, Xmax, Ymax;
+ t_outlet *force_new;// outlet
+ t_outlet *profondeur;// outlet
+ t_outlet *vitesse;// outlet
+} t_tLine2D;
+
+void tLine2D_position2D(t_tLine2D *x, t_float X, t_float Y)
+{
+ t_float a1, b1, c1, profondeur, tmp;
+
+ b1 = x->X2 - x->X1;
+ a1 = -x->Y2 + x->Y1;
+
+ if (!((a1==0) & (b1==0)))
+ {
+ tmp = sqrt((a1*a1)+(b1*b1)); // = longueur du vecteur pour renormalisation
+ a1 = a1/tmp;
+ b1 = b1/tmp;
+ c1 = a1*x->X1+b1*x->Y1;
+
+ profondeur = ( (a1 * X) + (b1 * Y) ) - c1;
+
+ tmp = profondeur - x->P_old;
+
+ x->P_old = profondeur;
+
+ outlet_float(x->vitesse, tmp);
+
+ outlet_float(x->profondeur, profondeur);
+
+ if ( ( profondeur < 0) & (profondeur > - x->P) )
+ {
+ outlet_float(x->force_new, 1);
+ }
+ else
+ {
+ outlet_float(x->force_new, 0);
+ }
+ }
+ else
+ {
+ outlet_float(x->force_new, 0);
+ }
+
+}
+
+void tLine2D_Xmin(t_tLine2D *x, t_float X)
+{
+ x->X1= X;
+}
+
+void tLine2D_Xmax(t_tLine2D *x, t_float X)
+{
+ x->X2= X;
+}
+
+void tLine2D_Ymin(t_tLine2D *x, t_float X)
+{
+ x->Y1= X;
+}
+
+void tLine2D_Ymax(t_tLine2D *x, t_float X)
+{
+ x->Y2= X;
+}
+
+void tLine2D_P(t_tLine2D *x, t_float X)
+{
+ x->P= X;
+}
+
+void *tLine2D_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_tLine2D *x = (t_tLine2D *)pd_new(tLine2D_class);
+
+ x->force_new=outlet_new(&x->x_obj, 0);
+ x->profondeur=outlet_new(&x->x_obj, 0);
+ x->vitesse=outlet_new(&x->x_obj, 0);
+
+ x->P_old=0;
+
+ if (argc>=5)
+ x->P = atom_getfloatarg(4, argc, argv);
+ else
+ x->P = 1;
+
+ if (argc>=4)
+ x->Y2 = atom_getfloatarg(3, argc, argv);
+ else
+ x->Y2 = 0;
+
+ if (argc>=3)
+ x->X2 = atom_getfloatarg(2, argc, argv);
+ else
+ x->X2 = 1;
+
+ if (argc>=2)
+ x->Y1 = atom_getfloatarg(1, argc, argv);
+ else
+ x->Y1 = 0;
+
+
+ if (argc>=1)
+ x->X1 = atom_getfloatarg(0, argc, argv);
+ else
+ x->X1 = -1;
+
+ return (x);
+}
+
+void tLine2D_setup(void)
+{
+
+ tLine2D_class = class_new(gensym("tLine2D"),
+ (t_newmethod)tLine2D_new,
+ 0, sizeof(t_tLine2D),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addcreator((t_newmethod)tLine2D_new, gensym("pmpd.tLine2D"), A_GIMME, 0);
+
+ class_addmethod(tLine2D_class, (t_method)tLine2D_position2D, gensym("position2D"), A_DEFFLOAT, A_DEFFLOAT, 0);
+
+ class_addmethod(tLine2D_class, (t_method)tLine2D_Xmin, gensym("setX1"), A_DEFFLOAT, 0);
+ class_addmethod(tLine2D_class, (t_method)tLine2D_Ymin, gensym("setY1"), A_DEFFLOAT, 0);
+ class_addmethod(tLine2D_class, (t_method)tLine2D_Xmax, gensym("setX2"), A_DEFFLOAT, 0);
+ class_addmethod(tLine2D_class, (t_method)tLine2D_Ymax, gensym("setY2"), A_DEFFLOAT, 0);
+ class_addmethod(tLine2D_class, (t_method)tLine2D_P, gensym("setPmax"), A_DEFFLOAT, 0);
+
+}
diff --git a/src/tPlane3D.c b/src/tPlane3D.c
new file mode 100755
index 0000000..3213bea
--- /dev/null
+++ b/src/tPlane3D.c
@@ -0,0 +1,175 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *tPlane3D_class;
+
+typedef struct _tPlane3D {
+ t_object x_obj;
+ t_float X, Y, Z, VX, VY, VZ, P, distance_old;
+ t_outlet *force_new, *profondeur, *vitesse;// outlet
+} t_tPlane3D;
+
+
+void tPlane3D_position3D(t_tPlane3D *x, t_float X, t_float Y, t_float Z)
+{
+t_float d, tmp, profondeur, vitesse;
+
+ tmp = sqrt (x->VX*x->VX + x->VY*x->VY + x->VZ*x->VZ);
+ if (tmp != 0)
+ {
+ x->VX /= tmp;
+ x->VY /= tmp;
+ x->VZ /= tmp;
+
+ }
+ else
+ {
+ x->VX=1;
+ x->VY=0;
+ x->VZ=0;
+ }
+
+ d = x->VX * x->X + x->VY * x->Y + x->VZ * x->Z;
+
+ profondeur = x->VX * X + x->VY * Y + x->VZ * Z - d;
+
+ vitesse = profondeur - x->distance_old ;
+
+ x->distance_old = profondeur;
+
+ outlet_float(x->vitesse, vitesse);
+
+ outlet_float(x->profondeur, profondeur);
+
+
+ if ( (profondeur < 0) & (profondeur > - x->P) )
+ {
+ outlet_float(x->force_new, 1);
+ }
+ else
+ {
+ outlet_float(x->force_new, 0);
+ }
+
+}
+
+void tPlane3D_setXYZ(t_tPlane3D *x, t_float X, t_float Y, t_float Z)
+{
+ x->X= X;
+ x->Y= Y;
+ x->Z= Z;
+}
+void tPlane3D_setVXYZ(t_tPlane3D *x, t_float X, t_float Y, t_float Z)
+{
+ x->VX= X;
+ x->VY= Y;
+ x->VZ= Z;
+}
+
+void tPlane3D_setVX(t_tPlane3D *x, t_float X)
+{
+ x->VX= X;
+}
+
+void tPlane3D_setVY(t_tPlane3D *x, t_float Y)
+{
+ x->VY= Y;
+}
+
+void tPlane3D_setVZ(t_tPlane3D *x, t_float Z)
+{
+ x->VZ= Z;
+}
+void tPlane3D_setX(t_tPlane3D *x, t_float X)
+{
+ x->X= X;
+}
+
+void tPlane3D_setY(t_tPlane3D *x, t_float Y)
+{
+ x->Y= Y;
+}
+
+void tPlane3D_setZ(t_tPlane3D *x, t_float Z)
+{
+ x->Z= Z;
+}
+
+void tPlane3D_setP(t_tPlane3D *x, t_float X)
+{
+ x->P= X;
+}
+
+
+void *tPlane3D_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_tPlane3D *x = (t_tPlane3D *)pd_new(tPlane3D_class);
+
+ x->force_new=outlet_new(&x->x_obj, 0);
+ x->profondeur=outlet_new(&x->x_obj, 0);
+ x->vitesse=outlet_new(&x->x_obj, 0);
+
+ x->distance_old = 0;
+
+ if (argc>=7)
+ x->P= atom_getfloatarg(6, argc, argv);
+ else
+ x->P= 10000;
+
+ if (argc>=6)
+ x->Z= atom_getfloatarg(5, argc, argv);
+ else
+ x->Z= 0;
+
+ if (argc>=5)
+ x->Y= atom_getfloatarg(4, argc, argv);
+ else
+ x->Y= 0;
+
+ if (argc>=4)
+ x->X= atom_getfloatarg(3, argc, argv);
+ else
+ x->X= 0;
+
+ if (argc>=3)
+ x->VZ= atom_getfloatarg(2, argc, argv);
+ else
+ x->VZ= 0;
+
+ if (argc>=2)
+ x->VY= atom_getfloatarg(1, argc, argv);
+ else
+ x->VY= 0;
+
+ if (argc>=1)
+ x->VX= atom_getfloatarg(0, argc, argv);
+ else
+ x->VX= 1;
+
+ return (x);
+}
+
+void tPlane3D_setup(void)
+{
+
+ tPlane3D_class = class_new(gensym("tPlane3D"),
+ (t_newmethod)tPlane3D_new,
+ 0, sizeof(t_tPlane3D),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addcreator((t_newmethod)tPlane3D_new, gensym("pmpd.tPlane3D"), A_GIMME, 0);
+
+ class_addmethod(tPlane3D_class, (t_method)tPlane3D_position3D, gensym("position3D"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+
+ class_addmethod(tPlane3D_class, (t_method)tPlane3D_setVX, gensym("setVX"), A_DEFFLOAT, 0);
+ class_addmethod(tPlane3D_class, (t_method)tPlane3D_setVY, gensym("setVY"), A_DEFFLOAT, 0);
+ class_addmethod(tPlane3D_class, (t_method)tPlane3D_setVZ, gensym("setVZ"), A_DEFFLOAT, 0);
+ class_addmethod(tPlane3D_class, (t_method)tPlane3D_setX, gensym("setX"), A_DEFFLOAT, 0);
+ class_addmethod(tPlane3D_class, (t_method)tPlane3D_setY, gensym("setY"), A_DEFFLOAT, 0);
+ class_addmethod(tPlane3D_class, (t_method)tPlane3D_setZ, gensym("setZ"), A_DEFFLOAT, 0);
+ class_addmethod(tPlane3D_class, (t_method)tPlane3D_setXYZ, gensym("setXYZ"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(tPlane3D_class, (t_method)tPlane3D_setVXYZ, gensym("setVXYZ"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(tPlane3D_class, (t_method)tPlane3D_setP, gensym("setPmax"), A_DEFFLOAT, 0);
+
+
+}
diff --git a/src/tSeg2D.c b/src/tSeg2D.c
new file mode 100755
index 0000000..7345bd7
--- /dev/null
+++ b/src/tSeg2D.c
@@ -0,0 +1,139 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *tSeg2D_class;
+
+typedef struct _tSeg2D {
+ t_object x_obj;
+ t_float X1, X2, Y1, Y2, P, P_old;
+ t_outlet *force_new, *profondeur, *vitesse;// outlet
+} t_tSeg2D;
+
+void tSeg2D_position2D(t_tSeg2D *x, t_float X, t_float Y)
+{
+ t_float a1, b1, c1, a2, b2, c2, a3, b3, c3, profondeur, tmp;
+
+ b1 = x->X2 - x->X1;
+ a1 = -x->Y2 + x->Y1;
+
+ if (!((a1==0) & (b1==0)))
+ {
+ tmp = sqrt((a1*a1)+(b1*b1)); // = longueur du vecteur pour renormalisation
+ a1 = a1/tmp;
+ b1 = b1/tmp;
+ c1 = a1*x->X1+b1*x->Y1;
+
+ profondeur = ( (a1 * X) + (b1 * Y) ) - c1;
+
+ tmp = profondeur - x->P_old;
+
+ x->P_old = profondeur;
+
+ a2 = b1;
+ b2 = -a1;
+ c2 = a2*x->X1+b2*x->Y1;
+
+ a3 = a2;
+ b3 = b2;
+ c3 = a3*x->X2+b3*x->Y2;
+
+ outlet_float(x->vitesse, tmp);
+ outlet_float(x->profondeur, profondeur);
+
+ if ( ( profondeur < 0) & (profondeur > - x->P) & (( (a2 * X) + (b2 * Y) ) > c2) & ( ((a3 * X) + (b3 * Y) ) < c3) )
+ {
+ outlet_float(x->force_new, 1);
+ }
+ else
+ {
+ outlet_float(x->force_new, 0);
+ }
+ }
+ else
+ {
+ outlet_float(x->force_new, 0);
+ }
+
+}
+
+void tSeg2D_Xmin(t_tSeg2D *x, t_float X)
+{
+ x->X1= X;
+}
+
+void tSeg2D_Xmax(t_tSeg2D *x, t_float X)
+{
+ x->X2= X;
+}
+
+void tSeg2D_Ymin(t_tSeg2D *x, t_float X)
+{
+ x->Y1= X;
+}
+
+void tSeg2D_Ymax(t_tSeg2D *x, t_float X)
+{
+ x->Y2= X;
+}
+
+void tSeg2D_P(t_tSeg2D *x, t_float X)
+{
+ x->P= X;
+}
+
+void *tSeg2D_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_tSeg2D *x = (t_tSeg2D *)pd_new(tSeg2D_class);
+ x->force_new = outlet_new(&x->x_obj, 0);
+ x->profondeur =outlet_new(&x->x_obj, 0);
+ x->vitesse = outlet_new(&x->x_obj, 0);
+
+ x->P_old = 0;
+
+ if (argc>=5)
+ x->P = atom_getfloatarg(4, argc, argv);
+ else
+ x->P = 1;
+
+ if (argc>=4)
+ x->Y2 = atom_getfloatarg(3, argc, argv);
+ else
+ x->Y2 = 0;
+
+ if (argc>=3)
+ x->X2 = atom_getfloatarg(2, argc, argv);
+ else
+ x->X2 = 1;
+
+ if (argc>=2)
+ x->Y1 = atom_getfloatarg(1, argc, argv);
+ else
+ x->Y1 = 0;
+
+ if (argc>=1)
+ x->X1 = atom_getfloatarg(0, argc, argv);
+ else
+ x->X1 = -1;
+
+ return (x);
+}
+
+void tSeg2D_setup(void)
+{
+
+ tSeg2D_class = class_new(gensym("tSeg2D"),
+ (t_newmethod)tSeg2D_new,
+ 0, sizeof(t_tSeg2D),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addcreator((t_newmethod)tSeg2D_new, gensym("pmpd.tSeg2D"), A_GIMME, 0);
+
+ class_addmethod(tSeg2D_class, (t_method)tSeg2D_position2D, gensym("position2D"), A_DEFFLOAT, A_DEFFLOAT, 0);
+
+ class_addmethod(tSeg2D_class, (t_method)tSeg2D_Xmin, gensym("setX1"), A_DEFFLOAT, 0);
+ class_addmethod(tSeg2D_class, (t_method)tSeg2D_Ymin, gensym("setY1"), A_DEFFLOAT, 0);
+ class_addmethod(tSeg2D_class, (t_method)tSeg2D_Xmax, gensym("setX2"), A_DEFFLOAT, 0);
+ class_addmethod(tSeg2D_class, (t_method)tSeg2D_Ymax, gensym("setY2"), A_DEFFLOAT, 0);
+ class_addmethod(tSeg2D_class, (t_method)tSeg2D_P, gensym("setPmax"), A_DEFFLOAT, 0);
+
+}
diff --git a/src/tSphere3D.c b/src/tSphere3D.c
new file mode 100755
index 0000000..6ef9cfa
--- /dev/null
+++ b/src/tSphere3D.c
@@ -0,0 +1,128 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *tSphere3D_class;
+
+typedef struct _tSphere3D {
+ t_object x_obj;
+ t_float X, Y, Z, Rmin, Rmax, position_old;
+ t_outlet *force_new, *distance_out, *vitesse;// outlet
+} t_tSphere3D;
+
+void tSphere3D_position3D(t_tSphere3D *x, t_float X, t_float Y, t_float Z)
+{
+t_float distance, vitesse;
+ distance = sqrt ( (X - x->X)*(X - x->X) + (Y - x->Y)*(Y - x->Y) + (Z - x->Z)*(Z - x->Z));
+
+ vitesse = distance - x->position_old;
+ x->position_old = distance;
+
+ outlet_float(x->vitesse, vitesse);
+
+ outlet_float(x->distance_out, distance);
+
+ if ( (distance < x->Rmax) & (distance > x->Rmin) )
+ {
+ outlet_float(x->force_new, 1);
+ }
+ else
+ {
+ outlet_float(x->force_new, 0);
+ }
+
+}
+
+void tSphere3D_setXYZ(t_tSphere3D *x, t_float X, t_float Y, t_float Z)
+{
+ x->X= X;
+ x->Y= Y;
+ x->Z= Z;
+}
+
+void tSphere3D_setX(t_tSphere3D *x, t_float X)
+{
+ x->X= X;
+}
+
+void tSphere3D_setY(t_tSphere3D *x, t_float Y)
+{
+ x->Y= Y;
+}
+
+void tSphere3D_setZ(t_tSphere3D *x, t_float Z)
+{
+ x->Z= Z;
+}
+
+void tSphere3D_setRmax(t_tSphere3D *x, t_float X)
+{
+ x->Rmax= X;
+}
+
+void tSphere3D_setRmin(t_tSphere3D *x, t_float X)
+{
+ x->Rmin= X;
+}
+
+
+
+void *tSphere3D_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_tSphere3D *x = (t_tSphere3D *)pd_new(tSphere3D_class);
+
+ x->force_new=outlet_new(&x->x_obj, 0);
+ x->distance_out=outlet_new(&x->x_obj, 0);
+ x->vitesse=outlet_new(&x->x_obj, 0);
+
+ x->position_old = 0;
+
+
+ if (argc>=5)
+ x->Rmax= atom_getfloatarg(4, argc, argv);
+ else
+ x->Rmax= 1;
+
+ if (argc>=4)
+ x->Rmin= atom_getfloatarg(3, argc, argv);
+ else
+ x->Rmin= 0;
+
+ if (argc>=3)
+ x->Z= atom_getfloatarg(2, argc, argv);
+ else
+ x->Z= 0;
+
+ if (argc>=2)
+ x->Y= atom_getfloatarg(1, argc, argv);
+ else
+ x->Y= 0;
+
+ if (argc>=1)
+ x->X= atom_getfloatarg(0, argc, argv);
+ else
+ x->X= 0;
+
+ return (x);
+}
+
+void tSphere3D_setup(void)
+{
+
+ tSphere3D_class = class_new(gensym("tSphere3D"),
+ (t_newmethod)tSphere3D_new,
+ 0, sizeof(t_tSphere3D),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addcreator((t_newmethod)tSphere3D_new, gensym("pmpd.tSphere3D"), A_GIMME, 0);
+
+ class_addmethod(tSphere3D_class, (t_method)tSphere3D_position3D, gensym("position3D"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+
+ class_addmethod(tSphere3D_class, (t_method)tSphere3D_setX, gensym("setX"), A_DEFFLOAT, 0);
+ class_addmethod(tSphere3D_class, (t_method)tSphere3D_setY, gensym("setY"), A_DEFFLOAT, 0);
+ class_addmethod(tSphere3D_class, (t_method)tSphere3D_setZ, gensym("setZ"), A_DEFFLOAT, 0);
+ class_addmethod(tSphere3D_class, (t_method)tSphere3D_setXYZ, gensym("setXYZ"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(tSphere3D_class, (t_method)tSphere3D_setRmax, gensym("setRmax"), A_DEFFLOAT, 0);
+ class_addmethod(tSphere3D_class, (t_method)tSphere3D_setRmin, gensym("setRmin"), A_DEFFLOAT, 0);
+
+
+}
diff --git a/src/tSquare2D.c b/src/tSquare2D.c
new file mode 100755
index 0000000..4e14fa0
--- /dev/null
+++ b/src/tSquare2D.c
@@ -0,0 +1,92 @@
+#include "m_pd.h"
+#include "math.h"
+
+static t_class *tSquare2D_class;
+
+typedef struct _tSquare2D {
+ t_object x_obj;
+ t_float Xmin, Xmax, Ymin, Ymax;
+ //extrem = Xmin, Ymin, Xmax, Ymax;
+ t_outlet *force_new;// outlet
+} t_tSquare2D;
+
+void tSquare2D_position2D(t_tSquare2D *x, t_float X, t_float Y)
+{
+
+ if ((X > x->Xmin) & (X < x->Xmax) & (Y > x->Ymin) & (Y < x->Ymax))
+ {
+ outlet_float(x->force_new, 1);
+ }
+ else
+ {
+ outlet_float(x->force_new, 0);
+ }
+}
+
+void tSquare2D_Xmin(t_tSquare2D *x, t_float X)
+{
+ x->Xmin= X;
+}
+
+void tSquare2D_Xmax(t_tSquare2D *x, t_float X)
+{
+ x->Xmax= X;
+}
+
+void tSquare2D_Ymin(t_tSquare2D *x, t_float X)
+{
+ x->Ymin= X;
+}
+
+void tSquare2D_Ymax(t_tSquare2D *x, t_float X)
+{
+ x->Ymax= X;
+}
+
+void *tSquare2D_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_tSquare2D *x = (t_tSquare2D *)pd_new(tSquare2D_class);
+ x->force_new=outlet_new(&x->x_obj, 0);
+
+ if (argc>=4)
+ x->Ymax = atom_getfloatarg(3, argc, argv);
+ else
+ x->Ymax = 1;
+
+ if (argc>=3)
+ x->Ymin = atom_getfloatarg(2, argc, argv);
+ else
+ x->Ymin = -1;
+
+ if (argc>=2)
+ x->Xmax = atom_getfloatarg(1, argc, argv);
+ else
+ x->Xmax = 1;
+
+ if (argc>=1)
+ x->Xmin = atom_getfloatarg(0, argc, argv);
+ else
+ x->Xmin = -1;
+
+ return (x);
+}
+
+void tSquare2D_setup(void)
+{
+
+ tSquare2D_class = class_new(gensym("tSquare2D"),
+ (t_newmethod)tSquare2D_new,
+ 0, sizeof(t_tSquare2D),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addcreator((t_newmethod)tSquare2D_new, gensym("pmpd.tSquare2D"), A_GIMME, 0);
+
+ class_addmethod(tSquare2D_class, (t_method)tSquare2D_position2D, gensym("position2D"), A_DEFFLOAT, A_DEFFLOAT, 0);
+
+ class_addmethod(tSquare2D_class, (t_method)tSquare2D_Xmin, gensym("setXmin"), A_DEFFLOAT, 0);
+ class_addmethod(tSquare2D_class, (t_method)tSquare2D_Ymin, gensym("setYmin"), A_DEFFLOAT, 0);
+ class_addmethod(tSquare2D_class, (t_method)tSquare2D_Xmax, gensym("setXmax"), A_DEFFLOAT, 0);
+ class_addmethod(tSquare2D_class, (t_method)tSquare2D_Ymax, gensym("setYmax"), A_DEFFLOAT, 0);
+
+
+}