不知道谁转的计算几何题集里面有这个题...标题还写的是基本线段求交...
结果题都没看就直接敲了个线段交...各种姿势WA一遍以后发现题意根本不是线段交而是直线交...白改了那个模板...
乱发文的同学真是该死...浪费我几个小时的生命...
/********************* Template ************************/
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std; #define EPS 1e-8
#define MAXN (int)5e5+5
#define MOD (int)1e9+7
#define PI acos(-1.0)
#define LINF ((1LL)<<50)
#define INF (1<<30)
#define DINF (1e10)
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) < (b) ? (a) : (b))
#define max3(a,b,c) (max(max(a,b),c))
#define min3(a,b,c) (min(min(a,b),c))
#define BUG cout<<"BUG! "<<endl
#define LLL cout<<"--------------"<<endl
#define L(t) (t << 1)
#define R(t) (t << 1 | 1)
#define Mid(a,b) ((a + b) >> 1)
#define lowbit(a) (a & -a)
#define FIN freopen("in.txt","r",stdin)
#define FOUT freopen("out.txt","w",stdout)
#pragma comment (linker,"/STACK:102400000,102400000") // typedef long long LL;
// typedef unsigned long long ULL;
// typedef __int64 LL;
// typedef unisigned __int64 ULL;
// int gcd(int a,int b){ return b?gcd(b,a%b):a; }
// int lcm(int a,int b){ return a*b/gcd(a,b); } /********************* F ************************/
struct POINT{
double x,y;
POINT(double _x = , double _y = ):x(_x),y(_y){};
};
bool operator == (POINT a,POINT b){
if(a.x == b.x && a.y == b.y) return true;
return false;
}
struct LINE{
POINT a,b;
double K,B;
LINE(POINT _a = ,POINT _b = ):a(_a),b(_b){
if((a.x - b.x) == ){
K = DINF;
B = a.x;
}else{
K = ((a.y - b.y) / (a.x - b.x));
B = (- (b.x * a.y - a.x * b.y) / (a.x - b.x));
}
} };
double dist(POINT p1,POINT p2){
return(sqrt((p1.x-p2.x) * (p1.x-p2.x) + (p1.y-p2.y) * (p1.y-p2.y)));
}
double multiply(POINT sp,POINT ep,POINT op){
return (sp.x-op.x) * (ep.y-op.y) - (ep.x-op.x) * (sp.y-op.y);
}
bool cross_Judge(LINE a ,LINE b) {
double x = multiply(a.a,a.b,b.a);
double y = multiply(a.a,a.b,b.b);
if(x == && y != ) return true;
if(x != && y == ) return true;
return (x * y < );
}
bool same(LINE a , LINE b) {
if(a.a == b.a && a.b == b.b) return true;
if(a.b == b.a && a.a == b.b) return true;
return false;
}
bool onseg(POINT a,POINT s,POINT e){
if(multiply(a,s,e) == && a.x <= max(s.x,e.x) && a.x >= min(s.x,e.x)
&& a.y <= max(s.y,e.y) && a.y >= min(s.y,e.y))
return true;
return false;
}
bool cover(LINE a , LINE b) {
if(multiply(a.a,a.b,b.a) == && multiply(a.a,a.b,b.b) == ){
if(onseg(a.a,b.a,b.b) || onseg(a.b,b.a,b.b)) return true;
if(onseg(b.a,a.a,a.b) || onseg(b.b,a.a,a.b)) return true;
}else return false;
}
bool cross(LINE a , LINE b){
if(min(a.a.x,a.b.x) > max(b.a.x,b.b.x)) return false;
if(min(b.a.x,b.b.x) > max(a.a.x,a.b.x)) return false;
if(min(a.a.y,a.b.y) > max(b.a.y,b.b.y)) return false;
if(min(b.a.y,b.b.y) > max(a.a.y,a.b.y)) return false;
return (cross_Judge(a,b) && cross_Judge(b,a));
}
int main()
{
//FIN;
int n ;
cin>>n;
cout<<"INTERSECTING LINES OUTPUT"<<endl;
for(int i = ; i < n ; i++){
double a,b,c,d,e,f,g,h;
cin>>a>>b>>c>>d>>e>>f>>g>>h;
LINE x = LINE(POINT(a,b),POINT(c,d));
LINE y = LINE(POINT(e,f),POINT(g,h));
if(multiply(x.a,x.b,y.a) == && multiply(x.a,x.b,y.b) == ){
cout<<"LINE"<<endl;
continue;
}else if(x.K == y.K && x.B != y.B){
cout<<"NONE"<<endl;
continue;
}else{
cout<<"POINT ";
if(x.K == DINF){
printf("%.2lf %.2lf\n",x.B,x.B * y.K + y.B);
}else if(y.K == DINF) {
printf("%.2lf %.2lf\n",y.B,y.B * x.K + x.B);
}else {
double cx = (x.B-y.B) / (y.K-x.K);
double cy = x.K * cx + x.B;
printf("%.2lf %.2lf\n",cx,cy);
}
continue;
}
}
cout<<"END OF OUTPUT"<<endl;
return ;
}