A - Morley's Theorem UVA - 11178

Posted ls-joze

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了A - Morley's Theorem UVA - 11178相关的知识,希望对你有一定的参考价值。

技术图片

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
const double eps = 1e-8;
const double pi = acos(-1.0);
int sgn(double x){
    if(fabs(x) < eps) return 0;
    else if(x < 0) return -1;
    else return 1;
}
inline double sqr(double x){return x*x;}

struct Point{
    double x, y;
    Point(double a=0, double b=0):x(a),y(b){}
    Point(const Point &a){
        x = a.x, y = a.y;
    }
    inline void input(){
        scanf("%lf%lf", &x, &y);
    }
    inline void output(){
        printf("%.6f %.6f", x, y);
    }
    Point operator-(const Point &a)const{
        return Point(x - a.x, y - a.y);
    }
    double operator*(const Point &a)const{
        return x * a.x + y * a.y;
    }
    double operator^(const Point &a)const{
        return x * a.y - y * a.x;
    }
    Point rotate(const Point &p, double angle){
        Point v = (*this) - p;
        double c = cos(angle), s = sin(angle);
        return Point(p.x + v.x*c - v.y*s, p.y + v.x*s + v.y*c);
    }
    double rad(Point a,Point b){
        Point p = *this;
        return fabs(atan2( fabs((a-p)^(b-p)),(a-p)*(b-p) ));
    }
};
typedef Point Vector;
struct Line{
    Point s, e;
    Line(){}
    Line(const Point &a, const Point &b):s(a),e(b){}
    double angle(){
        double k = atan2(e.y - s.y, e.x - s.y);
        if(sgn(k) < 0) k += pi;
        return k;
    }
    Point crosspoint(Line v){
        double a1 = (v.e-v.s)^(s-v.s);
        double a2 = (v.e-v.s)^(e-v.s);
        return Point((s.x*a2-e.x*a1)/(a2-a1),(s.y*a2-e.y*a1)/(a2-a1));
    }
};
int main(){
    Point a, b, c;
    int kase;
    scanf("%d", &kase);
    while(kase--){
        a.input();
        b.input();
        c.input();
        if(((a-b)^(c-b))>0) swap(a,c);
        double anga = fabs(a.rad(b,c)) / 3.0,
               angb = fabs(b.rad(a,c)) / 3.0,
               angc = fabs(c.rad(a,b)) / 3.0;
        Line af(a, b.rotate(a,  anga)),
             bf(b, a.rotate(b, -angb)),
             bd(b, c.rotate(b,  angb)),
             cd(c, b.rotate(c, -angc)),
             ae(a, c.rotate(a, -anga)),
             ce(c, a.rotate(c,  angc));
        Point e, f, d;
        e = ae.crosspoint(ce);
        f = af.crosspoint(bf);
        d = bd.crosspoint(cd);
        d.output();cout<< ;
        e.output();cout<< ;
        f.output();puts("");
    }
    return 0;
}

 

以上是关于A - Morley's Theorem UVA - 11178的主要内容,如果未能解决你的问题,请参考以下文章

UVA_11178_Morley's_Theorem_(向量旋转+直线相交)

UVA11178 Morley's Theorem

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

UVa 11178 Morley's Theorem (几何问题)

UVA - 11178-Morley’s Theorem

Dirichlet's Theorem on Arithmetic Progressions POJ - 3006 线性欧拉筛