function reflex = isReflex(index,polygon)
%isReflex determine if a vertex of a polygon is reflex or not.
%For performance, winding of polygon is assumed to be clockwise and is not
%checked. Input of a anti-clockwise polygon will flip results.

%   Copyright 2022 The MathWorks, Inc.

polygonSize=length(polygon);
[prev,next]=uav.internal.coveragePlanner.findNeighbor(index,polygonSize);
decisionMatrix=[polygon(prev,1) polygon(prev,2) 1;polygon(index,1) polygon(index,2) 1;...
    polygon(next,1) polygon(next,2) 1];
dec=det(decisionMatrix);
if(dec>0)
    reflex=true;
else
    reflex=false;
end
end
