addMinkowskiPolytope

PURPOSE ^

calculate the Minkowski sum of polytopes

SYNOPSIS ^

function polySum = addMinkowskiPolytope(varargin)

DESCRIPTION ^

 calculate the Minkowski sum of polytopes

 Syntax: polySum = addMinkowskiPolytope(poly1, poly2, ..)

 The output is returned in the representation of the first input polytope.

 Please consider using V-representation only, because Minkowski addition 
   is only efficiently performed in this representation.

 You can specify the zerotol for addMinkowskiVrep by an option/value pair:
     addMinkowskiPolytope('zerotol', 1e-8, ..).
   this zerotol is applied for all additions that follow the definition of
   zerotol. Default: see elkZerotol.
 
 See also: convertPolytope, obtainPolytope, addMinkowskiVrep

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function polySum = addMinkowskiPolytope(varargin)
0002 % calculate the Minkowski sum of polytopes
0003 %
0004 % Syntax: polySum = addMinkowskiPolytope(poly1, poly2, ..)
0005 %
0006 % The output is returned in the representation of the first input polytope.
0007 %
0008 % Please consider using V-representation only, because Minkowski addition
0009 %   is only efficiently performed in this representation.
0010 %
0011 % You can specify the zerotol for addMinkowskiVrep by an option/value pair:
0012 %     addMinkowskiPolytope('zerotol', 1e-8, ..).
0013 %   this zerotol is applied for all additions that follow the definition of
0014 %   zerotol. Default: see elkZerotol.
0015 %
0016 % See also: convertPolytope, obtainPolytope, addMinkowskiVrep
0017 
0018 % The elk-library: convex geometry applied to crystallization modeling.
0019 %   Copyright (C) 2012 Alexander Reinhold
0020 %
0021 % This program is free software: you can redistribute it and/or modify it
0022 %   under the terms of the GNU General Public License as published by the
0023 %   Free Software Foundation, either version 3 of the License, or (at your
0024 %   option) any later version.
0025 %
0026 % This program is distributed in the hope that it will be useful, but
0027 %   WITHOUT ANY WARRANTY; without even the implied warranty of
0028 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0029 %   General Public License for more details.
0030 %
0031 % You should have received a copy of the GNU General Public License along
0032 %   with this program.  If not, see <http://www.gnu.org/licenses/>.
0033 
0034 %! ToDo: Zerotol option.
0035 
0036 zerotol = elkZerotol;
0037 jumpLoop = 0;
0038 firstPoly = 1;
0039 for iInput = 1:nargin
0040     
0041     %% Handle possible options
0042     if jumpLoop
0043         jumpLoop = 0;
0044         continue;
0045     end
0046     
0047     if strcmpi(varargin{iInput}, 'zerotol')
0048         jumpLoop = 1;
0049         firstPoly = firstPoly + 2;
0050         zerotol = varargin{iInput+1};
0051         continue;
0052     end
0053     
0054     %% Input handling
0055     infoInput = identifyPolytope(varargin{iInput});
0056     
0057     if iInput == firstPoly
0058         repOut = infoInput.rep;
0059         switch infoInput.rep
0060             case 'Vrep'
0061                 vrepSum = varargin{iInput};
0062             case 'Hrep'
0063                 vrepSum = convertHrepToVrep(varargin{iInput}, zerotol, inf);
0064         end
0065         continue
0066     end
0067     
0068     switch infoInput.rep
0069         case 'Vrep'
0070             vrepSum = addMinkowskiVrep(vrepSum, varargin{iInput});
0071         case 'Hrep'
0072             vrepSum = addMinkowskiVrep(vrepSum, ...
0073                 convertHrepToVrep(varargin{iInput}, zerotol, inf));
0074     end
0075 end
0076 
0077 switch repOut
0078     case 'Vrep'
0079         polySum = vrepSum;
0080     case 'Hrep'
0081         polySum = convertVrepToHrep(vrepSum, zerotol);
0082 end
0083 
0084 end

Generated on Sat 18-Jul-2015 16:45:31 by m2html © 2005