#include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #include<cstring> #include<string> using namespace std; const double eps = 1e-8; const double pi = acos(-1.0); int sgn(double x){ if(fabs(x) < eps) return 0; else if(x < 0) return -1; else return 1; } inline double sqr(double x){return x*x;} struct Point{ double x, y; Point(double a=0, double b=0):x(a),y(b){} Point(const Point &a){ x = a.x, y = a.y; } inline void input(){ scanf("%lf%lf", &x, &y); } inline void output(){ printf("%.6f %.6f", x, y); } Point operator-(const Point &a)const{ return Point(x - a.x, y - a.y); } double operator*(const Point &a)const{ return x * a.x + y * a.y; } double operator^(const Point &a)const{ return x * a.y - y * a.x; } Point rotate(const Point &p, double angle){ Point v = (*this) - p; double c = cos(angle), s = sin(angle); return Point(p.x + v.x*c - v.y*s, p.y + v.x*s + v.y*c); } double rad(Point a,Point b){ Point p = *this; return fabs(atan2( fabs((a-p)^(b-p)),(a-p)*(b-p) )); } }; typedef Point Vector; struct Line{ Point s, e; Line(){} Line(const Point &a, const Point &b):s(a),e(b){} double angle(){ double k = atan2(e.y - s.y, e.x - s.y); if(sgn(k) < 0) k += pi; return k; } Point crosspoint(Line v){ double a1 = (v.e-v.s)^(s-v.s); double a2 = (v.e-v.s)^(e-v.s); return Point((s.x*a2-e.x*a1)/(a2-a1),(s.y*a2-e.y*a1)/(a2-a1)); } }; int main(){ Point a, b, c; int kase; scanf("%d", &kase); while(kase--){ a.input(); b.input(); c.input(); if(((a-b)^(c-b))>0) swap(a,c); double anga = fabs(a.rad(b,c)) / 3.0, angb = fabs(b.rad(a,c)) / 3.0, angc = fabs(c.rad(a,b)) / 3.0; Line af(a, b.rotate(a, anga)), bf(b, a.rotate(b, -angb)), bd(b, c.rotate(b, angb)), cd(c, b.rotate(c, -angc)), ae(a, c.rotate(a, -anga)), ce(c, a.rotate(c, angc)); Point e, f, d; e = ae.crosspoint(ce); f = af.crosspoint(bf); d = bd.crosspoint(cd); d.output();cout<<‘ ‘; e.output();cout<<‘ ‘; f.output();puts(""); } return 0; }
A - Morley's Theorem UVA - 11178
原文地址:https://www.cnblogs.com/LS-Joze/p/11674685.html
时间: 2024-10-14 02:36:22