莫雷定理,最早是英国数学家莫勒(Morley)于1904年发现的,内容为三角形三个角的三等分线共有6条,每相邻的(不在同一个角的)两条三等分线的交点,是一个等边三角形的顶点。
让求DEF三点,思路还是很简单的,先求一个点,例D,先用逆转的方法求BD,CD,再求交点。
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const double eps = 1e-6;
struct Point
{
double x,y;
Point(double xx=0,double yy=0):x(xx),y(yy){}
};
typedef Point Vector;
//#define Vector Point
Vector operator - (Point b, Point a)
{
return Vector(b.x - a.x, b.y - a.y);
}
Vector operator + (Vector a, Vector p)
{
return Vector(a.x + p.x, a.y + p.y);
}
Vector operator * (Vector A,double p)
{
return Vector(A.x*p,A.y*p);
}
double Dot(Vector A, Vector B)//点乘
{
return A.x*B.x + A.y*B.y;
}
double Length(Vector A)//模长
{
return sqrt(Dot(A,A));
}
double Angle(Vector A,Vector B)//夹角
{
return acos(Dot(A,B)/Length(A)/Length(B));
}
double Cross(Vector A,Vector B)//叉乘
{
return A.x*B.y - A.y*B.x;
}
Vector Rotate(Vector A,double rad)//按照A向量的起点旋转rad弧度
{
return Vector(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad) + A.y*cos(rad));
}
Point GetlineIntersection(Point P,Vector v,Point Q,Vector w)//求两直线交点
{
Vector u = P - Q;
double t = Cross(w,u) / Cross(v,w);
return P + v*t;
}
Point GetD(Point A,Point B,Point C)
{
Vector v1 = C - B;
double a1 = Angle(A-B,v1);
v1 = Rotate(v1,a1/3);
Vector v2 = B - C;
double a2 = Angle(A-C,v2);
v2 = Rotate(v2,-a2/3);
return GetlineIntersection(B,v1,C,v2);
}
Point read_point()
{
Point s;
cin >> s.x >>s.y;
return s;
}
int main()
{
int t;
cin >> t;
Point A,B,C,D,E,F;
while(t--)
{
A = read_point();
B = read_point();
C = read_point();
D = GetD(A,B,C);
E = GetD(B,C,A);
F = GetD(C,A,B);
printf("%.6f %.6f %.6f %.6f %.6f %.6f\n",D.x,D.y,E.x,E.y,F.x,F.y);
}
return 0;
}