function distance = getPointLineDistance(point,prev,next)
%getPointLineDistance get perpendicular distance of a point from a line.

%   Copyright 2022 The MathWorks, Inc.
%#codegen

	x3=point(1);
    y3=point(2);
    x1=prev(1);
    y1=prev(2);
    x2=next(1);
    y2=next(2);
	% Find the numerator for our point-to-line distance formula.
	numerator = abs((x2 - x1) * (y1 - y3) - (x1 - x3) * (y2 - y1));
	
	% Find the denominator for our point-to-line distance formula.
	denominator = sqrt((x2 - x1) ^ 2 + (y2 - y1) ^ 2);
    if(denominator<eps)
        %Points are very close handle edge case
        distance= hypot(x3 - mean([x1,x2]),y3 -mean([y1,y2]));
    else
	% Compute the distance.
	distance = numerator ./ denominator;
    end
end
