题意:给一个$\Delta ABC$,分别做三个角的三等分线相交成$\Delta DEF$,求出$D,E,F$的坐标。
直接根据题意模拟
#include<cstdio> #include<cmath> #include<algorithm> using namespace std; struct Point { double x,y; Point(double x1=0,double y1=0){x=x1;y=y1;} }; typedef Point Vector; inline Vector operator +(Point a,Point b) { return Vector(a.x+b.x,a.y+b.y); } inline Vector operator -(Point a,Point b) { return Vector(a.x-b.x,a.y-b.y); } inline Vector operator *(double t,Vector a) { return Vector(a.x*t,a.y*t); } inline Vector ratate(Vector v,double a) { return Vector(v.x*cos(a)-v.y*sin(a),v.x*sin(a)+v.y*cos(a)); } inline double Dot(Vector a,Vector b) { return a.x*b.x+a.y*b.y; } inline double len(Vector a) { return sqrt(Dot(a,a)); } inline double angle(Vector a,Vector b) { return acos(Dot(a,b)/len(a)/len(b)); } inline double Cross(Vector a,Vector b) { return a.x*b.y-a.y*b.x; } inline Point getLineIntersection(Point A,Point B,Vector v1,Vector v2) { Vector u=A-B; double t=Cross(v2,u)/Cross(v1,v2); return A+t*v1; } inline Point solve(Point A,Point B,Point C) { Vector v1=C-B,v2=B-C; double alpha=angle(v1,A-B),beta=angle(v2,A-C); v1=ratate(v1,alpha/3);v2=ratate(v2,-beta/3); return getLineIntersection(B,C,v1,v2); } inline Point readPoint() { double x,y; scanf("%lf%lf",&x,&y); return Point(x,y); } int main() { Point A,B,C,D,E,F; int T; scanf("%d",&T); while(T--) { A=readPoint();B=readPoint();C=readPoint(); D=solve(A,B,C);E=solve(B,C,A);F=solve(C,A,B); printf("%.6lf %.6lf %.6lf %.6lf %.6lf %.6lf\n",D.x,D.y,E.x,E.y,F.x,F.y); } return 0; }