#pragma once
#include "utils/Vector3.h"

class Spring
{
public:
   Vector3 *p1;
   Vector3 *p2;
   float L;
   float k;

   Spring(void){}
   Spring(Vector3 *p1_, Vector3 *p2_, float L_, float k_){p1=p1_; p2=p2_; L=L_; k=k_;}
   ~Spring(void){}

   Vector3 Force1(void) 
   {	//we use only this force1

	   //printf("possible probl. here? spring.h\n");
	  //if(fabs((*p1-*p2).length()) <= 0.00001)return Vector3(0,0,0);
      //return (*p2-*p1)*((*p1-*p2).length()-L)*(1.0f/(*p1-*p2).length())*(-k);
	  return (*p1-*p2) * ( -k*((*p1-*p2).length()-L)*(1.0f/(*p1-*p2).length()) );
   }
   Vector3 Force2(void)
   {
	  if(fabs((*p1-*p2).length()) < 0.00000001)return Vector3(0,0,0);
      return (*p2-*p1)*((*p2-*p1).length()-L)*(1.0f/(*p2-*p1).length())*(-k);
   }
};