0001 function collectiveStruct = computeCollectiveShapeStruct(hrep, zerotol)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 collectiveStruct(1).hrep = hrep;
0024 collectiveStruct(1).lambda = 0;
0025
0026 while ~isempty(collectiveStruct(end).hrep.A)
0027
0028 collectiveStruct(end).hrep = reduceHrep(collectiveStruct(end).hrep);
0029
0030
0031
0032 collectiveStruct(end).vrep = ...
0033 convertHrepToVrep(collectiveStruct(end).hrep, [], 1e5);
0034
0035
0036
0037
0038 if any(abs(collectiveStruct(end).vrep.V(:)) > 9e4) || ...
0039 (computeVolumeVrep(collectiveStruct(end).vrep) < 1e-3)
0040
0041 collectiveStruct(end).hrep = struct('A', [], 'h', []);
0042 collectiveStruct(end).vrep.V = [0 0];
0043 end
0044
0045
0046 [collectiveStruct(end).edgeLengthFunctional, ...
0047 collectiveStruct(end).vrepFunctional, ...
0048 collectiveStruct(end).incidenceMatrix] = ...
0049 computeEdgeLengthFunctional(collectiveStruct(end).hrep, ...
0050 collectiveStruct(end).vrep, zerotol);
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061 nEdge = size(collectiveStruct(end).hrep.A, 1);
0062 leftVector = collectiveStruct(end).edgeLengthFunctional(ones(nEdge, 1));
0063 rightVector = collectiveStruct(end).edgeLengthFunctional(...
0064 collectiveStruct(end).hrep.h);
0065 lambdaVector = rightVector ./ leftVector;
0066 [thisLambda thisRemIndex] = min(lambdaVector);
0067
0068
0069 if ~isempty(collectiveStruct(end).hrep.A)
0070 collectiveStruct(end+1).hrep = collectiveStruct(end).hrep;
0071 collectiveStruct(end).hrep.A(thisRemIndex, :) = [];
0072 collectiveStruct(end).hrep.h(thisRemIndex) = [];
0073 collectiveStruct(end).hrep.h = collectiveStruct(end).hrep.h - thisLambda;
0074 collectiveStruct(end).lambda = collectiveStruct(end-1).lambda + ...
0075 thisLambda;
0076 end
0077
0078 end