function [SHAPES] = shape3d(M,S,GIIDs); % SHAPE3d(M,S,GIIDs) ---- This function calculates the the 'shape' of each group in % field 'M', and modifies the measure so that it will return 1 for a perfect circle, % and higher values the more the group diverges from a circle. % % See 'shape' for details on the shape index. %Created by Jim Work, University of South Carolina, August 13th, 2003 % Initialize the SHAPES matrix, to be filled with the shape for each group. SHAPES = []; % Now, each group will be taken out, and the shape calculated. for i = 1:size(GIIDs,1) % Loop over each group. if size(GIIDs{i},2) > 3 % Convhull only works for more than 3 points % so any pairs/singles will be ignored. mxiid = max(GIIDs{i}); % Finds the max IID for the group. % Now, the group data will be pulled from the full array. GIND = S(i).members; % Indices of the group members found. GRP = []; % Initialize the GRP matrix. for p = 1:size(GIND,2) % Loops over all members. ind = GIND(1,p); % Gets individual index... IND = M(ind,:); % Pulls that row from array. GRP = [GRP; IND]; % And builds the group matrix, a subset of % the original M. end % Next, convhull finds the volume (V). [K V] = convhulln(GRP(:,2),GRP(:,3),GRP(:,4)); % And shape is calculated. shape = (mxiid^2) / V; % For pairs/stragglers, shape is set to a low number, so it can be ignored later. else shape = -999; end % Since the shape function returns (6/pi) for a circle, the index is now multiplied % by pi/6 to standardize it to a circle. shape = shape * (pi/6); % Builds SHAPES matrix, of each group's shape value. SHAPES = [SHAPES; shape]; end