identifyPolytope

PURPOSE ^

returns basic information on the geometric object

SYNOPSIS ^

function info = identifyPolytope(input)

DESCRIPTION ^

 returns basic information on the geometric object

 Syntax: info = identifyiPolytope(input)

 Where info is a structure containing:
   info.dim - dimension of polytope
   info.rep - the representation of the input
   info.m   - dependent on representation: number of vertices or number of
              facets.

 The possible representations are:
   Hrep: H-representation. The variable is a struct with two fields. An m 
         by n matrix A containing the facet normals and an m by 1 vector h
         containing the corresponding facet distances.
   Vrep: V-representation. The variable is a struct with one field. An m
         by n matrix containing the vertices for which the convex hull
         represents the polytope.

 see also: obtainPolytope

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function info = identifyPolytope(input)
0002 % returns basic information on the geometric object
0003 %
0004 % Syntax: info = identifyiPolytope(input)
0005 %
0006 % Where info is a structure containing:
0007 %   info.dim - dimension of polytope
0008 %   info.rep - the representation of the input
0009 %   info.m   - dependent on representation: number of vertices or number of
0010 %              facets.
0011 %
0012 % The possible representations are:
0013 %   Hrep: H-representation. The variable is a struct with two fields. An m
0014 %         by n matrix A containing the facet normals and an m by 1 vector h
0015 %         containing the corresponding facet distances.
0016 %   Vrep: V-representation. The variable is a struct with one field. An m
0017 %         by n matrix containing the vertices for which the convex hull
0018 %         represents the polytope.
0019 %
0020 % see also: obtainPolytope
0021 
0022 % The elk-library: convex geometry applied to crystallization modeling.
0023 %   Copyright (C) 2012 Alexander Reinhold
0024 %
0025 % This program is free software: you can redistribute it and/or modify it
0026 %   under the terms of the GNU General Public License as published by the
0027 %   Free Software Foundation, either version 3 of the License, or (at your
0028 %   option) any later version.
0029 %
0030 % This program is distributed in the hope that it will be useful, but
0031 %   WITHOUT ANY WARRANTY; without even the implied warranty of
0032 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0033 %   General Public License for more details.
0034 %
0035 % You should have received a copy of the GNU General Public License along
0036 %   with this program.  If not, see <http://www.gnu.org/licenses/>.
0037 
0038 %% Some list
0039 if iscell(input)
0040     info = identifyPolytopeList(input);
0041 %% H-representation
0042 elseif isstruct(input) && isfield(input, 'A') && isfield(input, 'h') && ...
0043         ismatrix(input.A) && isvector(input.h)
0044     info.rep = 'Hrep';
0045     info.dim = size(input.A, 2);
0046     info.m   = size(input.A, 1);
0047     %% Consistency checks
0048     assert(size(input.h, 2) == 1, 'elk:polytope:wrongType', ...
0049         'The vector of facet distances should be a column vector');
0050     assert(size(input.h, 1) == size(input.A, 1), 'elk:polytope:wrongType', ...
0051         'matrix of facet normals does not match the vector of facet distances')
0052 %% V-representation
0053 elseif isstruct(input) && isfield(input, 'V') && ...
0054         ismatrix(input.V) && isnumeric(input.V) 
0055     info.rep = 'Vrep';
0056     info.dim = size(input.V, 2);
0057     info.m   = size(input.V, 1);
0058 %% No supportet representation
0059 else
0060     error('elk:polytope:wrongType', ...
0061         'check the geometric representation of the input');
0062 end

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