My teacher says to use this formulae if this makes more sense but i couldnt get this one to work so i got that one above from gamasutra.com.
Using this formulae and what jjd said about the magnitude i do this for all of x y z forces.
r->kd = 0.2;
r->ks = 500;
r->r = 0.5;
Lx = r->P[j].Pos.x - r->P[j+1].Pos.x;
" "
Ldotx = r->P[j].Vel.x - r->P[j+1].Vel.x;
" "
Lmag = sqrt(Lx*Lx + Ly*Ly + Lz*Lz);
if(Lx != 0)
ForceA.x = -(r->ks * (Lmag - r->r)
+ r->kd * ((Ldotx * Lx) / Lmag)) * ( Lx / Lmag);
if(Ly != 0)
ForceA.y = -(r->ks * (Lmag - r->r)
+ r->kd * ((Ldotx * Ly) / Lmag)) * ( Ly / Lmag);
ForceA.y += -9.8 / r->P[j].M;
if(Lz != 0)
ForceA.z = -(r->ks * (Lmag - r->r)
+ r->kd * ((Ldotx * Lz) / Lmag)) * ( Lz / Lmag);
If i do it this way all the particles are insanely close. I start off all these particles resting on the x axis spaced 0.5 appart i must be doing this wrong because the force in the x between the 1st and 2nd pixel is zero and between the 3rd and 4th particle its 250 force in the x axis =/.
thanks again for any help.
[Edited by - fishleg003 on November 25, 2005 12:28:50 PM]