function PDiff
% Pontryagin difference
%
% M. Herceg, Automatic Control Laboratory, ETH Zurich 2014
% requires MPT3

close all
%% printing parameters
label_font_size = 14;
tick_font_size = 10;
line_width = 0.8;
axeswidth=0.2;
% create new folder for storing figures
mkdir('figures');
figure_name = ['.',filesep,'figures',filesep,'fig_4_8_a'];

%% core code
% unit boxes
Q = Polyhedron('lb',[-2;-2],'ub',[2;2]);
P = Polyhedron('lb',[-6;-6],'ub',[6;6]);
% Pontryagin difference of two boxes with different size
PmQ = P - Q;

% plot the result
h1 = plot(P,'Color', [0.9 0.9 0.9],'LineWidth',line_width);
hold on
h2 = plot(PmQ,'Color', [0.7 0.7 0.7],'LineWidth',line_width);
h3 = plot(Q,'Color', [0.5 0.5 0.5],'LineWidth',line_width);
axis([-9 9 -9 9]);
grid on


%% save book figures
% text in polytopes
ht1=text(-5, 5, '$\mathcal{P}$');
ht2=text(-3, 3, '$\mathcal{P}\ominus\mathcal{Q}$');
ht3=text(-0.5, 0, '$\mathcal{Q}$');
set(ht1, 'FontSize', label_font_size);
set(ht2, 'FontSize', label_font_size);
set(ht3, 'FontSize', label_font_size);

% custom axis labels & font size
hx = xlabel('$x_1$');
set(hx, 'FontSize', label_font_size);
hy = ylabel('$x_2$');
set(hy, 'FontSize', label_font_size);

% font size of tick labels
set(gca,'LineWidth',axeswidth)
set(gca,'FontSize', tick_font_size);
xl=[-6 -4 -2 2 4 6];
set(gca,'XTick',xl)
set(gca,'XTickLabel',num2str(xl'))
set(gca,'YTick',xl);
set(gca,'YTickLabel',num2str(xl'))


% generate FIG file
disp('Hit any key to print the figure and continue.');
pause
saveas(gcf, [figure_name '_matlab'], 'fig');

% print using laprint
laprint(gcf, [figure_name '_tex'],'scalefonts','off');

fprintf('Figure "%s" generated...\n', figure_name);

end