reduceVrepDimension

PURPOSE ^

project lower dimensional (flat) polytope into embedding space

SYNOPSIS ^

function varargout = reduceVrepDimension(vrep, zerotol)

DESCRIPTION ^

 project lower dimensional (flat) polytope into embedding space

 Syntax: vrep = reduceVrepDimension(vrep, zerotol)
   or    [vrep, rot, x0] = reduceVrepDimension(vrep, zerotol)
 
 If the polytope vrep has a lower dimension r<n than the space it is
   embedded in, this fucntion moves and rotates the polytope such that the
   values for the last (n-r) coordinate axes are zero for all points in
   vrep.

 The zerotol determines how flat a polytope must be to be recognized.
   Points can be approximately a distance of zerotol away from the flat
   polytope. Default: see elkZerotol.

 With the second syntax, the rotation matrix rot and the offset x0 is
   returned so that the original polytope can be obtained by:
     removedCoordinates = zeros(size(vrep, 1), size(V, 1) - size(vrep, 2));
     vrepOriginal = [vrep, removedCoordinates]*rot';
     vrepOriginal = moveVrep(vrepOriginal, x0);

 See also: reduceVrep, scaleVrep

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = reduceVrepDimension(vrep, zerotol)
0002 % project lower dimensional (flat) polytope into embedding space
0003 %
0004 % Syntax: vrep = reduceVrepDimension(vrep, zerotol)
0005 %   or    [vrep, rot, x0] = reduceVrepDimension(vrep, zerotol)
0006 %
0007 % If the polytope vrep has a lower dimension r<n than the space it is
0008 %   embedded in, this fucntion moves and rotates the polytope such that the
0009 %   values for the last (n-r) coordinate axes are zero for all points in
0010 %   vrep.
0011 %
0012 % The zerotol determines how flat a polytope must be to be recognized.
0013 %   Points can be approximately a distance of zerotol away from the flat
0014 %   polytope. Default: see elkZerotol.
0015 %
0016 % With the second syntax, the rotation matrix rot and the offset x0 is
0017 %   returned so that the original polytope can be obtained by:
0018 %     removedCoordinates = zeros(size(vrep, 1), size(V, 1) - size(vrep, 2));
0019 %     vrepOriginal = [vrep, removedCoordinates]*rot';
0020 %     vrepOriginal = moveVrep(vrepOriginal, x0);
0021 %
0022 % See also: reduceVrep, scaleVrep
0023 
0024 % The elk-library: convex geometry applied to crystallization modeling.
0025 %   Copyright (C) 2012 Alexander Reinhold
0026 %
0027 % This program is free software: you can redistribute it and/or modify it
0028 %   under the terms of the GNU General Public License as published by the
0029 %   Free Software Foundation, either version 3 of the License, or (at your
0030 %   option) any later version.
0031 %
0032 % This program is distributed in the hope that it will be useful, but
0033 %   WITHOUT ANY WARRANTY; without even the implied warranty of
0034 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0035 %   General Public License for more details.
0036 %
0037 % You should have received a copy of the GNU General Public License along
0038 %   with this program.  If not, see <http://www.gnu.org/licenses/>.
0039 
0040 %% input
0041 if ~exist('zerotol', 'var')
0042     zerotol = elkZerotol;
0043 end
0044 
0045 %% ensure zero mean of points
0046 vrepDim = size(vrep.V, 2);
0047 x0 = mean(vrep.V, 1);
0048 vrepMoved = moveVrep(vrep, -1*x0);
0049 
0050 %% singular value decomposition
0051 [u, s, rot] = svd(vrepMoved.V, 0);
0052 filter = abs(diag(s)) >= zerotol;
0053 
0054 %% assign output
0055 % and do nothing whenever there was no reduction
0056 if sum(filter) == vrepDim
0057     x0 = zeros(1, vrepDim);
0058     rot = diag(ones(1, vrepDim));
0059     varargout{1} = vrep;
0060 else
0061     varargout{1} = vrepMoved.V*rot;
0062     varargout{1} = struct('V', varargout{1}(:, filter));
0063 end
0064 
0065 if nargout == 3
0066     varargout{2} = rot;
0067     varargout{3} = x0;
0068 end

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