computeMeanWidthVrep

PURPOSE ^

compute the mean width of a polytope in V-representation

SYNOPSIS ^

function meanWidth = computeMeanWidthVrep(vrep, zerotol)

DESCRIPTION ^

 compute the mean width of a polytope in V-representation

 Syntax: meanWidth = computeMeanWidthVrep(vrep)

 computeMeanWidthHrep(.., zerotol) allows to set the tolerance for 
   underlying algorithms (determining flat polytopes; default in
   elkZerotol).

 See also: computeMeanWidthHrep, computeVolumeHrep, computeFacetAreaHrep,
   computeFeretHrep, obtainMeasureInfo

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function meanWidth = computeMeanWidthVrep(vrep, zerotol)
0002 % compute the mean width of a polytope in V-representation
0003 %
0004 % Syntax: meanWidth = computeMeanWidthVrep(vrep)
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, computeVolumeHrep, computeFacetAreaHrep,
0011 %   computeFeretHrep, 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(vrep.V, 2) > 3
0036     error('elk:polytope:inputError', ...
0037         'Only 1-, 2- or three dimensional polytopes can be handled');
0038 elseif size(vrep.V, 2) == 2
0039     meanWidth = computeFacetAreaVrep(vrep, [], zerotol) / pi;
0040     return
0041 elseif size(vrep.V, 2) == 1
0042     meanWidth = computeVolumeVrep(vrep, zerotol);
0043     return
0044 elseif size(vrep.V, 2) == 0
0045     meanWidth = 0;
0046     return
0047 end
0048 % from here on, we only treat 3D polytopes
0049     
0050 % obtain edge-information
0051 hrep = convertVrepToHrep(vrep, zerotol);
0052 vrepReduced = reduceVrepDimension(vrep, zerotol);
0053 
0054 if size(vrepReduced.V, 2) < size(vrep.V, 2)
0055     meanWidth = computeMeanWidthVrep(vrepReduced, zerotol);
0056     if size(vrep.V, 2) == 3 && size(vrepReduced.V, 2) == 1
0057         meanWidth = 0.5*meanWidth;
0058     elseif size(vrep.V, 2) == 3 && size(vrepReduced.V, 2) == 2
0059         meanWidth = 0.25*pi*meanWidth;
0060     end
0061 else
0062     edgeStruct = computeEdgeSetVrep(vrep, 'hrep', hrep, ...
0063         'zerotol', zerotol, 'output', 'full');
0064     % call mean width core algorithm
0065     meanWidth = computeMeanWidthCore(hrep, vrep, edgeStruct);
0066 end

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