convertPolytope

PURPOSE ^

converting a polytope between V-representation and H-representation

SYNOPSIS ^

function polyConverted = convertPolytope(polyInput, targetRep, varargin)

DESCRIPTION ^

 converting a polytope between V-representation and H-representation

 Syntax: polyConverted = convertPolytope(polyInput, targetRep)

 This function converts an arbitrary polytope representation (PtInput)
   into the representation given by the string targetRep. Possible 
   strings for representations are:
      Vrep - V-representation (convex hull or extreme points)
      Hrep - H-representation (halfspaces)

 convertPolytope(.., 'zerotol', zerotol) lets you specify the zerotol that
   is used to identify values that are close to zero by zero (default is 
   elkZerotol).

 convertPolytope(.., 'flatness', flatness) the parameter flatness is only 
   applied if the dimension of the object is smaller than the dimension it
   is embedded in (e.g. a 2D object in 3D space). The flatness is applied 
   by adding [flatness/2] to all facet distances for which the 
   corresponding hyperplane fully contains the polytope. Default: 0.

 convertPolytope(.., 'infinityBoxSize', size) is used only when the given
   H-representation is unbounded. In that case the V-representation of the
   intersection of the original object with an infinity box is calculated. 
   The infinity box is a hypercube, centered at the origin and extending
   to [-1, 1] for each dimension.

 convertPolytope(.., 'useCddlib', useCddlib) is a switch that enforces or
   prevents from using the double-description method (cddlib) as a basis
   for converions. The alternative is always tried, anyway.
 
 See also: identifyPolytope, obtainPolytope, convertVrepToHrep,
   convertHrepToVrep

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function polyConverted = convertPolytope(polyInput, targetRep, varargin)
0002 % converting a polytope between V-representation and H-representation
0003 %
0004 % Syntax: polyConverted = convertPolytope(polyInput, targetRep)
0005 %
0006 % This function converts an arbitrary polytope representation (PtInput)
0007 %   into the representation given by the string targetRep. Possible
0008 %   strings for representations are:
0009 %      Vrep - V-representation (convex hull or extreme points)
0010 %      Hrep - H-representation (halfspaces)
0011 %
0012 % convertPolytope(.., 'zerotol', zerotol) lets you specify the zerotol that
0013 %   is used to identify values that are close to zero by zero (default is
0014 %   elkZerotol).
0015 %
0016 % convertPolytope(.., 'flatness', flatness) the parameter flatness is only
0017 %   applied if the dimension of the object is smaller than the dimension it
0018 %   is embedded in (e.g. a 2D object in 3D space). The flatness is applied
0019 %   by adding [flatness/2] to all facet distances for which the
0020 %   corresponding hyperplane fully contains the polytope. Default: 0.
0021 %
0022 % convertPolytope(.., 'infinityBoxSize', size) is used only when the given
0023 %   H-representation is unbounded. In that case the V-representation of the
0024 %   intersection of the original object with an infinity box is calculated.
0025 %   The infinity box is a hypercube, centered at the origin and extending
0026 %   to [-1, 1] for each dimension.
0027 %
0028 % convertPolytope(.., 'useCddlib', useCddlib) is a switch that enforces or
0029 %   prevents from using the double-description method (cddlib) as a basis
0030 %   for converions. The alternative is always tried, anyway.
0031 %
0032 % See also: identifyPolytope, obtainPolytope, convertVrepToHrep,
0033 %   convertHrepToVrep
0034 
0035 % The elk-library: convex geometry applied to crystallization modeling.
0036 %   Copyright (C) 2012 Alexander Reinhold
0037 %
0038 % This program is free software: you can redistribute it and/or modify it
0039 %   under the terms of the GNU General Public License as published by the
0040 %   Free Software Foundation, either version 3 of the License, or (at your
0041 %   option) any later version.
0042 %
0043 % This program is distributed in the hope that it will be useful, but
0044 %   WITHOUT ANY WARRANTY; without even the implied warranty of
0045 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0046 %   General Public License for more details.
0047 %
0048 % You should have received a copy of the GNU General Public License along
0049 %   with this program.  If not, see <http://www.gnu.org/licenses/>.
0050 
0051 %% Input handling
0052 infoInput = identifyPolytope(polyInput);
0053 
0054 [zerotol, flatness, infinityBoxSize, useCddlib] = mapOption(varargin, ...
0055     'zerotol', elkZerotol, ...
0056     'flatness', 0, ...
0057     'infinityBoxSize', inf, ...
0058     'useCddlib', 1);
0059 
0060 
0061 %% conversion
0062 if strcmpi(infoInput.rep, targetRep)
0063     polyConverted = polyInput;
0064     
0065 elseif strcmpi(infoInput.rep, 'Vrep') && strcmpi(targetRep, 'Hrep')
0066     polyConverted = convertVrepToHrep(polyInput, zerotol, flatness, useCddlib);
0067 
0068 elseif strcmpi(infoInput.rep, 'Hrep') && strcmpi(targetRep, 'Vrep')
0069     polyConverted = convertHrepToVrep(polyInput, zerotol, infinityBoxSize, useCddlib);
0070     
0071 else
0072     error('elk:polytope:wrongType', ...
0073         ['Check representation of input polytope; ' ...
0074          'Check name of target representation; ' ...
0075          'Check if conversion is supported']);
0076 end

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