function belowabove = classify2(x, y, tol)
%CLASSIFY Below, on, or above the line x = y.
%   BELOWABOVE = CLASSIFY(X, Y, TOL) classifies a scalar point (X, Y)
%   as being below, on, or above of the line x = y.
%   BELOWABOVE is -1 if the point is below the line,
%   0 if the point is on the line, and 1 if the point is above
%   the line.
%
%   A point is considered on the line if (X - Y) is inside the
%   range -TOL to +TOL.

% easiest if you check the 'on' case first
if abs(x - y) < tol
    belowabove = 0;
elseif x > y
    belowabove = -1;
else
    belowabove = 1;
end
