I am using the code below to define a grid and find the shortest point between two points. I am also defining a polygon as a keep out area. How can I change the cost of the paths inside the polygon so that the connection line goes around the keep out are?
I have Identified the points that are inside the polygon.
clear all;close all;
[xgrid ygrid]= meshgrid (-5:0.5:5,-5:0.5:5);
L = linspace(0,2.*pi,11); xv = 3*sin(L);yv = 3*cos(L);
in = inpolygon(xx,yy,xv,yv);
n = size(xy,1); A = zeros(n); %xy = 10*rand(n,2)
tri = delaunay(xy(:,1),xy(:,2));
I = tri(:); J = tri(:,[2 3 1]); J = J(:);
IJ = I + n*(J-1); A(IJ) = 1 ;
[cost,path] = dijkstra(A,xy,3,437) ;
gplot(A,xy,'k.:'); hold on;
% for k = 1:n, text(xy(k,1),xy(k,2),[' ' num2str(k)],'Color','k'); end