function inout = vclassify(x, y, tol)
%CLASSIFY In, on, or outside of a circle.
%   INOUT = CLASSIFY(X, Y, TOL) classifies an array of points [X; Y]
%   as being inside, on, or outside of the unit circle.
%   INOUT is -1 if the point is inside the circle,
%   0 if the point is on the circle, and 1 if the point is outside
%   the circle.
%
%   A point is considered on the circle if (X^2 + Y^2) is inside the
%   range (1 + TOL) to (1 - TOL).


s = x .^ 2 + y .^ 2;
inout = zeros(1, length(s));

% it is important to assign the 'on' case last here
inout(s < 1) = -1;
inout(s > 1) = 1;
inout(abs(s - 1) < tol) = 0;

