Sha 11178 (simple exercise) Morley's Theorem

Source: Internet
Author: User

Question:

Morley's theorem: In any triangle, the three equal points of each angle form a positive triangle.

However, this has little to do with the question. The question is the coordinates of the three vertices of the positive triangle, with 6 decimal places retained.

Analysis:

Because of the symmetry, EF is the same for finding the D point.

A straight line is expressed in the form of a vertex and a vector. If the angle between the vectors BA and BC is A1, a straight line BD can be obtained by rotating BC counterclockwise A1/3, and a straight line CD can also be obtained, finally, calculate the intersection.

 

  1 //#define LOCAL  2 #include <cstdio>  3 #include <cstring>  4 #include <algorithm>  5 #include <cmath>  6 using namespace std;  7   8 struct Point  9 { 10     double x, y; 11     Point(double x=0, double y=0) :x(x),y(y) {} 12 }; 13 typedef Point Vector; 14 const double EPS = 1e-10; 15  16 Vector operator + (Vector A, Vector B)    { return Vector(A.x + B.x, A.y + B.y); } 17  18 Vector operator - (Vector A, Vector B)    { return Vector(A.x - B.x, A.y - B.y); } 19  20 Vector operator * (Vector A, double p)    { return Vector(A.x*p, A.y*p); } 21  22 Vector operator / (Vector A, double p)    { return Vector(A.x/p, A.y/p); } 23  24 bool operator < (const Point& a, const Point& b) 25 { return a.x < b.x || (a.x == b.x && a.y < b.y); } 26  27 int dcmp(double x) 28 { if(fabs(x) < EPS) return 0; else x < 0 ? -1 : 1; } 29  30 bool operator == (const Point& a, const Point& b) 31 { return dcmp(a.x-b.x) == 0 && dcmp(a.y-b.y) == 0; } 32  33 double Dot(Vector A, Vector B) 34 { return A.x*B.x + A.y*B.y; } 35  36 double Length(Vector A)    { return sqrt(Dot(A, A)); } 37  38 double Angle(Vector A, Vector B) 39 { return acos(Dot(A, B) / Length(A) / Length(B)); } 40  41 double Cross(Vector A, Vector B) 42 { return A.x*B.y - A.y*B.x; } 43  44 double Area2(Point A, Point B, Point C) 45 { return Cross(B-A, C-A); } 46  47 Vector VRotate(Vector A, double rad) 48 { 49     return Vector(A.x*cos(rad) - A.y*sin(rad), A.x*sin(rad) + A.y*cos(rad)); 50 } 51  52 Point GetLineIntersection(Point P, Vector v, Point Q, Vector w) 53 { 54     Vector u = P - Q; 55     double t = Cross(w, u) / Cross(v, w); 56     return P + v*t; 57 } 58  59 Point read_point(void) 60 { 61     double x, y; 62     scanf("%lf%lf", &x, &y); 63     return Point(x, y); 64 } 65  66 Point GetD(Point A, Point B, Point C) 67 { 68     Vector v1 = C - B; 69     double a1 = Angle(A-B, v1); 70     v1 = VRotate(v1, a1/3); 71  72     Vector v2 = B - C; 73     double a2 = Angle(A-C, v2); 74     v2 = VRotate(v2, -a2/3); 75  76     return GetLineIntersection(B, v1, C, v2); 77 } 78  79 int main(void) 80 { 81     #ifdef    LOCAL 82         freopen("11178in.txt", "r", stdin); 83     #endif 84      85     int T; 86     scanf("%d", &T); 87     while(T--) 88     { 89         Point A, B, C, D, E, F; 90         A = read_point(); 91         B = read_point(); 92         C = read_point(); 93         D = GetD(A, B, C); 94         E = GetD(B, C, A); 95         F = GetD(C, A, B); 96         printf("%.6lf %.6lf %.6lf %.6lf %.6lf %.6lf\n", D.x, D.y, E.x, E.y, F.x, F.y); 97     } 98  99     return 0;100 }
Code Jun

 

Sha 11178 (simple exercise) Morley's Theorem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.