function tmax = optimize_raptorchase(theta)


anglegrid0 = 0:0.1:pi;
anglegrid = 0:0.1:2*pi;
[X,Y] = meshgrid(anglegrid0,anglegrid);
nangles = numel(X);
survival = zeros(size(X));

for i=1:nangles
    subplot(1,2,1);
    survival(i) = show_raptorchase3([X(i), Y(i)]);
    subplot(1,2,2);
    %plot3(X(1:i), Y(1:i), survival(1:i));
    pcolor(survival);
    ylabel('Survival time (sec)');
    xlabel('Angle (radians)');
    drawnow;
end

