% Input:
% dimensions: integer
% angle: double

% Output;
% L: Matrix (N x dimensions)

% Description:
% Generates a matrix with direction vectors for each plane in a 
% multidimensional space, specified through "dimensions". The angle between
% successively generated vectors in one plane is of size "angle".
% The generated vectores are stored row-wise in the output matrix

function [L] = vectorgeneratorEXT(dimensions, angle)
global precision;
numberofdirections = 0;
L = [];

for i=1:1:dimensions
    
    for j=i+1:1:dimensions    
        % i,j describes all possible dimension-pairs (planes in exactly 2 dimensions)
        
        start = zeros(dimensions,1);    % start vector for the rotation
        start(i,1) = 1;                 % is of length 1 and in plane along the first dimension
        
        rotationmatrix = eye(dimensions,dimensions);
        rotationmatrix(i,i) = cos(angle);
        rotationmatrix(i,j) = -sin(angle);
        rotationmatrix(j,j) = rotationmatrix(i,i);
        rotationmatrix(j,i) = sin(angle);
        
        L(numberofdirections+1,:) = start';
        numberofdirections = numberofdirections +1;
        
        for k=1:1:((2*pi)/angle)-1  % rotate a full circle
            L(numberofdirections+1,:) = (rotationmatrix* L(numberofdirections,:)')';
            numberofdirections = numberofdirections +1;
        end;
        
    end;
end;

% eliminate multiple entries which are the same regarding a tolerance of 1/1000000
L = round(L*precision)/precision;
L = unique(L,'rows');
