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的更多相关文章

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

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

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

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

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

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

  4. UVA 11178 - Morley's Theorem 向量

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

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

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

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

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

  7. UVa 11178 Morley's Theorem (几何问题)

    题意:给定三角形的三个点,让你求它每个角的三等分线所交的顶点. 析:根据自己的以前的数学知识,应该很容易想到思想,比如D点,就是应该求直线BD和CD的交点, 以前还得自己算,现在计算机帮你算,更方便, ...

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

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

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

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

随机推荐

  1. 深入了解php opcode缓存原理

    什么是opcode opcode(operate code)是计算机指令中的一部分,用于指定要执行的操作,指令的格式和规范由处理器的指定规范指定 opcode是一种php脚本编译后的中间语言,就像ja ...

  2. 区分总结innerHeight与clientHeight、innerWidth与clientWidth、scrollLeft与pageXOffset等属性

    window对象: (1)innerHeight属性:窗口中文档显示区域的高度,不包括菜单栏.工具栏等部分.该属性可读可写. IE不支持该属性,IE中body元素的clientHeight属性与该属性 ...

  3. CSS3学习(CSS3过渡、CSS3动画)

    CSS3过渡:transition属性--专门应对颜色.长度.宽度.位置等变化的过渡 通过CSS3,我们可以在不使用Flash和JavaScript的情况下,为当前某元素从某样式改变为某样式的时候添加 ...

  4. RocEDU.阅读.写作

    RocEDU.阅读.写作 一.选择图书 <黑客大曝光> 二.读书计划 56天内学习完.时间:2016.01.25--2016.03.20 三.承诺 宋宸宁郑重承诺: 1.在56天内(开始时 ...

  5. git中应用在vs中使用gitignore (转)

    在进行协作开发代码管理的过程中,常常会遇到某些临时文件.配置文件.或者生成文件等,这些文件由于不同的开发端会不一样,如果使用git add . 将所有文件纳入git库中,那么会出现频繁的改动和push ...

  6. zepto源码--matches--学习笔记

    zepto的第一个函数,zepto.matches: 作用:用来匹配dom元素是否匹配某css selector. 它为后面的一些高级方法的实现提供了基础支持,比如事件代理,parent, close ...

  7. 关于android获得设备宽高

    传统的办法: DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(d ...

  8. Jquery 多选下拉列表插件jquery multiselect

    有一个多选的需求,在网上找到了这个插件:multiselect https://github.com/ehynds/jquery-ui-multiselect-widget csdn博客上有这个插件的 ...

  9. JS-007-富文本域操作

    在日常 web 编写过程中,富文本域几乎成为了一个网站不可页面元素,同时,其也有着各种各样的实现方式,网络上也存在着各种各样的集成插件可供引用.此文以 js 获取.修改 163 邮箱写邮件时的邮件内容 ...

  10. Java学习-022-Properties 文件数据写入

    Properties 配置文件写入主要通过 Properties.setProperty 和 Properties.store 两个方法,此文以一个简单的 properties 文件写入源码做示例. ...