


convert the H-representation of a polytope into V-representation Syntax: vrep = convertHrepToVrep(hrep, zerotol, infinityBoxSize) The input should already be scaled by calling function. Consider that cddlib applies an additional zerotol that is stored in the function zerotolCddlib during initialization of this library (buildCddlib). THIS FUNCTION IS NO USER FUNCTION.


0001 function vrep = convertHrepToVrepByCddlib(hrep, maxTrial) 0002 % convert the H-representation of a polytope into V-representation 0003 % 0004 % Syntax: vrep = convertHrepToVrep(hrep, zerotol, infinityBoxSize) 0005 % 0006 % The input should already be scaled by calling function. 0007 % 0008 % Consider that cddlib applies an additional zerotol that is stored in the 0009 % function zerotolCddlib during initialization of this library 0010 % (buildCddlib). 0011 % 0012 % THIS FUNCTION IS NO USER FUNCTION. 0013 0014 % The elk-library: convex geometry applied to crystallization modeling. 0015 % Copyright (C) 2012 Alexander Reinhold 0016 % 0017 % This program is free software: you can redistribute it and/or modify it 0018 % under the terms of the GNU General Public License as published by the 0019 % Free Software Foundation, either version 3 of the License, or (at your 0020 % option) any later version. 0021 % 0022 % This program is distributed in the hope that it will be useful, but 0023 % WITHOUT ANY WARRANTY; without even the implied warranty of 0024 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0025 % General Public License for more details. 0026 % 0027 % You should have received a copy of the GNU General Public License along 0028 % with this program. If not, see <http://www.gnu.org/licenses/>. 0029 0030 %% conversion 0031 % the try/catch environment and while-loop is connected to a currently 0032 % "strange" numerical behavior of cddlib. It seems to be sensitive to 0033 % slight adjustments of the input (e.g. scaling). 0034 callCddLibLoop = 1; 0035 extraScalingVector = [1 (0.1 + linspace(0, 0.8, maxTrial-1))]; 0036 thisExtraScaling = extraScalingVector(1); 0037 hrepExtraScaled = hrep; 0038 while callCddLibLoop 0039 try 0040 resCddlib = callCddLib('extreme', ... 0041 struct('A', hrepExtraScaled.A, 'B', hrepExtraScaled.h)); 0042 callCddLibLoop = 0; 0043 catch dumpError 0044 callCddLibLoop = callCddLibLoop + 1; 0045 if callCddLibLoop > maxTrial 0046 % we don't want to rethrow the error message that would be: 0047 % "CDD returned an error, see above(!) for details", instead we 0048 % use: 0049 error('elk:polytope:conversion', ['cddlib (MEX-interface) ' ... 0050 'returned an error']); 0051 end 0052 thisExtraScaling = extraScalingVector(callCddLibLoop); 0053 hrepExtraScaled = stretchHrep(hrep, thisExtraScaling); 0054 end 0055 end 0056 % strip everything except field V 0057 vrepExtraScaled = struct('V', resCddlib.V); 0058 0059 % failure if there are rays (unbounded polytope) 0060 if ~isempty(resCddlib.R) 0061 vrep = []; 0062 else 0063 if thisExtraScaling ~= 1 0064 vrep = stretchVrep(vrep, 1/thisExtraScaling); 0065 else 0066 vrep = vrepExtraScaled; 0067 end 0068 end