% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %
% function_CompareDistance return true or false depending on the meeting   %
% of a condition. That condition is that, "IF BETWEEN TWO FRAMES, THE      %
% DISTANCE BETWEEN TWO POINTS CHANGES PER LESS THAN A THRESHOLD, THOSE TWO %
% POINTS PROBABLY CORRESPOND TO THE SAME FEATURE IN BOTH IMAGES"           %
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %

%  INPUTS:   Name           | Type    | Dimensions | Description
%            Point1         | 2Points | 2x2        | Points in t-1 and t for feature 1
%            Point2         | 2Points | 2x2        | Points in t-1 and t for feature 1
%            threshold      | int     | 1x1        | change limite
%
% OTUPUTS:   Name           | Type    | Dimensions | Description
%            veracity       | bool    |            | Condition is met or no

function veracity = function_CompareDistance(Point1, Point2, threshold)
    % Points in t-1
    xP1t1 = Point1(1,1);
    yP1t1 = Point1(1,2);
    xP2t1 = Point2(1,1);
    yP2t1 = Point2(1,2);
    % Points in t
    xP1t2 = Point1(2,1);
    yP1t2 = Point1(2,2);
    xP2t2 = Point2(2,1);
    yP2t2 = Point2(2,2);
    
    % Distance between two points in both frames
    distT1 = sqrt((xP2t1 - xP1t1)^2+(yP2t1 - yP1t1)^2);
    distT2 = sqrt((xP2t2 - xP1t2)^2+(yP2t2 - yP1t2)^2);
    
    % If the difference in distances in less than a certain threshold, then
    % the condition was met and the function returns truw, otherwise it
    % return false
    if (abs(distT1 - distT2) < threshold)
        veracity = true;
    else
        veracity = false;
    end
end