UVA 11178 Morley's Theorem——直线相交
#include #include #include #include #include using namespace std;const double eps = 1e-5;const double PI = acos(-1.0);struct Point { double x, y; Point (double xx = 0.0, double yy = 0.0) : x(xx), y(yy) {}};typedef Point Vector;Point operator + (const Point &p1, const Point &p2) { return Point(p1.x + p2.x, p1.y + p2.y); }Point operator - (const Point &p1, const Point &p2) { return Point(p1.x - p2.x, p1.y - p2.y); }Vector operator * (const Vector &v, double x) { return Vector(v.x*x, v.y*x); }double Dot(Vector v1, Vector v2) { return v1.x*v2.x+v1.y*v2.y; }double Length(Vector v) { return sqrt(Dot(v, v)); }double Angle(Vector v1, Vector v2) { return acos(Dot(v1, v2) / Length(v1) / Length(v2)); }double Cross(Vector v1, Vector v2) { return v1.x*v2.y - v1.y*v2.x; }Vector Rotate(Vector v, double rad) { return Vector(v.x*cos(rad) - v.y*sin(rad), v.x*sin(rad) + v.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 Solve(Point p1, Point p2, Point p3) { Vector v1 = p2 - p1, v2 = p3 - p1, v3 = p3 - p2; double angle1 = Angle(v1, v2), angle2 = PI - Angle(v1, v3); angle1 /= 3.0, angle2 /= 3.0; Vector t1 = Rotate(v1, angle1), t2 = Rotate(v1, PI - angle2); return GetLineIntersection(p1, t1, p2, t2);}int main() { int T; scanf("%d", &T); Point A, B, C, D, E, F; for (int kase = 1; kase <= T; kase++) { scanf("%lf %lf %lf %lf %lf %lf", &A.x, &A.y, &B.x, &B.y, &C.x, &C.y); D = Solve(B, C, A); E = Solve(C, A, B); F = Solve(A, B, C); printf("%lf %lf %lf %lf %lf %lf\n", D.x, D.y, E.x, E.y, F.x, F.y); } return 0;}
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
暂时没有评论,来抢沙发吧~