标签:bsp turn int 情况 return lse amp style 判断
1 /* 2 *函数名:if_not_parallel 3 *功能:两条直线不垂直的情况下,判断是否相交 4 *输入:(x1,y1),(x2,y2)是线段一的两个端点的坐标 5 * (x3,y3),(x4,y4)是线段二的两个端点的坐标 6 *输出:返回整型值判断两条线段是否相交 7 */ 8 int if_intersect_np(double x1,double y1,double x2,double y2, double x3,double y3,double x4,double y4) 9 { 10 double x; 11 x=((x1*y2-x2*y1)/(x2-x1)+(x4*y3-x3*y4)/(x4-x3))/((y2-y1)/(x2-x1)-(y4-y3)/(x4-x3)); 12 if(((x1-x)*(x-x2)>=0)&&((x3-x)*(x-x4)>=0)) 13 return 1; 14 else 15 return 0; 16 }
标签:bsp turn int 情况 return lse amp style 判断
原文地址:https://www.cnblogs.com/lovebay/p/10470313.html