连接

UVa 11178 Morley's Theorem

Morley's Theorem

Morley’s Theorem Input: Standard Input

Output: Standard Output

 Morley’s theorem states that that the lines trisecting the angles of an arbitrary plane triangle meet at the vertices of an equilateral triangle. For example in the figure below the tri-sectors of angles A, B and C has intersected and created an equilateral triangle DEF.

 

 

Of course the theorem has various generalizations, in particular if all of the tri-sectors are intersected one obtains four other equilateral triangles. But in the original theorem only tri-sectors nearest to BC are allowed to intersect to get point D, tri-sectors nearest to CA are allowed to intersect point E and tri-sectors nearest to AB are intersected to get point F. Trisector like BD and CE are not allowed to intersect. So ultimately we get only one equilateral triangle DEF. Now your task is to find the Cartesian coordinates of D, E and F given the coordinates of A, B, and C.

 

Input

First line of the input file contains an integer N (0<N<5001) which denotes the number of test cases to follow. Each of the next lines contain sixintegers . This six integers actually indicates that the Cartesian coordinates of point A, B and C are  respectively. You can assume that the area of triangle ABC is not equal to zero,  and the points A, B and C are in counter clockwise order.

 

Output

For each line of input you should produce one line of output. This line contains six floating point numbers  separated by a single space. These six floating-point actually means that the Cartesian coordinates of D, E and F are  respectively. Errors less than   will be accepted.

 

Sample Input   Output for Sample Input

2
1 1 2 2 1 2
0 0 100 0 50 50

1.316987 1.816987 1.183013 1.683013 1.366025 1.633975

56.698730 25.000000 43.301270 25.000000 50.000000 13.397460

 

Problemsetters: Shahriar Manzoor

Special Thanks: Joachim Wulff

 

 

 

水题!!套模板就ok啦!

 

  1 #include<stdio.h>
  2 #include<math.h>
  3 #include<algorithm>
  4 using namespace std;
  5 #define eps 1e-8
  6 #define oo 100000000
  7 #define pi acos(-1) 
  8 struct point
  9 {
 10     double x,y;
 11      point(double _x = 0.0,double _y = 0.0)
 12     {
 13         x =_x;
 14         y =_y;
 15     }
 16     point operator -(const point &b)const
 17     {

 18         return point(x - b.x, y - b.y);
 19     }
 20     point operator +(const point &b)const
 21     {
 22         return point(x +b.x, y + b.y);
 23     }
 24     double operator ^(const point &b)const
 25     {
 26         return x*b.y - y*b.x;
 27     }
 28     double operator *(const point &b)const
 29     {
 30         return x*b.x + y*b.y;
 31     }
 32     void input()
 33     {
 34         scanf("%lf%lf",&x,&y);
 35     }
 36 }p[10010];
 37 
 38 int dcmp(double a)//判断一个double型的符号 
 39 {
 40     if(fabs(a)<eps)return 0;
 41     if(a>0)return 1;
 42     else return -1; 
 43 }
 44 
 45  point operator |(point a,double p)//重载数乘,向量*数!!! 
 46  {
 47      return point(a.x*p,a.y*p);
 48  }
 49     
 50 bool operator ==(const point &a,const point &b)
 51 {
 52     return dcmp(a.x-b.x)==0&&dcmp(a.y-b.y)==0; 
 53 }
 54 double len(point a)//向量的摸 
 55 {
 56      return sqrt(a*a);
 57 }
 58 point rote(point a,double rad)//逆时针旋转rad弧度!! 
 59 {
 60     return point(a.x*cos(rad)-a.y*sin(rad),a.x*sin(rad)+a.y*cos(rad));
 61 }
 62 
 63 double Angle(point a,point b)
 64 {
 65     double ans=acos((a*b)/len(a)/len(b));
 66     return ans;
 67 }
 68 point getjiaodian(point p,point v,point q,point w)//前提有唯一交点!!参数方程,v,w都为方向向量,p,q,为两直线上的点,求交点 !
 69 {
 70     point u;
 71     u=p-q;
 72     double t=(w^u)/(v^w);
 73     v.x=t*v.x;v.y=t*v.y;
 74     return p+v;
 75 }
 76 
 77 point getxy(point b,point c,point a)
 78 {
 79     point v=c-b,w;
 80     double ag1=Angle(v,a-b)/3.0,ag2=Angle(v,c-a)/3.0;
 81     v=rote(c-b,ag1),w=rote(b-c,-ag2);
 82     point ans=getjiaodian(b,v,c,w);
 83     return ans;
 84 }
 85 int main()
 86 {
 87     int i,T;
 88     point a,b,c,ans1,ans2,ans3;
 89     scanf("%d",&T);
 90     while(T--)
 91     {
 92         a.input();
 93         b.input();
 94         c.input();
 95          ans1=getxy(b,c,a);printf("%.6f %.6f ",ans1.x,ans1.y);
 96          ans2=getxy(c,a,b);printf("%.6f %.6f ",ans2.x,ans2.y);
 97          ans3=getxy(a,b,c);printf("%.6f %.6f\n",ans3.x,ans3.y);
 98     }
 99     return 0;
100 }
View Code

 

posted @ 2013-08-04 11:57  朱群喜_QQ囍_海疯习习  阅读(253)  评论(0编辑  收藏  举报
Map