genericNonlinearCondition

PURPOSE ^

compute minmal distance of projected extreme rays to cone

SYNOPSIS ^

function [distance emptyValue] = genericNonlinearCondition(x, grassStruct)

DESCRIPTION ^

 compute minmal distance of projected extreme rays to cone

 THIS IS NO USER FUNCTION

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [distance emptyValue] = genericNonlinearCondition(x, grassStruct)
0002 % compute minmal distance of projected extreme rays to cone
0003 %
0004 % THIS IS NO USER FUNCTION
0005 
0006 % The elk-library: convex geometry applied to crystallization modeling.
0007 %   Copyright (C) 2013 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 % Get the desired projection matrix
0023 projectionMatrix = computeProjectionFromGrass(x, grassStruct);
0024 
0025 % Take the enclosing extreme points of the data in scaled-PCA space and
0026 %   compute their projection:
0027 pointMatrixProjected = projectionMatrix * grassStruct.extremePointMatrix;
0028 
0029 if any(all(...
0030         grassStruct.coneNormalVectorMatrix' * pointMatrixProjected < 0 ...
0031         , 1))
0032     % all projected vectors are inside the cone, everything OK
0033     distance = 0;
0034         
0035     %! Debug:
0036 %     disp('validd')
0037 %     color = [0 1 0];
0038     %/
0039 else
0040     % some projected extreme ray is outside the cone - all
0041     % original to projected distances are:
0042     distanceVector = sqrt(sum((grassStruct.extremePointMatrix...
0043                              - pointMatrixProjected).^2, 1));
0044     % the shortest distance represents the distance of the current range of
0045     %   projection to a valid range of projection
0046     distance = min(distanceVector);
0047     
0048     %! Debug:
0049 %     disp('INVALID')
0050 %     color = [1 0 0];
0051     %/
0052 end
0053 
0054 if nargout > 1
0055     emptyValue = [];
0056 end
0057 
0058 %! Debug
0059 % global thisDbgPoint
0060 % set(thisDbgPoint, 'color', color, 'markerSize', 8)
0061 %/

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