
function [tmpD1,tmpD2,tmpD3] = DistView(edge)

n1 = size(edge,1); % size initialization

if n1 < 3
    error('Error: First list less than 3 points !');
end

[array]=index(edge);
[tmpD1,tmpD2,tmpD3] = GetTripleDistView (array,1);  % Get three distance views of the shape part 1 

return          

%----------------------------------------------------------------------
% function [list]=index(edge)
%input: data of the selected edge detection algorithm
% this function converts the row vector of the indices into 
%column vector
%-----------------------------------------------------------------------

function [list] = index(edgedata)

[l1,l2]=find(edgedata);% % Extracting value for image matching

size_l1=size(l1,1);
for i=1:2             % Converting data into column vector
    for j=1:size_l1
        if(i==1)
            list(j,i)=l1(j,1);
        end
        if(i==2)
            list(j,i)=l2(j,1);
        end
    end
end
return 
%--------------------------------------------------------------------------
% function [d1,d2,d3] = GetTripleDistView(arrList, keepEndPoints)
% input: arrlist: shape-part (n x 2 matrix)
%        keepEndPoints: if 1, the endpoints are taken into account,
%                       i.e. length of resulting distanceview equals
%                       length of arrlist.
%                       else (=0): 
%                       length of distanceview = length(arrlist)-2
%------------------------------------------------------------------

function [d1,d2,d3] = GetTripleDistView(arrList, keepEndPoints)

arrSize = size(arrList,1);
if keepEndPoints==1
    indexStart=1; indexEnd=arrSize;
else
    indexStart=2; indexEnd=arrSize-1;
end

arrSize = size(arrList,1);
x =  arrList(indexStart:indexEnd,1);
y =  arrList(indexStart:indexEnd,2);

dvCenter1_x  = arrList(1,1);
dvCenter1_y  = arrList(1,2);
d1 = sqrt((y - dvCenter1_y).^2 + (x - dvCenter1_x).^2);
    
dvCenter2_x = arrList(arrSize,1);
dvCenter2_y = arrList(arrSize,2);
d2 = sqrt((y - dvCenter2_y).^2 + (x - dvCenter2_x).^2);
    
dvCenter3_x = sum(x)/(arrSize-2);
dvCenter3_y = sum(y)/(arrSize-2);
d3 = sqrt((y - dvCenter3_y).^2 + (x - dvCenter3_x).^2);


return

