当前位置: 代码迷 >> 综合 >> Uva - 11178 - Morley's Theorem
  详细解决方案

Uva - 11178 - Morley's Theorem

热度:23   发布时间:2024-01-10 13:21:06.0

题意:求Morley定理的3个点的坐标。

题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18543

——>>照要求做~

#include <cstdio>
#include <cmath>using namespace std;struct Point{double x;double y;Point(double x = 0, double y = 0):x(x), y(y){}
}p[3];typedef Point Vector;Vector operator + (Point A, Point B){return Vector(A.x + B.x, A.y + B.y);
}Vector operator - (Point A, Point B){return Vector(A.x - B.x, A.y - B.y);
}Vector operator * (Point A, double p){return Vector(A.x * p, A.y * p);
}Vector operator / (Point 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 Cross(Vector A, Vector B){return A.x * B.y - B.x * A.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));
}Vector Rotate(Vector A, double 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;
}void read(){for(int i = 0; i < 3; i++) scanf("%lf%lf", &p[i].x, &p[i].y);
}Point getD(Point A, Point B, Point C){Vector BC = C - B, BA = A - B;Vector CB = B - C, CA = A - C;BC = Rotate(BC, Angle(BC, BA) / 3);CB = Rotate(CB, -Angle(CB, CA) / 3);return GetLineIntersection(B, BC, C, CB);
}void solve(){Point D, E, F;D = getD(p[0], p[1], p[2]);E = getD(p[1], p[2], p[0]);F = getD(p[2], p[0], p[1]);printf("%.6f %.6f %.6f %.6f %.6f %.6f\n", D.x, D.y, E.x, E.y, F.x, F.y);
}int main()
{int N;scanf("%d", &N);while(N--){read();solve();}return 0;
}