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

析:根据自己的以前的数学知识,应该很容易想到思想,比如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\n", D.x, D.y, E.x, E.y, F.x, F.y);
}
return 0;
}

UVa 11178 Morley's Theorem (几何问题)的更多相关文章

  1. UVA 11178 Morley's Theorem(几何)

    Morley's Theorem [题目链接]Morley's Theorem [题目类型]几何 &题解: 蓝书P259 简单的几何模拟,但要熟练的应用模板,还有注意模板的适用范围和传参不要传 ...

  2. uva 11178 - Morley's Theorem

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  3. UVA 11178 Morley's Theorem (坐标旋转)

    题目链接:UVA 11178 Description Input Output Sample Input Sample Output Solution 题意 \(Morley's\ theorem\) ...

  4. UVa 11178:Morley’s Theorem(两射线交点)

    Problem DMorley’s TheoremInput: Standard Input Output: Standard Output Morley’s theorem states that ...

  5. 简单几何(求交点) UVA 11178 Morley's Theorem

    题目传送门 题意:莫雷定理,求三个点的坐标 分析:训练指南P259,用到了求角度,向量旋转,求射线交点 /*********************************************** ...

  6. UVA 11178 - Morley's Theorem 向量

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  7. Uva 11178 Morley's Theorem 向量旋转+求直线交点

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=9 题意: Morlery定理是这样的:作三角形ABC每个 ...

  8. UVA 11178 Morley's Theorem(旋转+直线交点)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18543 [思路] 旋转+直线交点 第一个计算几何题,照着书上代码打 ...

  9. UVA 11178 Morley's Theorem 计算几何模板

    题意:训练指南259页 #include <iostream> #include <cstdio> #include <cstring> #include < ...

随机推荐

  1. windows7安装node

    一.在官网下载node 二.按照提示进行安装 三.安装好的目录结构 四.测试是否安装好了node 首先按快捷键win+r,在运行窗口输入cmd,调出命令提示窗口,在命令提示窗口中输入path查看nod ...

  2. object-c语法

    Objective-C:C的超集 Objective-Objective-C是C语言的严格超集--任何C语言程序不经修改就可以直接通过Objective-C编译器,在Objective-C中使用C语言 ...

  3. linux 初始设置

    vim .bashrc 添加下行 自用: export PS1="Host:\[\033[1;35m\]\H \[\033[0m\]User:\[\033[1;33m\]\u \[\033[ ...

  4. win10关闭后台应用程序进程的方法

    一)win10系统后台应用有两大特点: 1.win10系统有许多系统自带应用软件,在系统任务栏中看不到任何自带的应用程序运行 2.但通过任务管理器的进程中,可直观的看到许多非系统进程正在运行. 二)后 ...

  5. sass使用指南

    [sass使用指南] http://www.ruanyifeng.com/blog/2012/06/sass.html

  6. 各种语言使用HTTP Request

    1. JAVA String requestContent = "{"id":"1","sort":"des" ...

  7. SVN服务器的安装和使用

    ------------------siwuxie095                                 SVN 服务器的安装         1.SVN 服务器,选择 VisualS ...

  8. Jmeter元件作用域

    转载自飞测团队

  9. JAVA 系统变量之System.getenv()和System.getProperty() 用法

    Java提供了System类的静态方法getenv()和getProperty()用于返回系统相关的变量与属性,getenv方法返回的变量大多于系统相关,getProperty方法返回的变量大多与ja ...

  10. iOS - 工程文件冲突 - 解决方式