


compute the mean width of a polytope in H-representation Syntax: meanWidth = computeMeanWidthHrep(hrep) computeMeanWidthHrep(.., zerotol) allows to set the tolerance for underlying algorithms (determining flat polytopes; default in elkZerotol). See also: computeMeanWidthHrep, computeVolumeVrep, computeFacetAreaVrep, computeFeretVrep, obtainMeasureInfo


0001 function meanWidth = computeMeanWidthHrep(hrep, zerotol) 0002 % compute the mean width of a polytope in H-representation 0003 % 0004 % Syntax: meanWidth = computeMeanWidthHrep(hrep) 0005 % 0006 % computeMeanWidthHrep(.., zerotol) allows to set the tolerance for 0007 % underlying algorithms (determining flat polytopes; default in 0008 % elkZerotol). 0009 % 0010 % See also: computeMeanWidthHrep, computeVolumeVrep, computeFacetAreaVrep, 0011 % computeFeretVrep, obtainMeasureInfo 0012 0013 % The elk-library: convex geometry applied to crystallization modeling. 0014 % Copyright (C) 2012 Alexander Reinhold 0015 % 0016 % This program is free software: you can redistribute it and/or modify it 0017 % under the terms of the GNU General Public License as published by the 0018 % Free Software Foundation, either version 3 of the License, or (at your 0019 % option) any later version. 0020 % 0021 % This program is distributed in the hope that it will be useful, but 0022 % WITHOUT ANY WARRANTY; without even the implied warranty of 0023 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0024 % General Public License for more details. 0025 % 0026 % You should have received a copy of the GNU General Public License along 0027 % with this program. If not, see <http://www.gnu.org/licenses/>. 0028 0029 % default zerotol 0030 if ~exist('zerotol', 'var') 0031 zerotol = elkZerotol; 0032 end 0033 0034 % check dimension 0035 if size(hrep.A, 2) > 3 0036 error('elk:polytope:inputError', ... 0037 'Only 1-, 2- or three dimensional polytopes can be handled'); 0038 elseif size(hrep.A, 2) == 2 0039 meanWidth = computeFacetAreaHrep(hrep, [], zerotol) / pi; 0040 return 0041 elseif size(hrep.A, 2) == 1 0042 meanWidth = computeVolumeHrep(hrep, zerotol); 0043 return 0044 end 0045 0046 % obtain edge-information 0047 hrep = normalizeHrep(reduceHrep(hrep)); 0048 vrep = convertHrepToVrep(hrep, zerotol); 0049 vrepReduced = reduceVrepDimension(vrep, zerotol); 0050 if size(vrepReduced.V, 2) < size(vrep.V, 2) 0051 meanWidth = computeMeanWidthVrep(vrepReduced, zerotol); 0052 if size(vrep.V, 2) == 3 && size(vrepReduced.V, 2) == 1 0053 meanWidth = 0.5*meanWidth; 0054 elseif size(vrep.V, 2) == 3 && size(vrepReduced.V, 2) == 2 0055 meanWidth = 0.25*pi*meanWidth; 0056 end 0057 else 0058 edgeStruct = computeEdgeSetVrep(vrep, 'hrep', hrep, ... 0059 'zerotol', zerotol, 'output', 'full'); 0060 % call mean width core algorithm 0061 meanWidth = computeMeanWidthCore(hrep, vrep, edgeStruct); 0062 end 0063