您的位置:首页 > 其它

uva 11178 Morley's Theorem 三角形内角三等分线交点

2016-07-20 14:56 555 查看
给出一个三角形ABC的三个顶点坐标,共有6条内角三等分线:AF 、AE、 BF、 BD、 CE、 CD,求点D、E、F的坐

标。



#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define for0(a, n) for (int (a) = 0; (a) < (n); (a)++)
#define for1(a, n) for (int (a) = 1; (a) <= (n); (a)++)
typedef long long ll;
typedef pair<int, int> pii;
const int INF =0x3f3f3f3f;
//const int maxn=    ;
const double eps=1e-10;
struct Point
{
double x,y;
Point(double x=0,double y=0):x(x),y(y) {};
void show()
{
cout<<x<<" "<<y<<endl;
}
}A,B,C,D,E,F;

typedef Point Vector;
Vector operator +(Vector A,Vector B) {return Vector(A.x+B.x,A.y+B.y); }
Vector operator -(Vector A,Vector B) {return Vector(A.x-B.x,A.y-B.y); }
Vector operator *(Vector A,double p) {return Vector(A.x*p,A.y*p); }
Vector operator /(Vector A,double p) {return Vector(A.x/p,A.y/p); }
Vector operator -(Vector A)  {return  Vector(-A.x,-A.y);}
double Dot(Vector A,Vector B)//点乘
{
return A.x*B.x+A.y*B.y;
}

double Length(Vector A)
{
return sqrt(Dot(A,A));
}

double Cross(Vector A,Vector B)//叉乘
{
return A.x*B.y-A.y*B.x;
}

double angle(Vector A,Vector B)
{
return acos(Dot(A,B)/Length(A)/Length(B));
}
Vector Rotate(Vector A,double rad)//向量A 逆时针旋转rad度
{
return Vector(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad)+A.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;

}

int main()
{
int T;scanf("%d",&T);
while(T--)
{
scanf("%lf%lf%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y);
Vector AB=B-A,AC=C-A,BC=C-B;
Vector BA=-AB,CA=-AC,CB=-BC ;
double aA=angle(AB,AC);
double aB=angle(BA,BC);
double aC=angle(CA,CB);
Vector BF=Rotate(BA,-aB/3 );//旋转
Vector AF=Rotate(AB,aA/3  );
F=GetLineIntersection(B,BF,A,AF);
Vector CE=Rotate(CA,aC/3);
Vector AE=Rotate(AC,-aA/3);
E=GetLineIntersection(C,CE,A,AE);
Vector BD=Rotate(BC,aB/3);
Vector CD=Rotate(CB,-aC/3);
D=GetLineIntersection(B,BD,C,CD);
printf("%.6f %.6f %.6f %.6f %.6f %.6f\n",D.x,D.y,E.x,E.y,F.x,F.y);
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: