reading netcdf
[wrf-fire-matlab.git] / ignition / line_inter.m
blob12c1f84760f26395c593995e527a1423b97e4aae
1 function [x,y]=line_inter(x1,y1,x2,y2,x3,y3,x4,y4)
3 % Volodymyr Kondratenko           August 2011
5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 % finds the distance from (x3,y3) to line through (x1,y1) and (x2,y2)
9 m21=(y2-y1)/(x2-x1);
10 m43=(y4-y3)/(x4-x3);
11 x = (x1*m21-x3*m43-y1+y3)/(m21-m43);
12 y = y1 + m21*(x-x1);
14 if (x2==x1) 
15     x=x1;
16     m21=0;
17 y = y3 + m43*(x-x3);
19 end
21 if (x3==x4)
22     x=x3;
23     m43=0;
24 y = y1 + m21*(x-x1);
26 end
28 end