function seen = canSee(i,j,poly)
%canSee determine if a vertex j can be seen by a vertex i.

%   Copyright 2022 The MathWorks, Inc.

polygonSize=size(poly,1);
[prev,next] = uav.internal.coveragePlanner.findNeighbor(i,polygonSize);
if(prev==j)||(next==j)
    %if Neighbor of edge return.
    seen=false;
    return
end
[in,~]=intersect(polyshape(poly),poly([i j], 1:2));
xi=in(:,1);
yi=in(:,2);
[l,~]=size(xi);
centerx=mean(xi,1);
centery=mean(yi,1);
if(l==2)&&inpolygon(centerx,centery,[poly(:,1);poly(1,1)],[poly(:,2);poly(1,2)])
    %still an edge case where the line is completely outside the polygon.
    seen= true;
else
    seen=false;
end

end

