Equation used in the above simulation.
Assume angle \theta for the pendulum, angular velocity \omega=\frac{d\theta}{dt}
And \frac{d\omega}{dt}=calAplha(\theta)+ g\cos\theta+ -b\omega/m
where caAplha(\theta) calculate spring force and find it tangential component.

[code]
public double calAlpha (double c) {
cs=Math.cos(c);
sc=Math.sin(c);
x=x2-R*cs;
y=y2-R*sc;
L=Math.sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));
f=-k*(L-L0); fx=f*(x-x1);
fy=f*(y-y1);
n=-fx*cs-fy*sc;
nx=-n*cs;
ny=-n*sc;
fx=fx-nx;
fy=fy-ny;
if(c>0)sign=-1;
else sign=1;
return sign*Math.sqrt(fx*fx+fy*fy)/I; // where I is the momentum of initial
}
[/code]