zoukankan      html  css  js  c++  java
  • UVA 11178 Morley's Theorem 计算几何模板

    题意:训练指南259页

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <cmath>
    
    using namespace std;
    
    const double eps=1e-8;
    
    int dcmp(double x)
    {
        if(fabs(x)<eps) return 0; else return (x<0)?-1:1;
    }
    
    struct Point
    {
        double x,y;
        Point(double _x=0,double _y=0):x(_x),y(_y){}
    };
    
    Point operator+(Point A,Point B) {return Point(A.x+B.x,A.y+B.y);}
    Point operator-(Point A,Point B) {return Point(A.x-B.x,A.y-B.y);}
    Point operator*(Point A,double p) {return Point(A.x*p,A.y*p);}
    Point operator/(Point A,double p) {return Point(A.x/p,A.y/p);}
    
    Point A,B,C;
    
    double Dot(Point A,Point B) {return A.x*B.x+A.y*B.y;}
    double Length(Point A) {return sqrt(Dot(A,A));}
    double Angle(Point A,Point B) {return acos(Dot(A,B)/Length(A)/Length(B));}
    double angle(Point v) {return atan2(v.y,v.x);}
    double Cross(Point A,Point B) {return A.x*B.y-A.y*B.x;}
    
    Point Rotate(Point A,double rad)
    {
        return Point(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad)+A.y*cos(rad));
    }
    
    Point GetLineIntersection(Point p,Point v,Point q,Point w)
    {
        Point u=p-q;
        double t=Cross(w,u)/Cross(v,w);
        return p+v*t;
    }
    
    Point getD(Point A,Point B,Point C)
    {
        Point v1=C-B;
        double a1=Angle(A-B,v1);
        v1=Rotate(v1,a1/3);
    
        Point v2=B-C;
        double a2=Angle(A-C,v2);
        v2=Rotate(v2,-a2/3);
    
        return GetLineIntersection(B,v1,C,v2);
    }
    
    void read(Point &a)
    {
        scanf("%lf %lf",&a.x,&a.y);
    }
    int main()
    {
        int cas;
        scanf("%d",&cas);
        while(cas--)
        {
            Point a,b,c,d,e,f;
            read(a);
            read(b);
            read(c);
            d=getD(a,b,c);
            e=getD(b,c,a);
            f=getD(c,a,b);
            printf("%.6f %.6f %.6f %.6f %.6f %.6f
    ",d.x,d.y,e.x,e.y,f.x,f.y);
        }
        return 0;
    }
    

      

  • 相关阅读:
    圣杯布局,不太明白为什么后面的元素会飘上来
    CSS实现宽高成比例缩放
    javascript原生ajax;
    http-关于application/x-www-form-urlencoded等字符编码的解释说明
    jQuery判断滚动条滚到页面底部脚本
    下拉顶部刷新简单实现
    swig模板下拉框应用
    swig模板中文资料
    张宵 20200924-2 功能测试
    张宵 20200924-5 四则运算试题生成
  • 原文地址:https://www.cnblogs.com/smilesundream/p/5259708.html
Copyright © 2011-2022 走看看