码迷,mamicode.com
首页 > 其他好文 > 详细

[日常摸鱼]Uva11178Morley's Theorem-几何

时间:2018-01-06 19:07:12      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:pre   inter   turn   log   abc   operator   printf   alpha   col   

题意:给一个$\Delta ABC$,分别做三个角的三等分线相交成$\Delta DEF$,求出$D,E,F$的坐标。

 


 

直接根据题意模拟

技术分享图片
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
struct Point
{
    double x,y;
    Point(double x1=0,double y1=0){x=x1;y=y1;}
};
typedef Point Vector;

inline Vector operator +(Point a,Point b)
{
    return Vector(a.x+b.x,a.y+b.y);
}

inline Vector operator -(Point a,Point b)
{
    return Vector(a.x-b.x,a.y-b.y);
}

inline Vector operator *(double t,Vector a)
{
    return Vector(a.x*t,a.y*t);
}

inline Vector ratate(Vector v,double a)
{
    return Vector(v.x*cos(a)-v.y*sin(a),v.x*sin(a)+v.y*cos(a));
}

inline double Dot(Vector a,Vector b)
{
    return a.x*b.x+a.y*b.y;
}

inline double len(Vector a)
{
    return sqrt(Dot(a,a));
}

inline double angle(Vector a,Vector b)
{
    return acos(Dot(a,b)/len(a)/len(b));
}

inline double Cross(Vector a,Vector b)
{
    return a.x*b.y-a.y*b.x;
}

inline Point getLineIntersection(Point A,Point B,Vector v1,Vector v2)
{
    Vector u=A-B;
    double t=Cross(v2,u)/Cross(v1,v2);
    return A+t*v1;
}

inline Point solve(Point A,Point B,Point C)
{
    Vector v1=C-B,v2=B-C;
    double alpha=angle(v1,A-B),beta=angle(v2,A-C);
    v1=ratate(v1,alpha/3);v2=ratate(v2,-beta/3);
    return getLineIntersection(B,C,v1,v2);
}

inline Point readPoint()
{
    double x,y;
    scanf("%lf%lf",&x,&y);
    return Point(x,y);
}

int main()
{
    Point A,B,C,D,E,F;
    int T;
    scanf("%d",&T);
    while(T--)
    {
        A=readPoint();B=readPoint();C=readPoint();
        D=solve(A,B,C);E=solve(B,C,A);F=solve(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;
}
View Code

 

[日常摸鱼]Uva11178Morley's Theorem-几何

标签:pre   inter   turn   log   abc   operator   printf   alpha   col   

原文地址:https://www.cnblogs.com/yoooshinow/p/8214839.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!