double* ImplicitEuler (double theta0, double dtheta0, double h, int n)
{
int c = 1;
const int maxIterations = 32;
double* theta = new double[n];
for (int i = 0;i < n; i++){
double theta1 = theta0;
for (int j = 0; j < maxIterations; j++){
double g = theta1 +h * h * c * sin(theta1) - theta0 - h * dtheta0;
double gder = 1.0 + h * h * c * cos(theta1);
theta1 -= g/gder;
}//end for inner
double dtheta1 = dtheta0 - h * c * sin(theta1);
theta = theta1;
theta0 = theta1;
dtheta0 = dtheta1;
}//end for outer
return theta;
}
Vector x1 = force * oneOverMass * dt2;
vel= (pos - m_prevPos) + x1;
vel.y-=9.81f*dt2;
m_prevPos = pos;
pos+=vel;