function HRepresentation
% H-representation of a polytope
%
% M. Herceg 2014, ETH Zurich,
% 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_2_b'];
close all

%% core code
% vertices
V = [-7.7 3.5; -4 6; 0.5 7.9; 7 8; 7.5 -5; -2.5 -8; -7.3 -1.9];
% construct polyhedron out of vertices
P = Polyhedron(V);
% extract hyperplane representation
H = P.A;
K = P.b;
h1 = plot(P,'Color',[0.9 0.9 0.9],'LineWidth',line_width);
grid on
hold on
for i = 1:size(H, 1)
    h = H(i, :);
    k = K(i);
    x1 = [-10 10];
    x2 = [(k-h(1)*x1(1))/h(2) (k-h(1)*x1(2))/h(2)];
    plot(x1, x2, 'k', 'LineWidth', line_width);
end
axis([-10 10 -10 10]);

%% save book figure
% 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);
set(gca,'YTickLabel',{''})
set(gca,'XTickLabel',{''})


% 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