http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=9
题意:
Morlery定理是这样的:作三角形ABC每个内角的三等分线。相交成三角形DEF。则DEF为等边三角形,你的任务是给你A,B,C点坐标求D,E,F的坐标
思路:
根据对称性,我们只要求出一个点其他点一样:我们知道三点的左边即可求出每个夹角,假设求D,我们只要将向量BC
旋转rad/3的到直线BD,然后旋转向量CB然后得到CD,然后就是求两直线的交点了。
#include <iostream> #include <cstdio> #include <cmath> #include <vector> #include <cstring> #include <algorithm> #include <string> #include <set> #include <functional> #include <numeric> #include <sstream> #include <stack> #include <map> #include <queue> #define CL(arr, val) memset(arr, val, sizeof(arr)) #define lc l,m,rt<<1 #define rc m + 1,r,rt<<1|1 #define pi acos(-1.0) #define L(x) (x) << 1 #define R(x) (x) << 1 | 1 #define MID(l, r) (l + r) >> 1 #define Min(x, y) (x) < (y) ? (x) : (y) #define Max(x, y) (x) < (y) ? (y) : (x) #define E(x) (1 << (x)) #define iabs(x) (x) < 0 ? -(x) : (x) #define OUT(x) printf("%I64d ", x) #define lowbit(x) (x)&(-x) #define Read() freopen("din.txt", "r", stdin) #define Write() freopen("d.out", "w", stdout) #define ll unsigned long long #define keyTree (chd[chd[root][1]][0]) #define M 100007 #define N 300017 using namespace std; const double eps = 1e-8; const int inf = 0x7f7f7f7f; const int mod = 1000000007; struct Point { double x,y; Point(double tx = 0,double ty = 0) : x(tx),y(ty){} }; typedef Point Vtor; //向量的加减乘除 Vtor operator + (Vtor A,Vtor B) { return Vtor(A.x + B.x,A.y + B.y); } Vtor operator - (Point A,Point B) { return Vtor(A.x - B.x,A.y - B.y); } Vtor operator * (Vtor A,double p) { return Vtor(A.x*p,A.y*p); } Vtor operator / (Vtor A,double p) { return Vtor(A.x/p,A.y/p); } bool operator < (Point A,Point B) { return A.x < B.x || (A.x == B.x && A.y < B.y);} int dcmp(double x){ if (fabs(x) < eps) return 0; else return x < 0 ? -1 : 1; } bool operator == (Point A,Point B) {return dcmp(A.x - B.x) == 0 && dcmp(A.y - B.y) == 0; } //向量的点积,长度,夹角 double Dot(Vtor A,Vtor B) { return A.x*B.x + A.y*B.y; } double Length(Vtor A) { return sqrt(Dot(A,A)); } double Angle(Vtor A,Vtor B) { return acos(Dot(A,B)/Length(A)/Length(B)); } //叉积,三角形面积 double Cross(Vtor A,Vtor B) { return A.x*B.y - A.y*B.x; } double Area2(Point A,Point B,Point C) { return Cross(A - B,C - B); } //向量的旋转,求向量的单位法线(即左转90度,然后长度归一) Vtor Rotate(Vtor A,double rad){ return Vtor(A.x*cos(rad) - A.y*sin(rad),A.x*sin(rad) + A.y*cos(rad)); } Vtor Normal(Vtor A) { double L = Length(A); return Vtor(-A.y/L, A.x/L); } //直线的交点 Point GetLineIntersection(Point P,Vtor v,Point Q,Vtor w) { Vtor u = P - Q; double t = Cross(w,u)/Cross(v,w); return P + v*t; } //点到直线的距离 double DistanceToLine(Point P,Point A,Point B) { Vtor v1 = B - A; return Cross(P,v1)/Length(v1); } //点到线段的距离 double DistanceToSegment(Point P,Point A,Point B) { if (A == B) return Length(P - A); Vtor v1 = B - A , v2 = P - A, v3 = P - B; if (dcmp(Dot(v1,v2)) < 0) return Length(P - A); else if (dcmp(Dot(v1,v3)) > 0) return Length(P - B); else return Cross(v1,v2)/Length(v1); } //点到直线的映射 Point GetLineProjection(Point P,Point A,Point B) { Vtor v = B - A; return A + v*Dot(v,P - A)/Dot(v,v); } //判断线段是否规范相交 bool SegmentProperIntersection(Point a1,Point a2,Point b1,Point b2) { double c1 = Cross(a2 - a1,b1 - a1), c2 = Cross(a2 - a1,b2 - a1), c3 = Cross(a1 - a2,b1 - a1), c4 = Cross(a1 - a2,b2 - a2); return dcmp(c1)*dcmp(c2) < 0 && dcmp(c3)*dcmp(c4) < 0; } //判断点是否在一条线段上 bool OnSegment(Point P,Point a1,Point a2) { return dcmp(Cross(a1 - P,a2 - P)) == 0 && dcmp(Dot(a1 - P,a2 - P)) < 0; } //多边形面积 double PolgonArea(Point *p,int n) { double area = 0; for (int i = 1; i < n - 1; ++i) area += Cross(p[i] - p[0],p[i + 1] - p[0]); return area/2; } Point solve(Point A,Point B,Point C) { double rad1 = Angle(A - B, C - B)/3.0; Vtor v1 = C - B; v1 = Rotate(v1,rad1); double rad2 = Angle(A - C,B - C)/3.0; Vtor v2 = B - C; v2 = Rotate(v2,-rad2); return GetLineIntersection(B,v1,C,v2); } int main() { // Read(); int T; Point A,B,C; scanf("%d",&T); while (T--) { scanf("%lf%lf%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y); Point D = solve(A,B,C); Point E = solve(B,C,A); Point F = solve(C,A,B); printf("%.6lf %.6lf %.6lf %.6lf %.6lf %.6lf ",D.x,D.y,E.x,E.y,F.x,F.y); } return 0; }