


data to identify valid hC-vectors THIS FUNCTION IS NO USER FUNCTION.


0001 function dec = addValidityCone(dec, validityConeNormalMatrix, zerotol) 0002 % data to identify valid hC-vectors 0003 % 0004 % THIS FUNCTION IS NO USER FUNCTION. 0005 0006 % The elk-library: convex geometry applied to crystallization modeling. 0007 % Copyright (C) 2012 Alexander Reinhold 0008 % 0009 % This program is free software: you can redistribute it and/or modify it 0010 % under the terms of the GNU General Public License as published by the 0011 % Free Software Foundation, either version 3 of the License, or (at your 0012 % option) any later version. 0013 % 0014 % This program is distributed in the hope that it will be useful, but 0015 % WITHOUT ANY WARRANTY; without even the implied warranty of 0016 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0017 % General Public License for more details. 0018 % 0019 % You should have received a copy of the GNU General Public License along 0020 % with this program. If not, see <http://www.gnu.org/licenses/>. 0021 0022 %% generate validityCone (irredundant H-rep) 0023 % we only need unique rows 0024 validityConeNormalMatrix = unique(validityConeNormalMatrix, 'rows'); 0025 % hrep data 0026 %! DEV: reduceHrep did not work out for one case, it reduced 4D A matrix to 0027 % only 3 rows even though when computing the extreme rays from the full 0028 % matrix, it results in 4 properly spanning rays. 0029 % Hence, the reduce step is ignored which should not do much harm in 0030 % applications. 0031 dec.validityCone = struct('A', validityConeNormalMatrix, ... 0032 'h', zeros(size(validityConeNormalMatrix, 1), 1)... 0033 ); 0034 % dec.validityCone = reduceHrep(dec.validityCone); 0035 dec.validityCone = normalizeHrep(dec.validityCone); 0036 0037 % vrep data (rays) 0038 rayMatrix = computeExtremeRaysFromCone(dec.validityCone.A, zerotol); 0039 0040 if isempty(rayMatrix) 0041 %% empty validity cone 0042 % this happens only in the context of projectDec, where it is expected 0043 % to initialize the following variables with proper sizes. 0044 dec.se = zeros(0, dec.nC); 0045 dec.nS = 0; 0046 dec.validityCone.seIndexVector = []; 0047 dec.centerRay = zeros(1, dec.nC); 0048 dec.seScaledToClose = dec.se; 0049 dec.validityCone.volume = 0; 0050 0051 else 0052 % enter more SE data 0053 dec.se = scaleToReal(rayMatrix, dec, zerotol); 0054 dec.nS = size(rayMatrix, 1); 0055 dec.validityCone.seIndexVector = 1:dec.nS; 0056 0057 % center ray 0058 dec.centerRay = mean(dec.se, 1)'; 0059 dec.centerRay = dec.centerRay / norm(dec.centerRay, 2); 0060 % calculate SEs as they actually close the validity cone 0061 dec.seScaledToClose = scaleToClose(rayMatrix, dec); 0062 0063 % volume computation is based on V-representation so we use the structuring 0064 % elements and the origin as generating points. 0065 dec.validityCone.volume = computeVolumeHrep(closeCone(dec.validityCone, ... 0066 dec.centerRay)); 0067 end