⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 is_cross.m

📁 best routing protocol
💻 M
字号:
function res =is_cross(pt1, pt2, pt3, pt4)%check if line (pt1->pt2) and line (pt3->pt4) is acrossres=0;if pt3(1)==pt4(1) %horizontal line  x=pt3(1);  if (pt1(1)>=x) & (pt2(1)>=x) %above the h-line	return  elseif (pt1(1)<=x) & (pt2(1)<=x) % below the h-line	return  end  b=(x-pt1(1))/(pt2(1)-pt1(1));  cross_pt_y = pt1(2)+(pt2(2)-pt1(2))*b;  if cross_pt_y>min(pt3(2),pt4(2)) & cross_pt_y<max(pt3(2),pt4(2))	res=1;  end	elseif pt3(2)==pt4(2) % vertical line  y=pt3(2);  if (pt1(2)>=y) & (pt2(2)>=y) % right to the v-line	return  elseif (pt1(2)<=y) & (pt2(2)<=y) % left to the v-line	return  end  b=(y-pt1(2))/(pt2(2)-pt1(2));  cross_pt_x = pt1(1)+(pt2(1)-pt1(1))*b;  if cross_pt_x>min(pt3(1),pt4(1)) & cross_pt_x<max(pt3(1), pt4(1))	res = 1;  endelse  error(['unsupported line cross computation--pt3->pt4 must be either' ...		 ' horizontal or vertical']);end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -