简介:三角形内角三等分线相交形成等边三角形
分析:
向量旋转和直线交点的练习
tip
新操作的第一次练习,板子不要写错
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
using namespace std;
struct node{
double x,y;
node (double xx=0,double yy=0)
{
x=xx;y=yy;
}
};
node operator + (const node &a,const node &b){return node(a.x+b.x,a.y+b.y);}
node operator - (const node &a,const node &b){return node(a.x-b.x,a.y-b.y);}
node operator * (const node &a,const double &b){return node(a.x*b,a.y*b);}
node operator / (const node &a,const double &b){return node(a.x/b,a.y/b);}
double Dot(node x,node y){return x.x*y.x+x.y*y.y;}
double Len(node x){return sqrt(Dot(x,x));}
double Angle(node x,node y){
return acos( Dot(x,y)/Len(x)/Len(y) );
}
double Cross(node x,node y){return x.x*y.y-x.y*y.x;}
node rotate(node x,double a)
{
return node(x.x*cos(a)-x.y*sin(a),x.x*sin(a)+x.y*cos(a));
}
node getpoint(node P,node v,node Q,node w)
{
node u=P-Q;
double t=Cross(w,u)/Cross(v,w);
return P+v*t;
}
node get(node A,node B,node C)
{
node X=C-B;
double a=Angle(A-B,X);
X=rotate(X,a/3);
node Y=B-C;
double b=Angle(A-C,Y);
Y=rotate(Y,-b/3); //负数表示顺时针转动
return getpoint(B,X,C,Y);
}
int main()
{
node A,B,C,D,E,F;
int T;
scanf("%d",&T);
while (T--)
{
scanf("%lf %lf",&A.x,&A.y);
scanf("%lf %lf",&B.x,&B.y);
scanf("%lf %lf",&C.x,&C.y);
D=get(A,B,C);
E=get(B,C,A);
F=get(C,A,B);
printf("%0.6lf %0.6lf %0.6lf %0.6lf %0.6lf %0.6lf\n",D.x,D.y,E.x,E.y,F.x,F.y);
}
return 0;
}