# Intersecting Lines 【POJ - 1269】【直线的关系 相交、平行、重合】

### 题目链接

###### 解题思路

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
double eps=1e-8;

double cross(double x1,double y1,double x2,double y2,double x3,double y3)
{
double xx1=x2-x1,yy1=y2-y1;
double xx2=x3-x1,yy2=y3-y1;
return xx1*yy2-yy1*xx2;
}

int main()
{
double x1,x2,y1,y2,x3,y3,x4,y4;
int n;
while(~scanf("%d",&n))
{

printf("INTERSECTING LINES OUTPUT\n");
for(int i=1;i<=n;i++)
{
scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
double A1=x2-x1,B1=-(y2-y1),C1=-y1*(x2-x1)+x1*(y2-y1);
double A2=x4-x3,B2=-(y4-y3),C2=-y3*(x4-x3)+x3*(y4-y3);
if((A1*B2-A2*B1)!=0)
{
printf("POINT ");
double m=A1*B2-A2*B1;
printf("%.2f %.2f\n",((C1*A2)-(C2*A1))/m,((C2*B1)-(C1*B2))/m);
}
else
{
if(fabs(cross(x3,y3,x1,y1,x2,y2))<eps&&fabs(cross(x4,y4,x1,y1,x2,y2))<eps)
printf("LINE\n");
else
printf("NONE\n");
}
}
printf("END OF OUTPUT\n");
}
return 0;
}



08-23 178
08-07 1464
11-12 206
11-25 574
04-19 28
04-13 410
05-10