function [weight]=invalidade(q,p,w)

rq=q(1:2,:)';
nq=LineNormals2D(rq);
anq=unwrap(atan2(nq(:,2),nq(:,1)));

rp=p(1:2,:)';
np=LineNormals2D(rp);
anp=unwrap(atan2(np(:,2),np(:,1)));


sda=abs(anq-anp);
da=sda;
da(isnan(da))=0;

if sum(da)<0.1
    da=w;
end

da=da+0.5;
da=da/max(da);

% if isnan(da)
%     sda'
%     nq'
%     np'
%     q
%     p
%     da'
% end
weight=da';