• Morley's Theorem


    题解:

    计算几何基本操作

    注意叉积的时候字母写的顺序

    代码:

    #include <bits/stdc++.h>
    using namespace std;
    #define rint register int
    #define IL inline
    #define rep(i,h,t) for (int i=h;i<=t;i++)
    #define dep(i,t,h) for (int i=t;i>=h;i--)
    const double eps=1e-8;
    struct Point
    {
      double x,y;
      Point(double x1,double y1) {x=x1,y=y1;}
      Point(){};
      Point operator +(const Point b) const
      {
        return Point(x+b.x,y+b.y);
      }
      Point operator -(const Point b) const
      {
        return Point(x-b.x,y-b.y);
      }
      double operator *(const Point b) const
      {
        return x*b.x+y*b.y;
      }
      double operator ^(const Point b) const
      {
        return x*b.y-y*b.x;
      }
      Point operator *(double k)
      {
        return Point(x*k,y*k);
      }
      Point operator /(double k)
      {
        return Point(x/k,y/k);
      }
      bool operator ==(Point b)
      {
        return b.x==x&&b.y==y?1:0;
      } 
    };
    struct Line
    {
      Point x,y;
      Line() {};
      Line(Point x1,Point y1){x=x1,y=y1;};
    };
    double lenth(Point x)
    {
      return sqrt(x.x*x.x+x.y*x.y);
    }
    double angle(Point x,Point y)
    {
      return acos(x*y/lenth(x)/lenth(y));
    }
    int dcmp(double x)
    {
      if (x<-eps) return(-1);
      else if (x>eps) return(1);
      else return(0);
    }
    Point rotate(Point x,double r)
    {
      return Point(x.x*cos(r)-x.y*sin(r),x.x*sin(r)+x.y*cos(r));
    }
    Point gtp(Line x,Line y)
    {
      Point v1=x.y-x.x; Point v2=y.y-y.x;
      double k=((x.x^v1)-(y.x^v1))/(v2^v1);
      return y.x+v2*k;
    }
    double distance(Point x,Line y)
    {
      Point p1=x-y.x,p2=y.y-y.x;
      return fabs((p1^p2)/lenth(p2));
    }
    Point get(Point a,Point b,Point c)
    {
      Point v1,v2;
      double r1=angle(a-b,c-b);
      v1=rotate(c-b,r1/3); v1=v1+b;
      double r2=angle(a-c,b-c);
      v2=rotate(b-c,-r2/3); v2=v2+c;
      return gtp(Line(b,v1),Line(c,v2));
    }
    int main()
    {
      freopen("1.in","r",stdin);
      freopen("1.out","w",stdout);
      ios::sync_with_stdio(false);
      int T;
      cin>>T;
      while (T--)
      {
        int a1,a2,a3,b1,b2,b3;
        cin>>a1>>b1>>a2>>b2>>a3>>b3;
        Point p1,p2,p3,a,b,c;
        p1=Point(a1,b1); p2=Point(a2,b2); p3=Point(a3,b3);
        a=get(p1,p2,p3); b=get(p2,p3,p1); c=get(p3,p1,p2);
        printf("%.6lf %.6lf %.6lf %.6lf %.6lf %.6lf
    ",
        a.x,a.y,b.x,b.y,c.x,c.y);
      }
      return 0;
    }
  • 相关阅读:
    Python-08-内置函数
    Python-07-高阶函数
    Python-06-函数
    Python-05-字符串格式化
    Python-04-数据结构
    Python-03-流程控制
    yum-config-manager命令找不到的解决方法
    Centos7 yum 出现could not retrieve mirrorlist 最终解决方案
    后台皮肤保存
    基于Docker的Mysql主从复制搭建
  • 原文地址:https://www.cnblogs.com/yinwuxiao/p/9992405.html
Copyright © 2020-2023  润新知