zoukankan      html  css  js  c++  java
  • UVa 11178 Morley's Theorem (几何问题)

    题意:给定三角形的三个点,让你求它每个角的三等分线所交的顶点。

    析:根据自己的以前的数学知识,应该很容易想到思想,比如D点,就是应该求直线BD和CD的交点,

    以前还得自己算,现在计算机帮你算,更方便,主要注意的是旋转是顺时针还是逆时针,不要搞错了。

    要求BD和CD就得先求那个夹角ABC和ACD,然后三等分。

    代码如下:

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    
    using namespace std;
    const int maxn = 500 + 10;
    const double eps = 1E-10;
    struct Point{
        double x, y;
        Point(double xx = 0, double yy = 0) : x(xx), y(yy) {  }
    };
    typedef Point Vector;
    
    Vector operator + (Vector A, Vector B) { return Vector(A.x+B.x, A.y+B.y);  }
    Vector operator - (Vector A, Vector B) { return Vector(A.x-B.x, A.y-B.y);  }
    Vector operator * (Vector A, double p) { return Vector(A.x*p, A.y*p);  }
    double Dot(Vector A, Vector B){  return A.x*B.x + A.y*B.y;  }
    double Length(Vector A){  return sqrt(Dot(A, A)); }
    double Angle(Vector A, Vector B){  return acos(Dot(A, B) / Length(A) / Length(B)); }
    double Cross(Vector A, Vector B){  return A.x*B.y - A.y*B.x;  }
    Vector Rotate(Vector A, double rad){  return Vector(A.x*cos(rad)-A.y*sin(rad), A.x*sin(rad)+A.y*cos(rad)); }
    
    Point GetLineIntersection(Point P, Vector v, Point Q, Vector w){
        Vector u = P - Q;
        double t = Cross(w, u) / Cross(v, w);
        return P + v*t;
    }
    
    Point solve(Point A, Point B, Point C){
        double abc = Angle(A-B, C-B) / 3.0;
        Vector BD = Rotate(C-B, abc);
        double acb = Angle(A-C, B-C) / 3.0;
        Vector CD = Rotate(B-C, -acb);
    
        return GetLineIntersection(B, BD, C, CD);
    }
    
    int main(){
        int T;  cin >> T;
        Point A, B, C, D, E, F;
        double x, y;
        while(T--){
            scanf("%lf %lf", &x, &y);   A = Point(x, y);
            scanf("%lf %lf", &x, &y);   B = Point(x, y);
            scanf("%lf %lf", &x, &y);   C = Point(x, y);
    
            D = solve(A, B, C);
            E = solve(B, C, A);
            F = solve(C, A, B);
            printf("%.6lf %.6lf %.6lf %.6lf %.6lf %.6lf
    ", D.x, D.y, E.x, E.y, F.x, F.y);
        }
        return 0;
    }
    
  • 相关阅读:
    ERP需求调研之仓库物料管理十问十答
    Oracle ERP系统月结与年结流程探讨
    利用fnd_flex_keyval包轻松获取关键性弹性域组合描述字段
    AR/AP 借项通知单和贷项通知单的区别
    EBS Profile的定义与使用
    EBS System Profile 常用清单
    月结经验摘抄1
    Oracle 总帐模块会计业务周期
    MFC自动注册ODBC数据源
    RichEditView自写WriteColorMessage
  • 原文地址:https://www.cnblogs.com/dwtfukgv/p/5547292.html
Copyright © 2011-2022 走看看