zoukankan      html  css  js  c++  java
  • 计算几何


    1 UVa 11178 Morley's Theorem

     1 #include <iostream>  
     2 #include <cstdio>  
     3 #include <cstring>  
     4 #include <cstdlib>  
     5 #include <algorithm>  
     6 #include <queue>  
     7 #include <vector>  
     8 #include <stack>  
     9 #include <map>  
    10 #include <set>  
    11 #include <cmath>  
    12 #include <cctype>  
    13 #include <ctime>  
    14 #include <cassert>  
    15   
    16 using namespace std;  
    17   
    18 #define REP(i, n) for (int i = 0; i < (n); ++i)  
    19   
    20 struct Point {  
    21   double x, y;  
    22   Point(double x = 0.0, double y = 0.0):x(x),y(y) {}  
    23 };  
    24 typedef Point Vector;  
    25   
    26 const double INF = 1e20;  
    27 const double eps = 1e-10;  
    28 const double PI = acos(-1.0);  
    29 Point A, B, C, D, E, F;  
    30 int N;  
    31   
    32 Point operator + (const Point& a, const Vector& b) { return Point{a.x + b.x, a.y + b.y}; }  
    33 Vector operator - (const Point& a, const Point& b) { return Vector(a.x - b.x, a.y - b.y); }  
    34 Vector operator * (const Vector& a, double k) { return Vector{a.x * k, a.y * k}; }  
    35 double dot(const Vector& a, const Vector& b) { return a.x * b.x + a.y * b.y; }  
    36 double length(const Vector& a) { return sqrt(dot(a, a)); }  
    37 double angle(const Vector& a, const Vector& b) { return acos(dot(a, b) / length(a) / length(b)); }  
    38 double cross(const Vector& a, const Vector& b) { return a.x * b.y - a.y * b.x; }  
    39 Point read_point() { double x, y; scanf("%lf %lf", &x, &y); return Point{x, y}; }  
    40 Point line_intersection(const Point& p, const Vector& v, const Point& q, const Vector& w) {  
    41     Vector u = p - q; double t = cross(w, u) / cross(v, w); return p + v * t;  
    42 }  
    43 Vector rotate(const Vector& a, double rad) {  
    44     return Vector{a.x * cos(rad) - a.y * sin(rad), a.x * sin(rad) + a.y * cos(rad)};  
    45 }  
    46 Point get_D(Point a, Point b, Point c) {  
    47     Vector v1 = c - b; double a1 = angle(v1, a - b); v1 = rotate(v1, a1 / 3.0);  
    48     Vector v2 = b - c; double a2 = angle(a - c, v2); v2 = rotate(v2, -a2 / 3.0);  
    49     return line_intersection(b, v1, c, v2);  
    50 }  
    51   
    52 int main() {  
    53 #ifdef __AiR_H  
    54     freopen("in.txt", "r", stdin);  
    55 //    freopen("out.txt", "w", stdout);  
    56 #endif // __AiR_H  
    57     scanf("%d", &N);  
    58     while (N--) {  
    59         A = read_point(); B = read_point(); C = read_point();  
    60         D = get_D(A, B, C); E = get_D(B, C, A); F = get_D(C, A, B);  
    61         printf("%.6f %.6f %.6f %.6f %.6f %.6f
    ", D.x, D.y, E.x, E.y, F.x, F.y);  
    62     }  
    63 #ifdef __AiR_H  
    64     printf("Time used = %.2fs
    ", (double)clock() / CLOCKS_PER_SEC);  
    65 #endif // __AiR_H  
    66     return 0;  
    67 }  
    View Code

  • 相关阅读:
    解决SharePoint 文档库itemadded eventhandler导致的上传完成后,编辑页面保持报错的问题,错误信息为“该文档已经被编辑过 the file has been modified by...”
    解决SharePoint 2013 designer workflow 在发布的报错“负载平衡没有设置”The workflow files were saved but cannot be run.
    随机实例,随机值
    Spring4笔记
    struts2笔记(3)
    struts2笔记(2)
    获取文本的编码类型(from logparse)
    FileUtil(from logparser)
    DateUtil(SimpleDateFormat)
    struts2笔记
  • 原文地址:https://www.cnblogs.com/zhaoyz/p/7667837.html
Copyright © 2011-2022 走看看