% Input:
% L: Matrix (containing row-wise direction vectors)
% results: Matrix
% directions: vector

% Output:
% L: Matrix (containing row-wise direction vectors)
% results: Matrix
% indexes: vector

% Description:
% Reduces L and results to the rows such that each row l from L contains
% only entries different from 0 in the dimensions specified through the
% vector directions.

% Beschreibung:
% Reduziert L und results auf die Zeilen, so dass die l aus L
% ausschließlich Einträge in den Dimensionen aus dem Vektor directions
% haben.

function [L,results, indexes] = selectDirectionsInSpace(L,results,directions)

%combi = [L, results];
ind = cell(1);
iterator = 0;

for i= 1:1:size(directions,1)
    for j=i+1:1:size(directions,1)
        iterator = iterator +1;
        [~,~,ind{iterator}] = selectDirectionsInPlane(L,results,directions(i),directions(j));
    end;
end;

indexes = [];
for i=1:1:iterator
    indexes = [indexes ind{i}];
end;

indexes = indexes';
indexes = unique(indexes,'rows');

L = L(indexes,:);
results = results(indexes,:);