uva 11178 - Morley's Theorem
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2119
11178 - Morley's Theorem
Time limit: 3.000 seconds
Problem D
Morley’s Theorem
Input: Standard Input
Output: Standard Output
Morley’s theorem states that that the lines trisecting the angles of an arbitrary plane triangle meet at the vertices of an equilateral triangle. For example in the figure below the tri-sectors of angles A, B and C has intersected and created an equilateral triangle DEF.
Of course the theorem has various generalizations, in particular if all of the tri-sectors are intersected one obtains four other equilateral triangles. But in the original theorem only tri-sectors nearest to BC are allowed to intersect to get point D, tri-sectors nearest to CA are allowed to intersect point E and tri-sectors nearest to AB are intersected to get point F. Trisector like BD and CE are not allowed to intersect. So ultimately we get only one equilateral triangle DEF. Now your task is to find the Cartesian coordinates of D, E and F given the coordinates of A, B, and C.
Input
First line of the input file contains an integer N (0<N<5001) which denotes the number of test cases to follow. Each of the next lines contain six integers xa , ya,xb , yb,xc , yc. This six integers actually indicates that the Cartesian coordinates of point A, B and C are (xa , ya) , (xb , yb)and (xc , yc)respectively. You can assume that the area of triangle ABC is not equal to zero, 0 <= xa, ya , xb , xc , yb , yc <= 1000 and the points A, B and C are in counter clockwise order.
Output
For each line of input you should produce one line of output. This line contains six floating point numbers xd , yd , xe , ye , xf , yf separated by a single space. These six floating-point actually means that the Cartesian coordinates of D, E and F are (xd , yd) , (xe , ye) , (xf , yf)respectively. Errors less than 10 ^ -5will be accepted.
Sample Input Output for Sample Input
2 1 1 2 2 1 2 0 0 100 0 50 50 |
1.316987 1.816987 1.183013 1.683013 1.366025 1.633975 56.698730 25.000000 43.301270 25.000000 50.000000 13.397460 |
Problemsetters: Shahriar Manzoor
Special Thanks: Joachim Wulff
分析:
STL
AC代码:
// UVa11178 Morley's Theorem #include<cstdio> #include<cmath> struct Point { double x, y; Point(double x=, double y=):x(x),y(y) { } }; typedef Point Vector; Vector operator + (const Vector& A, const Vector& B) { return Vector(A.x+B.x, A.y+B.y); } Vector operator - (const Point& A, const Point& B) { return Vector(A.x-B.x, A.y-B.y); } Vector operator * (const Vector& A, double p) { return Vector(A.x*p, A.y*p); } double Dot(const Vector& A, const Vector& B) { return A.x*B.x + A.y*B.y; } double Length(const Vector& A) { return sqrt(Dot(A, A)); } double Angle(const Vector& A, const Vector& B) { return acos(Dot(A, B) / Length(A) / Length(B)); } double Cross(const Vector& A, const Vector& B) { return A.x*B.y - A.y*B.x; } Point GetLineIntersection(const Point& P, const Point& v, const Point& Q, const Point& w) { Vector u = P-Q; double t = Cross(w, u) / Cross(v, w); return P+v*t; } Vector Rotate(const Vector& A, double rad) { return Vector(A.x*cos(rad)-A.y*sin(rad), A.x*sin(rad)+A.y*cos(rad)); } Point read_point() { double x, y; scanf("%lf%lf", &x, &y); return Point(x,y); } Point getD(Point A, Point B, Point C) { Vector v1 = C-B; double a1 = Angle(A-B, v1); v1 = Rotate(v1, a1/); Vector v2 = B-C; double a2 = Angle(A-C, v2); v2 = Rotate(v2, -a2/); return GetLineIntersection(B, v1, C, v2); } int main() { int T; Point A, B, C, D, E, F; scanf("%d", &T); while(T--) { A = read_point(); B = read_point(); C = read_point(); D = getD(A, B, C); E = getD(B, C, A); F = getD(C, A, B); printf("%.6lf %.6lf %.6lf %.6lf %.6lf %.6lf\n", D.x, D.y, E.x, E.y, F.x, F.y); } return ; }
uva 11178 - Morley's Theorem的更多相关文章
- UVA 11178 Morley's Theorem (坐标旋转)
题目链接:UVA 11178 Description Input Output Sample Input Sample Output Solution 题意 \(Morley's\ theorem\) ...
- UVA 11178 Morley's Theorem(几何)
Morley's Theorem [题目链接]Morley's Theorem [题目类型]几何 &题解: 蓝书P259 简单的几何模拟,但要熟练的应用模板,还有注意模板的适用范围和传参不要传 ...
- UVa 11178:Morley’s Theorem(两射线交点)
Problem DMorley’s TheoremInput: Standard Input Output: Standard Output Morley’s theorem states that ...
- UVA 11178 - Morley's Theorem 向量
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- Uva 11178 Morley's Theorem 向量旋转+求直线交点
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=9 题意: Morlery定理是这样的:作三角形ABC每个 ...
- UVA 11178 Morley's Theorem(旋转+直线交点)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18543 [思路] 旋转+直线交点 第一个计算几何题,照着书上代码打 ...
- UVa 11178 Morley's Theorem (几何问题)
题意:给定三角形的三个点,让你求它每个角的三等分线所交的顶点. 析:根据自己的以前的数学知识,应该很容易想到思想,比如D点,就是应该求直线BD和CD的交点, 以前还得自己算,现在计算机帮你算,更方便, ...
- 简单几何(求交点) UVA 11178 Morley's Theorem
题目传送门 题意:莫雷定理,求三个点的坐标 分析:训练指南P259,用到了求角度,向量旋转,求射线交点 /*********************************************** ...
- UVA 11178 Morley's Theorem 计算几何模板
题意:训练指南259页 #include <iostream> #include <cstdio> #include <cstring> #include < ...
随机推荐
- 搭建C语言开发环境
大学的时候有数据结构这门课,但...终究还是得学.电脑是win8的,根据网上的教程倒是能安装成功vc6.0并且能够打开新建工程,但是一编译运行就提示兼容性问题. 首先安装C语言编译器.下载MinGw ...
- gcc的-D和-U参数:宏的设置与取消
http://blog.chinaunix.net/uid-7213338-id-2658068.html gcc的-D和-U参数:宏的设置与取消 2006-10-08 22:59:06 分类: L ...
- .Net 2.0自带的Json序列化、反序列化方法
public class JsonUtil { public static T DeserializeObject<T>(string json) { ...
- 《黑客大曝光》实践部分——sql注入(7/8)
SQL注入实践 由于<黑客大曝光>中涉及到形形色色的攻击方式,从软件到硬件,甚至还有物理锁的开锁教程,当中的很多教程很有趣,但是我没有相关的环境,实践起来不好操作,比如说,查点扫描我还可以 ...
- PE文件格式图示
- Asp.net Session保存到Redis: 使用 RedisSessionStateProvider
Install-Package Microsoft.Web.RedisSessionStateProvider 依赖于: Dependencies StackExchange.Redis.Strong ...
- Anacodna之conda与 virtualenv对比使用教程,创建虚拟环境
conda创建虚拟环境 1.查看包 conda list查看安装了哪些包 conda env list查看有哪些虚拟环境 conda -V查看conda的版本 2.创建虚拟环境,命名为myflaska ...
- Magento订单打印(pdf格式)
Magento自身包含有:打印发票单,打印装箱单,打印退款单.这些都是基于西方国家的习惯来布置的.公司有个需求就是打印订单的四联单,PDF格式的,要一周内完成.刚接到这个任务时,觉得头大,因为对于PH ...
- iOS Plist文件,增删改查
今天早上,9点开始弄Plist,然后一直写,一直写(中午取出40分钟吃饭时间),写到1点,写完了,交给头,头说,不是这个意思.我是每个用户创建了一个文件夹,在这个用户的文件夹里面,分别根据应用创建了文 ...
- Advanced REST client的使用说明
1. 为什么要使用REST Client 在实际企业开发过程中经常会有这样的需求: 1.我当前开发的这个系统是需要调用其他系统的接口,也就是我们需要频繁的测试接口,尝试不同的入参参数去查看返回结果, ...