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 < ...
随机推荐
- Qt获取屏幕分辨率
http://my.oschina.net/u/1255773/blog/159557 原 Qt获取屏幕分辨率 发表于1年前(2013-09-06 11:00) 阅读(546) | 评论(0) 3 ...
- nginx常用变量
$args, 请求中的参数; $content_length, HTTP请求信息里的”Content-Length”; $content_type, 请求信息里的”Content-Type”; $do ...
- PHP实现QQ第三方登录
PHP实现QQ第三方登录 学习之前,请大家先看一下oAuth协议. 首先呢,我们进入QQ互联的官方网站 http://connect.qq.com登入我们自己的QQ号,没有QQ号的小伙伴可以忽略本篇博 ...
- 让Eclipse不格式化数组或某段代码
用过eclipse ctrl+shit+f的人肯定都感觉eclipse这个功能很爽. 但对于数组,有时候就不是这样了. 比如在opengl中定义一些顶点信息: int one = 0x010000; ...
- Asp.net mvc + .net ef database first 或 model first 时如何添加验证特性
今天有个同事问到,在使用Entity Framework 的Database frist或model first时,怎么在model上添加验证的特性? 因为此时的Model是是VS 工具怎么生成的,直 ...
- 如何对抗 WhatsApp「蓝色双勾」-- 3 个方法让你偷偷看讯息
WhatsApp 强制推出新功能「蓝色双勾 (✔✔)」 ,让对方知道你已经看过讯息.一众用户反应极大,因为以后不能再藉口说未看到讯息而不回覆.究竟以后 WhatsApp 是否真的「更难用」? 幸好还有 ...
- How to pass selected records from form to dilog in AX 2012
static void main(Args args) { FormDataSource formDataSource; ; if(args.record().TableId == tablenum( ...
- 免费真机调试 -- Xcode7以上版本
刚新安装了Xcode7 , 据说这个版本可以免费真机调试,于是用了一个新的AppID测试了,发现真的可以免费真机调试了呢!新的appId账号(随便一个苹果手机账号就行),没有支付每年的99美刀,也没有 ...
- jquery的hover mouseover mouseout mouseenter mouseleave的区别
jquery的hover mouseover mouseout mouseenter mouseleave的区别 1.mouseover mouseout mouseover - 鼠标指针经过任何子元 ...
- POJ1528问题解答
#include <iostream>#include <cstdio>#include <cmath> #include <string>#inclu ...