function animate_pendulum(times,sols,L,d,Omega)
xa = d*cos(Omega*times);
ya = d*sin(Omega*times);
xp = xa + L*sin(sols(:,1));
yp = ya - L*cos(sols(:,1));
maxv = max(max(max(xp),max(xa)),max(max(ya),max(yp)));
minv = min(min(min(xa),min(xp)),min(min(ya),min(yp)));
%if (minv>0) minv = -0.1; end
%if (maxv<0) maxv = 0.1; end
dx = 0.505*(maxv-minv);
xcen = 0.5*(max(max(xa),max(xp))+min(min(xa),min(xp)));
ycen = 0.5*(max(max(ya),max(yp))+min(min(ya),min(yp)));
figure;
for i = 1:length(times)
    clf
    ylim([ycen-dx ycen+dx]);
    xlim([xcen-dx xcen+dx]);
    axis square;
    hold on;
    plot(xp(i),yp(i),'ro','MarkerSize',11,'MarkerFaceColor',[1,0,0]);
    plot([xa(i),xp(i)],[ya(i),yp(i)],'LineWidth',2)
    plot([0,xa(i)],[0,ya(i)],'LineWidth',2)
    pause(0.05)
end

end