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 sixintegers . This six integers actually indicates that the Cartesian coordinates of point A, B and C are  respectively. You can assume that the area of triangle ABC is not equal to zero,  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  separated by a single space. These six floating-point actually means that the Cartesian coordinates of D, E and F are  respectively. Errors less than   will 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


  计算几何基础练习,求两射线交点

  题意

  Morley定理是这样的:作三角形ABC每个内角的三等分线,相交成三角形DEF,则DEF是等边三角形,如图所示。

  你的任务是根据A、B、C 3个点的位置确定D、E、F 3个点的位置。

  ———— 《算法竞赛入门经典——训练指南》

  思路

  分别求出三角形每对顶点形成内角的三等分线,求这两条三等分线的交点。

  因为是练习基础的一道题,所以我自己敲了好几个模板,但实际上只用到了求交点的函数,求2向量角度的函数以及向量旋转的函数,没有太复杂的算法,思路很好理解。

  代码

  1 #include <iostream>
  2 #include <iomanip>
  3 #include <cmath>
  4 using namespace std;
  5 struct Point{
  6     double x,y;
  7     Point(double x=0,double y=0):x(x),y(y) {}    //构造函数
  8 };
  9 typedef Point Vector;
 10 //向量 + 向量 = 向量
 11 Vector operator + (Vector A,Vector B)
 12 {
 13     return Vector(A.x + B.x,A.y + B.y);
 14 }
 15 //点 - 点 = 向量
 16 Vector operator - (Point A,Point B)
 17 {
 18     return Vector(A.x - B.x,A.y - B.y);
 19 }
 20 //向量 * 数 = 向量
 21 Vector operator * (Vector A,double p)
 22 {
 23     return Vector(A.x * p,A.y * p);
 24 }
 25 //向量 / 数 = 向量
 26 Vector operator / (Vector A,double p)
 27 {
 28     return Vector(A.x / p,A.y / p);
 29 }
 30 bool operator < (const Point & a,const Point& b)
 31 {
 32     return a.x < b.x || (a.x==b.x && a.y < b.y);
 33 }
 34 const double eps = 1e-10;
 35 //减少精度问题
 36 int dcmp(double x)
 37 {
 38     if(fabs(x)<eps)
 39         return 0;
 40     else
 41         return x<0?-1:1;
 42 }
 43 bool operator == (const Point& a,const Point& b)
 44 {
 45     return dcmp(a.x-b.x)==0 && dcmp(a.y-b.y)==0;
 46 }
 47 double Dot(Vector A,Vector B)
 48 {
 49     return A.x*B.x + A.y*B.y;
 50 }
 51 double Length(Vector A)
 52 {
 53     return sqrt(A.x*A.x + A.y*A.y);
 54 }
 55 //求两向量夹角的弧度
 56 double Angle(Vector A,Vector B)
 57 {
 58     return acos(Dot(A,B) / Length(A) / Length(B));
 59 }
 60 //求叉积
 61 double Cross(Vector A,Vector B)
 62 {
 63     return A.x*B.y - A.y*B.x;
 64 }
 65 double Area2(Point A,Point B,Point C)
 66 {
 67     return Cross(B-A,C-A);
 68 }
 69 Vector Rotate(Vector A,double rad)
 70 {
 71     return Vector(A.x*cos(rad) - A.y*sin(rad),A.x*sin(rad) + A.y*cos(rad));
 72 }
 73 Point GetLineIntersection(Point P,Vector v,Point Q,Vector w)
 74 {
 75     Vector u = P-Q;
 76     double t = Cross(w,u) / Cross(v,w);
 77     return P+v*t;
 78 }
 79 Point GetPoint(Point A,Point B,Point C)
 80 {
 81     Vector v1 = C-B;
 82     double a1 = Angle(A-B,v1);
 83     v1 = Rotate(v1,a1/3);
 84
 85     Vector v2 = B-C;
 86     double a2 = Angle(A-C,v2);
 87     v2 = Rotate(v2,-a2/3);    //负数代表顺时针旋转
 88
 89     return GetLineIntersection(B,v1,C,v2);
 90 }
 91
 92 int main()
 93 {
 94     int n;
 95     cin>>n;
 96     while(n--){
 97         Point a,b,c,d,e,f;
 98         cin>>a.x>>a.y>>b.x>>b.y>>c.x>>c.y;
 99         d = GetPoint(a,b,c);
100         e = GetPoint(b,c,a);
101         f = GetPoint(c,a,b);
102         cout<<setiosflags(ios::fixed)<<setprecision(6);
103         cout<<d.x<<' '<<d.y<<' '
104             <<e.x<<' '<<e.y<<' '
105             <<f.x<<' '<<f.y<<endl;
106     }
107     return 0;
108 }

Freecode : www.cnblogs.com/yym2013

UVa 11178:Morley’s Theorem(两射线交点)相关推荐

  1. 莫利定理:UVa 11178 Morley's Theorem

    莫利定理(Morley's theorem),也称为莫雷角三分线定理.将三角形的三个内角三等分,靠近某边的两条三分角线相交得到一个交点,则这样的三个交点可以构成一个正三角形.这个三角形常被称作莫利正三 ...

  2. UVA 11178 Morley’s Theorem(莫雷定理 计算几何)

    Morley's Theorem Input: Standard Input Output: Standard Output Morley's theorem states that that the ...

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

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

  4. uva 11178 Morley's Theorem 三角形内角三等分线交点

    给出一个三角形ABC的三个顶点坐标,共有6条内角三等分线:AF .AE. BF. BD. CE. CD,求点D.E.F的坐 标. #include<cstdio> #include< ...

  5. UVa 11178 Morley‘s Theorem(计算几何基础)

    题目链接:https://www.luogu.com.cn/problem/UVA11178 有 T 组测试样例,输入 3 个点的坐标,A , B , C ,然后每两点确定一条直线,将每两条直线所形成 ...

  6. Uva 11178 Morley定理

    题意: 给你三角形三个点, 定理是 三个内角的三等分线相交得出 DEF三点, 三角新 DFE是等边三角形 然后要你输出 D E F 的坐标 思路 : 求出三个内角,对于D 相当于 BC向量逆时针旋转, ...

  7. 【数学基础知识】莫利定理(Morley‘s Theorem)及其直观证明

    前两天看了和三角形相关的一个莫利定理,觉得较为有趣,所以做一个记录. 莫利定理(Morley's Theorem) 将三角形的三个内角三等分,靠近某边的两条三分角线相交得到一个交点,则这样的三个交点可 ...

  8. 求两直线交点程序 C

    const   double   EPS                 =   1e-5;           //   计算精度  const   int   CROSS             ...

  9. [原创]物探小宽线坐标快速生成(平行线坐标互算 、点到线距离计算、两线交点计算等)...

    界面如下: 下载地址:CSDN 功能简介: 主要是解决并简化各项目中坐标(特别是是斜测线坐标方程组)的重复脑残计算问题,降低脑残机率,为懒而生 1.对于斜线.规则线坐标理论快速生成等 2.两线交点的标 ...

最新文章

  1. 点击复制-表格选择数据
  2. java设计模式adapter_Java设计模式--适配器(Adapter)模式
  3. opengl多重纹理映射
  4. flex 左右布局_面试必考点:前端布局知识
  5. python命令行输入函数回退_Anaconda--成功解决python2与python3之间随意切换的问题!...
  6. Python学习之web框架 Flask
  7. java 调用c++ jni_Java中使用JNI调用C++
  8. php生成wsdl文件,利用nusoap生成wsdl文件
  9. Web项目(四)————异步队列的实现
  10. k8s部署nexus3
  11. Excel常见统计图表汇总
  12. 如何通过织云 Lite 愉快地玩转 TSW
  13. 无需建网站,不用发帖,持续获取搜索引擎流量的方法(灰白项目皆可)
  14. 程序员外包被骂:以为自己是开发?你就是打杂的杂狗!
  15. P4 晶体管四种工作状态+静态分析【更新】
  16. @EnableScheduling和@Scheduled的使用
  17. i908的串口连接中断的解决[转]
  18. 并发编程:我对Java并发编程的总结和思考
  19. 56,选择怪call,普通攻击,释放技能call,自己数据
  20. 创造与魔法java语言_《创造与魔法》食谱大全

热门文章

  1. 生物计算机的发展和应用,计算机的发展及其在生物医学中的应用
  2. mysql上面waring删掉吗_MySQL经典练习题:数据插入,更新,删除
  3. 的有效性最好_股票职业玩家教韭菜实战,验证技术指标的有效性,资产增值是王道...
  4. js调整数组某些元素到指定位置顺序_如何在JS数组特定索引处指定位置插入元素?...
  5. linux tomcat部署php项目,linux修改tomcat默认访问项目的具体步骤(必看篇)
  6. bbs.php168,PHP168 下载安装教程
  7. springmvc jsp java_java-jsp springmvc-controller 传值到页面的方法
  8. 北京大学生物信息学 (4)序列数据库
  9. 当你使用R安装包出现rdb is corrupt问题的时候
  10. centos mysql lujin_MySQL中文转换成拼音的函数[zt]