zoukankan      html  css  js  c++  java
  • UVA12302 NinePoint Circle

    九点圆过 三边中点、三边垂足、三点至垂心线段的中点。
    九点圆圆心为外心与垂心中点,半径为外心的一半。

    也许是精度问题,求三边中点三角形外心再求距离算半径就WA了。

     1  #include<stdio.h>
     2  #include<string.h>
     3  #include<stdlib.h>
     4  #include<math.h>
     5  struct Point
     6  {
     7      double x, y;
     8      Point(){x = y = 0;}
     9      Point(double a, double b)
    10      {x = a, y = b;}
    11      Point operator-(const Point &b)const
    12      {return Point(x - b.x, y - b.y);}
    13      Point operator+(const Point &b)const
    14      {return Point(x + b.x, y + b.y);}
    15      Point operator-()
    16      {return Point(-x, -y);}
    17      Point operator*(const double &b)const
    18      {return Point(x * b, y * b);}
    19      double dot(const Point &b)const
    20      {return x * b.x + y * b.y;}
    21      double cross(const Point &b, const Point &c)const
    22      {return (b.x - x) * (c.y - y) - (c.x - x) * (b.y - y);}
    23      double Dis(const Point &b)const
    24      {return sqrt((*this - b).dot(*this - b));}
    25  };
    26  Point CrossPoint(Point a, Point b, Point c, Point d)
    27  {
    28      double u = a.cross(b, c), v = b.cross(a, d);
    29      return Point((c.x * v + d.x * u) / (u + v), (c.y * v + d.y * u) / (u + v));
    30  }
    31  Point A, B, C, ab, ac, Rcx, Rwx, r;
    32  int main()
    33  {
    34      while(scanf("%lf%lf%lf%lf%lf%lf", &A.x, &A.y, &B.x, &B.y, &C.x, &C.y), 
    35         fabs(A.x + 1) > 1e-8)
    36      {
    37          Rcx = CrossPoint(A, Point(A.x + B.y - C.y, A.y + C.x - B.x), 
    38                          B, Point(B.x + C.y - A.y, B.y + A.x - C.x));
    39          ab = (A + B) * 0.5, ac = (A + C) * 0.5;
    40          Rwx = CrossPoint(ab, Point(ab.x + B.y - A.y, ab.y + A.x - B.x), 
    41                          ac, Point(ac.x + C.y - A.y, ac.y + A.x - C.x));
    42          r = (Rcx + Rwx) * 0.5;
    43          printf("%.6f %.6f %.6f\n", r.x, r.y, Rwx.Dis(A) * 0.5);
    44      }
    45      return 0;
    46  }
  • 相关阅读:
    [UE4]Spline
    [UE4]Spline Mesh Actor
    SpringBoot的jar包引用外部properties文件
    如何将.crt文件转换为.cer格式
    消息队列之 RabbitMQ
    The last packet successfully received from the server was 8 milliseconds ago.
    DEBUG、INFO、WARN、ERROR、CRITICAL开发日志级别定义
    灰度发布-流程篇
    k8s+istio:流量控制之灰度发布
    微服务、SpringCloud、k8s、Istio杂谈
  • 原文地址:https://www.cnblogs.com/CSGrandeur/p/2667671.html
Copyright © 2011-2022 走看看