//MJRT #include #include #include #include ////////////////////// #include #include #include #include #include #include #include /////////////////////// #include #include #include #include #include #include /////////////////////// //#include //pd_bs库,hdu&&poj不支持 using namespace std; #define lch(x) ((x) << 1) #define rch(x) ((x)<<1|1) #define dad(x) ((x)>>1) #define lowbit(x) ((x)&(-x)) static int INDEX = 0,BUGs = 0; #define BUG() cout << "There is BUG No." << BUGs++ <>1; //const int N = 5 + ; const double eps = 1e-4; const double PI = acos(-1.0); int sgn(double x) { if (fabs(x) < eps)return 0; if (x < 0)return -1; else return 1; } //1.1 Point 定义 struct Point { double x,y; Point() {} Point(double x,double y):x(x),y(y){} Point operator -(const Point & b)const { return Point(x - b.x,y - b.y); } bool operator ==(const Point & b)const { return x==b.x && y==b.y; } //*两点间距离 double operator &(const Point & b)const { return sqrt((*this-b)*(*this-b)); } //*叉积 //1.判断向量方向 //若 a x b > 0 表示a在b的顺时针方向上 //若 a x b < 0 表示a在b的逆时针方向上 //若 a x b == 0 表示a在b共线,但不确定方向是否相同 //2.求面积 //叉积的长度 |a×b| 可以解释成以a和b为邻边的平行四边形的面积 double operator ^(const Point & b)const { return x*b.y - y*b.x; } //*点积 //1.定义a*b = |a|*|b|*cos (0<= () <= PI) //2.判断垂直 a*b == 0 ,a,b相互垂直 double operator *(const Point & b)const { return x*b.x + y*b.y; } //*比较(先x后y) //极角排序需要最低的一点(改为先y后x) bool operator < (const Point & b) const { if(y!=b.y) return y= min(b.s.x,b.e.x) && max(b.s.x,b.e.x) >= min(s.x,e.x) && max(s.y,e.y) >= min(b.s.y,b.e.y) && max(b.s.y,b.e.y) >= min(s.y,e.y) && sgn((b.s-e)^(s-e))*sgn((b.e-e)^(s-e)) <= 0 && sgn((s-b.e)^(b.s-b.e))*sgn((e-b.e)^(b.s-b.e)) <= 0; } //*判断直线l1和线段l2是否相交 bool operator % (const Line & b) const { return sgn((b.s-e)^(s-e))*sgn((b.e-e)^(s-e)) <= 0; } //输入 void in() { s.in(); e.in(); } //输出 void out() { printf("Line: (%f,%f) -> (%f,%f)\n",s.x,s.y,e.x,e.y); } }; //1.3 点与直线关系 //*点到直线距离 //返回为result,是点到直线最近的点 Point PtoL(Point P,Line L) { Point result; double t = ((P-L.s)*(L.e-L.s))/((L.e-L.s)*(L.e-L.s)); result.x = L.s.x + (L.e.x-L.s.x)*t; result.y = L.s.y + (L.e.y-L.s.y)*t; return result; } //*点到线段的距离 //返回点到线段最近的点 Point PtoS(Point P,Line L) { Point res; double t = ((P-L.s)*(L.e-L.s))/((L.e-L.s)*(L.e-L.s)); if (t >= 0 && t <= 1) { res.x = L.s.x + (L.e.x - L.s.x)*t; res.y = L.s.y + (L.e.y - L.s.y)*t; } else { if( (P&L.s) < (P&L.e)) res = L.s; else res = L.e; } return res; } //*判断点在线段上 bool onSeg(Point P,Line L) { return sgn((L.s-P)^(L.e-P)) == 0 && sgn((P.x - L.s.x) * (P.x - L.e.x)) <= 0 && sgn((P.y - L.s.y) * (P.y - L.e.y)) <= 0; } const int MAXN = 1010; Point list[MAXN]; int pos; //相对于list[0]的极角排序 bool _cmp(Point p1,Point p2) { double tmp = (p1-list[pos])^(p2-list [pos]); if (sgn(tmp) > 0)return true; else if (sgn(tmp) == 0 && sgn((p1&list[pos]) - (p2&list[pos])) <= 0) return true; else return false; } Line l[5]; double a[5]; int main() { //ios::sync_with_stdio(false); #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); #endif int Case; scanf("%d",&Case); while(Case--) { int n = 5; for(int i = 0 ; i < 5 ; i++) list[i].in(); sort(list,list+5); pos = 0; for(int i = 1 ; i < n ;i++) { sort(list+i,list+n,_cmp); pos++; } for(int i = 0 ; i < 5 ; i++) l[i] = Line(list[i],list[(i+1)%n]); for(int i = 0 ; i < 5 ; i++) a[i] = l[i].getV()*l[(i+1)%n].getV(); //Show(a,0,5); bool flag = 1; for(int i = 1 ; i < 5; i++) if(sgn(a[0]-a[i])) { flag = 0; } puts(flag?"Yes":"No"); } return 0; }