#include<stdio.h> #include<string.h> #include<math.h> #include<algorithm> using namespace std; const double eps=1e-10; double fabs(double x) { //取正 return x>0?x:-x; } int comp(double x){ if(fabs(x)<eps) return 0; else return x>0?1:-1; //比大小 } struct Point { double x,y; Point(double x=0,double y=0):x(x),y(y) {} //赋值 void init(){ scanf("%lf%lf",&x,&y); //便捷的输入输出 } void prif(){ printf("%.6lf %.6lf",x,y); } }; Point operator +(Point a,Point b){ return Point(a.x+b.x,a.y+b.y); } Point operator *(Point a,double tp){ //向量扩大倍数 return Point(a.x*tp,a.y*tp); } double dot(Point a,Point b){ return a.x*b.x+a.y*b.y; } double cross(Point a,Point b){ return a.x*b.y-a.y*b.x; } typedef Point Vector; Vector rotate(Vector a,double du) //向量a 逆时针旋转 d° 得到的新向量 { double x=a.x*cos(du)-a.y*sin(du); double y=a.x*sin(du)+a.y*cos(du); return Vector(x,y); } double LEN(Vector a){ // 计算|a| return sqrt(a.x*a.x+a.y*a.y); } Vector operator -(Point a,Point b) { return Vector(a.x-b.x, a.y-b.y); } Point deal(Point a,Point b,Point c) { Vector bc,ba,bd,ca,cb,cd; ba=a-b; bc=c-b; double len=LEN(bc)*LEN(ba); double du=acos(dot(ba,bc)/len); bd=rotate(bc,du/3.0); ca=a-c; cb=b-c; len=LEN(cb)*LEN(ca); du=acos(dot(cb,ca)/len); cd= rotate(cb,du/3.0*(-1.0)); double tp=cross(cd,cb)/cross(bd,cd); return b+ bd*tp; } int main() { //freopen("in.txt","r",stdin); int T; scanf("%d",&T); while(T--) { Point A,B,C; Point ans[3]; A.init();B.init();C.init(); ans[0]=deal(A,B,C); ans[1]=deal(B,C,A); ans[2]=deal(C,A,B); for(int i=0;i<3;i++) { ans[i].prif(); if(i!=2) printf(" "); else printf("\n"); } } return 0; } |
Double click to view unformatted code.