function [prevPath,kPP,xPP,yPP]=checkFeas(xPP,yPP,Obst,dPerc) %init kPP=2; for i1=1:length(xPP)-1, %check for obstacle boundary crossings obstID=checkEdge(xPP(i1:i1+1),yPP(i1:i1+1),Obst); if obstID, perc=dPerc; while perc<=1, %clip edge to obstacle boundary (very coarse) xPP(i1+1)=xPP(i1+1)-(xPP(i1+1)-xPP(i1))*perc; yPP(i1+1)=yPP(i1+1)-(yPP(i1+1)-yPP(i1))*perc; %recheck for obstacle boundary crossings obstID=checkEdge(xPP(i1:i1+1),yPP(i1:i1+1),Obst); if obstID, perc=min(1,perc+dPerc); else break; end end else kPP=kPP+1; end %break if clipping was necessary if kPP~=i1+2, break; end end prevPath=0; if kPP>length(xPP), %previous path is still feasible prevPath=1; end