computeProjectionAreaVrep

PURPOSE ^

projection area of a V-polytope

SYNOPSIS ^

function area = computeProjectionAreaVrep(vrep, dirMatrix, zerotol)

DESCRIPTION ^

 projection area of a V-polytope

 Syntax: area = computeProjectionAreaVrep(vrep, dirMatrix)

 This function calculates a vector of projection areas for all directions
   in dirMatrix that contains one direction in each row.

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

 See also: computeProjectionAreaHrep, computeVolumeVrep,
   computeFacetAreaVrep, computeFeretVrep, computeSupportValueVrep

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function area = computeProjectionAreaVrep(vrep, dirMatrix, zerotol)
0002 % projection area of a V-polytope
0003 %
0004 % Syntax: area = computeProjectionAreaVrep(vrep, dirMatrix)
0005 %
0006 % This function calculates a vector of projection areas for all directions
0007 %   in dirMatrix that contains one direction in each row.
0008 %
0009 % computeProjectionAreaVrep(..., zerotol) allows to set the tolerance for
0010 %   underlying algorithms (e.g. determining flat polytopes; default in
0011 %   elkZerotol).
0012 %
0013 % See also: computeProjectionAreaHrep, computeVolumeVrep,
0014 %   computeFacetAreaVrep, computeFeretVrep, computeSupportValueVrep
0015 
0016 % The elk-library: convex geometry applied to crystallization modeling.
0017 %   Copyright (C) 2012 Alexander Reinhold
0018 %
0019 % This program is free software: you can redistribute it and/or modify it
0020 %   under the terms of the GNU General Public License as published by the
0021 %   Free Software Foundation, either version 3 of the License, or (at your
0022 %   option) any later version.
0023 %
0024 % This program is distributed in the hope that it will be useful, but
0025 %   WITHOUT ANY WARRANTY; without even the implied warranty of
0026 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0027 %   General Public License for more details.
0028 %
0029 % You should have received a copy of the GNU General Public License along
0030 %   with this program.  If not, see <http://www.gnu.org/licenses/>.
0031 
0032 %% Input handling
0033 % default zerotol
0034 if ~exist('zerotol', 'var')
0035     zerotol = elkZerotol;
0036 end
0037 
0038 % check dimension
0039 if size(vrep.V, 2) == 3
0040     % everything OK, that is the normal case
0041 elseif size(vrep.V, 2) == 2
0042     % we use the maximum and minimum projection onto the given line
0043     % normalize dir matrix
0044     dirMatrix = bsxfun(@times, ...
0045         1./sqrt(sum(dirMatrix.^2, 2)), ...
0046         dirMatrix);
0047     projectionLengthVector = dirMatrix * vrep.V';
0048     area = max(projectionLengthVector, [], 2) - min(projectionLengthVector, [], 2);
0049     return
0050 elseif size(vrep.V, 2) == 1
0051     % this is trivial
0052     area = 0;
0053     return
0054 else
0055     error('elk:polytope:inputError', ...
0056           'Only three dimensional polytopes can be handled');
0057 end
0058 
0059 %% do for each facet
0060 area = zeros(1,size(dirMatrix, 1));
0061 for iFacet = 1:size(dirMatrix, 1)
0062     % Get support set in direction
0063     projectedVrep = projectVrep3d(vrep, dirMatrix(iFacet, :));
0064     % Calculate volume of support set (2-D Volume)
0065     area(iFacet) = computeVolumeVrep(projectedVrep, zerotol);
0066 end

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