% Input:
% omegas: cell array of function handles (support functions in flowpipe)
% results: matrix (containing evaluations of support functions)

% Output:
% clusterresults: vector (containing the row-wise maximum of results)
% cluseromegas: function handle (representing the clustered set)

% Description:
% computes the convex hull of the sets represented by results and omegas.

function [clusterresults,clusteromegas] = clustering(omegas, results)

% generate convex hull
clusterresults = max(results,[],2);

if ~isempty(omegas)
    clusteromegas = @(l) -Inf;
    for i=1:1:length(omegas)
        omega = omegas{i};
        clusteromegas = @(l) max(clusteromegas(l),omega(l));
    end;
else
    clusteromegas = [];
end;