1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
| #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double db; const db eps = 1e-10; const db pi = acos(-1.0); const ll inf = 0x3f3f3f3f3f3f3f3f; const ll maxn = 1e5 + 10;
inline int dcmp(db x) { if(fabs(x) < eps) return 0; return x > 0? 1: -1; }
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} void input() { scanf("%lf%lf", &x, &y); } Point operator+(const Point a) { return Point(x + a.x, y + a.y); } Point operator-(const Point a) { return Point(x - a.x, y - a.y); } bool operator<(const Point &a) const { return (!dcmp(y - a.y))? dcmp(x - a.x) < 0: y < a.y; } db dis2() { return x * x + y * y; } db dis() { return sqrt(dis2()); } db dot(const Point a) { return x * a.x + y * a.y; } db cross(const Point a) { return x * a.y - y * a.x; } db ang(Point a) { return acos(dot(a) / (a.dis() * dis())); } Point Rotate(double rad) { return Point(x * cos(rad) - y * sin(rad), x * sin(rad) + y * cos(rad)); } }; typedef Point Vector;
class Line { public: Point s, e; db angle; Line() {} Line(Point s, Point e) : s(s), e(e) {} inline void input() { scanf("%lf%lf%lf%lf", &s.x, &s.y, &e.x, &e.y); } int toLeftTest(Point p) { if((e - s).cross(p - s) > 0) return 1; else if((e - s).cross(p - s) < 0) return -1; return 0; } Point crosspoint(Line l) { double a1 = (l.e - l.s).cross(s - l.s); double a2 = (l.e - l.s).cross(e - l.s); double x = (s.x * a2 - e.x * a1) / (a2 - a1); double y = (s.y * a2 - e.y * a1) / (a2 - a1); if(dcmp(x) == 0) x = 0; if(dcmp(y) == 0) y = 0; return Point(x, y); } };
Point get_crosspoint(Point A, Point B, Point C) { Vector v1 = C - B; db a1 = v1.ang(A - B); v1 = v1.Rotate(a1 / 3.0); v1 = v1 + B; Vector v2 = B - C; db a2 = v2.ang(A - C); v2 = v2.Rotate(-a2 / 3.0); v2 = v2 + C; Line l1 = Line(B, v1); Line l2 = Line(C, v2); return l1.crosspoint(l2); }
int main() { int T; scanf("%d", &T); while(T--) { Point a, b, c; a.input(); b.input(); c.input(); Point d, e, f; d = get_crosspoint(a, b, c); e = get_crosspoint(b, c, a); f = get_crosspoint(c, a, b); printf("%.6lf %.6lf %.6lf %.6lf %.6lf %.6lf\n", d.x, d.y, e.x, e.y, f.x, f.y); } return 0; }
|