function stretchedPoly = stretchPolytope(poly, scale, x0)
% stretch the polytope in arbitrary representation along axes
%
% Syntax: stretchedPoly = stretchPolytope(poly, scale)
%
% The vector v must be a vector that matches the dimentsion of the polytope 
%   Vrep. First element stretches coordinates at the x-axis, second element
%   on the y-axis and so on.
%
% With stretchPolytope(Hrep, scale, x0) the polytope is stretched with x0 
%   as origin. If x0 is a point of the polytope this point remains at its
%   position after stretching.
% 
% See also: obtainPolytope, movePolytope, rotatePolytope

% The elk-library: convex geometry applied to crystallization modeling.
%   Copyright (C) 2012 Alexander Reinhold
%
% This program is free software: you can redistribute it and/or modify it 
%   under the terms of the GNU General Public License as published by the 
%   Free Software Foundation, either version 3 of the License, or (at your 
%   option) any later version.
%
% This program is distributed in the hope that it will be useful, but 
%   WITHOUT ANY WARRANTY; without even the implied warranty of 
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
%   General Public License for more details.
%
% You should have received a copy of the GNU General Public License along 
%   with this program.  If not, see <http://www.gnu.org/licenses/>.

%% Input handling
infoP = identifyPolytope(poly);

%% set fixedpoint, if not specified
if nargin < 3
    x0 = zeros(infoP.dim, 1);
end

%% conversion
if strcmpi(infoP.rep, 'Vrep')
    stretchedPoly = stretchVrep(poly, scale, x0);
else
    stretchedPoly = stretchHrep(poly, scale, x0);
end

end
