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


给出一个三角形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;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值