


calculate the dual polytope
Syntax: dual = computeDualPolytope(polytope)
or dual = computeDualPolytope(polytope, rep)
The dual of a point is a hyperplane and vice versa. In that way the
extreme points of a V-representation can be mapped to the halfspaces of
a dual polytope. For the polytope and the dual polytope there exists a
one-to-one relationship of extreme points and hyperplanes. Especially
the following terms are equivalent by duality:
* a hyperplane is uniquely determined by n linearly independent
points
* n linearly independent hyperplanes intersect in a single point
Usually, if a H-representation is provided, a V-representation is
returned and vice versa. Using rep, you can specify the output
representation directly. Use [] or '' to maintain the default behavior.
The dual mapping is connected to the unit sphere. Hyperplanes that
intersect the sphere (do not intersect; touch) are mapped to points
outside (inside; on the circumfence) of the sphere and vice versa. For
this mapping the following must be considered:
* no point of a V-representation is equal to the origin. This would
map to an hyperplane at infinity.
* no facet distance equals zero. This would map to a point at
infinity.
See also: scaleVrep, scaleHrep, normalizeHrep

0001 function dual = computeDualPolytope(poly, rep) 0002 % calculate the dual polytope 0003 % 0004 % Syntax: dual = computeDualPolytope(polytope) 0005 % or dual = computeDualPolytope(polytope, rep) 0006 % 0007 % The dual of a point is a hyperplane and vice versa. In that way the 0008 % extreme points of a V-representation can be mapped to the halfspaces of 0009 % a dual polytope. For the polytope and the dual polytope there exists a 0010 % one-to-one relationship of extreme points and hyperplanes. Especially 0011 % the following terms are equivalent by duality: 0012 % * a hyperplane is uniquely determined by n linearly independent 0013 % points 0014 % * n linearly independent hyperplanes intersect in a single point 0015 % 0016 % Usually, if a H-representation is provided, a V-representation is 0017 % returned and vice versa. Using rep, you can specify the output 0018 % representation directly. Use [] or '' to maintain the default behavior. 0019 % 0020 % The dual mapping is connected to the unit sphere. Hyperplanes that 0021 % intersect the sphere (do not intersect; touch) are mapped to points 0022 % outside (inside; on the circumfence) of the sphere and vice versa. For 0023 % this mapping the following must be considered: 0024 % * no point of a V-representation is equal to the origin. This would 0025 % map to an hyperplane at infinity. 0026 % * no facet distance equals zero. This would map to a point at 0027 % infinity. 0028 % 0029 % See also: scaleVrep, scaleHrep, normalizeHrep 0030 0031 % The elk-library: convex geometry applied to crystallization modeling. 0032 % Copyright (C) 2012 Alexander Reinhold 0033 % 0034 % This program is free software: you can redistribute it and/or modify it 0035 % under the terms of the GNU General Public License as published by the 0036 % Free Software Foundation, either version 3 of the License, or (at your 0037 % option) any later version. 0038 % 0039 % This program is distributed in the hope that it will be useful, but 0040 % WITHOUT ANY WARRANTY; without even the implied warranty of 0041 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0042 % General Public License for more details. 0043 % 0044 % You should have received a copy of the GNU General Public License along 0045 % with this program. If not, see <http://www.gnu.org/licenses/>. 0046 0047 %% Input 0048 infoPolytope = identifyPolytope(poly); 0049 if ~exist('rep', 'var') || isempty(rep) 0050 switch infoPolytope.rep 0051 case 'Hrep' 0052 rep = 'Vrep'; 0053 case 'Vrep' 0054 rep = 'Hrep'; 0055 end 0056 end 0057 0058 switch infoPolytope.rep 0059 case 'Hrep' 0060 for iFacet = 1:infoPolytope.m 0061 poly.A(iFacet,:) = poly.A(iFacet,:) / ... 0062 poly.h(iFacet); 0063 poly.h(iFacet) = 1; 0064 end 0065 dual.V = poly.A; 0066 case 'Vrep' 0067 dual.A = poly.V; 0068 dual.h = ones(infoPolytope.m, 1); 0069 dual = normalizeHrep(dual); 0070 end 0071 0072 dual = convertPolytope(dual, rep); 0073 0074 end