function [yesno] = interior(xin,yin,x3,y3)
% [yesno] = interior(xin,yin,x3,y3)
% if xin,yin is interior to the triangle x3(3),y3(3)
%  yesno = 1       else   yesno = 0


%AB = [x3(2)-x3(1) x3(3)-x3(1) ; y3(2)-y3(1) y3(3)-y3(1) ];
%xinx1= [xin-x3(1) yin-y3(1)]';
%ab = AB\xinx1;

%if (ab(1)>0 & ab(1)<1 & ab(2)>0 & ab(2)<1)
%yesno = 1;
%else
%yesno = 0;
%end

d1 = det([xin-x3(1) , yin-y3(1) ; x3(2)-x3(1), y3(2)-y3(1)]);
d2 = det([xin-x3(2) , yin-y3(2) ; x3(3)-x3(2), y3(3)-y3(2)]); 
d3 = det([xin-x3(3) , yin-y3(3) ; x3(1)-x3(3), y3(1)-y3(3)]);

if (d1<0 & d2<0 & d3<0)
yesno = 1;
else
yesno = 0;
end
