


compute the triangulation of a convex cone given by its extreme rays THIS FUNCTION IS NO USER FUNCTION.


0001 function indexMatrix = computeTriangulationOfCone(extremeRayMatrix) 0002 % compute the triangulation of a convex cone given by its extreme rays 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 % special case 0023 % all the procedures below do not make sense for a cone in 1D and the 0024 % convhulln crashes. in these cases extremRayMatrix is a 1x1 matrix. 0025 if numel(extremeRayMatrix) == 1 0026 indexMatrix = 1; 0027 return 0028 end 0029 0030 % normalize to plane 0031 normalVector = mean(extremeRayMatrix, 1); 0032 normalVector = normalVector / norm(normalVector); 0033 for iRay = 1:size(extremeRayMatrix, 1) 0034 extremeRayMatrix(iRay, :) = extremeRayMatrix(iRay, :) / ... 0035 (extremeRayMatrix(iRay, :) * normalVector'); 0036 end 0037 0038 % use convex hull to calculate the triangulation of the surface 0039 indexMatrix = convhulln(... 0040 [zeros(1, size(extremeRayMatrix, 2)); extremeRayMatrix], ... 0041 {'Qt', 'Qs'}); 0042 0043 % throw away any patch that contains the origin 0044 indexMatrix(sum(indexMatrix == 1, 2) > 0, :) = []; 0045 indexMatrix = indexMatrix - 1;