%-------------------------------------------------------------------------%
%         This software is licensed by Creative Commons BY-NC-SA:         %
%      http://creativecommons.org/licenses/by-nc-sa/3.0/it/legalcode      %
%-------------------------------------------------------------------------%
%
% File: unoriented_KNN(A,k)
%
% Goal: find for each point the associated normal
%
% Inputs: A:    matrix MX3 containing the separatrix points
%         k:    number of nearest points used to estimate the normals
%
% Outputs: normals: the set of unoriented normals
%
% Calls on: kNearestNeighbors.m, normnd.m 
%
%-------------------------------------------------------------------------%
function [normals]=unoriented_KNN(A,k)
N=size(A,1);
for i=1:N
    % Given a point compute the k-nearest neighbors and find the unoriented
    % normal in such point 
    [neighbors] = kNearestNeighbors(A,A(i,:),k);
    normals(i,:)=normnd(neighbors);
end
end