公式如下:
若直线A1x十+B1y+十C1=0与直线A2x十+2y+十C2=0平行,则:
A1/A2=B1/B2≠C1/C2
①若B1=B2=0,此时两直线斜率不存在,满足:A1/A1=B1/B2≠C1/;C2;
②若B1≠0、B2≠0,此时也满足A1/A2=B1/B2≠C1/C2
则两直线平行,有:A1/A2=B1/B2≠C1/C2
上代码:
若直线A1x十+B1y+十C1=0与直线A2x十+2y+十C2=0平行,则:
A1/A2=B1/B2≠C1/C2
①若B1=B2=0,此时两直线斜率不存在,满足:A1/A1=B1/B2≠C1/;C2;
②若B1≠0、B2≠0,此时也满足A1/A2=B1/B2≠C1/C2
则两直线平行,有:A1/A2=B1/B2≠C1/C2
上代码:
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 }