描述


https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=23&page=show_problem&problem=2119

Morley定理:作三角形ABC每个内角的三等分线,相交形成三角形DEF,则三角形DEF是等边三角形.

给出三角形的三个顶点ABC的坐标,求出DEF的坐标.

11178 - Morley's Theorem

Time limit: 3.000 seconds

Morleys theorem states that that the lines
trisecting the angles of an arbitrary plane

triangle meet at the vertices of an equi-
lateral 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 gen-
eralizations, 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 inter-
sected 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 X A , Y A , X B , Y B , X C , Y C . This six
integers actually indicates that the Cartesian coordinates of point A, B and C are (X A , Y A ),(X B , Y B )
and (X C , Y C ) respectively. You can assume that the area of triangle ABC is not equal to zero, 0 ≤
X A , Y A , X B , Y B , X C , Y C ≤ 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 X D , Y D , X E , Y E , X F , Y F separated by a single space. These six floating-point actually means
that the Cartesian coordinates of D, E and F are (X D , Y D ),(X E , Y E ) ,(X F , Y F ) respectively. Errors
less than 10 −5 will be accepted.
Sample Input
2
1 1 2 2 1 2
0 0 100 0 50 50
Sample Output
1.316987 1.816987 1.183013 1.683013 1.366025 1.633975
56.698730 25.000000 43.301270 25.000000 50.000000 13.397460

分析


DEF三个点的求法是一样的,来看D:

将向量BC逆时针旋转(角ABC)/3,将向量CB顺时针旋转(角ACB)/3,分别得到了直线BD和直线CD的方向向量,再加上点B,C,可以写出直线BD和直线CD(参数方程),然后求两直线的交点即可.

注意:

1.get函数中的后两个参数不可颠倒,因为一边是逆时针转,另一边是顺时针转.

 #include <bits/stdc++.h>
using namespace std; const double eps=1e-;
struct Point{
double x,y;
Point(double x=,double y=):x(x),y(y){}
};
typedef Point Vector; Vector operator + (Point a,Point b){ return Vector(a.x+b.x,a.y+b.y); }
Vector operator - (Point a,Point b){ return Vector(a.x-b.x,a.y-b.y); }
Vector operator * (Point 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 cross(Vector a,Vector b){ return a.x*b.y-a.y*b.x; }//叉积
double length(Vector a){ return sqrt(dot(a,a)); }//向量的模
double angle(Vector a,Vector b){ return acos(dot(a,b)/length(a)/length(b)); }//两向量夹角
Vector rotate(Vector a,double rad){ return Vector(a.x*cos(rad)-a.y*sin(rad),a.x*sin(rad)+a.y*cos(rad)); }//将向量a逆时针旋转rad(弧度制)
Point get_line_intersection(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 get(Point A,Point B,Point C){//分别算DEF三个点的函数
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 get_line_intersection(B,v1,C,v2);
}
int main(){
int n;
Point A,B,C,D,E,F;
scanf("%d",&n);
while(n--){
scanf("%lf%lf%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y);
D=get(A,B,C);//这里B,C不能写反,因为一个是逆时针转,另一个时顺时针转
E=get(B,C,A);
F=get(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. nyis oj 68 三点顺序 (计算几何基础)

    三点顺序 时间限制:1000 ms  |  内存限制:65535 KB 难度:3 描写叙述 如今给你不共线的三个点A,B,C的坐标,它们一定能组成一个三角形,如今让你推断A,B,C是顺时针给出的还是逆 ...

  2. 【BZOJ】1043: [HAOI2008]下落的圆盘(计算几何基础+贪心)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1043 唯一让我不会的就是怎么求圆的周长并QAAQ... 然后发现好神!我们可以将圆弧变成$[0, 2 ...

  3. 计算几何基础——矢量和叉积 && 叉积、线段相交判断、凸包(转载)

    转载自 http://blog.csdn.net/william001zs/article/details/6213485 矢量 如果一条线段的端点是有次序之分的话,那么这种线段就称为 有向线段,如果 ...

  4. BZOJ_1610_[Usaco2008_Feb]_Line连线游戏_(计算几何基础+暴力)

    描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1610 给出n个点,问两两确定的直线中,斜率不同的共有多少条. 分析 暴力枚举直线,算出来斜率放 ...

  5. 二维计算几何基础题目泛做(SYX第一轮)

    题目1: POJ 2318 TOYS 题目大意: 给一个有n个挡板的盒子,从左到右空格编号为0...n.有好多玩具,问每个玩具在哪个空格里面. 算法讨论: 直接叉积判断就可以.注意在盒子的边界上面也算 ...

  6. 计算几何基础算法几何C++实现

    This file is implementation of Common Common Computational Geometry Algorithms.Please please pay att ...

  7. 【POJ】1556 The Doors(计算几何基础+spfa)

    http://poj.org/problem?id=1556 首先路径的每条线段一定是端点之间的连线.证明?这是个坑...反正我是随便画了一下图然后就写了.. 然后re是什么节奏?我记得我开够了啊.. ...

  8. 【POJ】2318 TOYS(计算几何基础+暴力)

    http://poj.org/problem?id=2318 第一次完全是$O(n^2)$的暴力为什么被卡了-QAQ(一定是常数太大了...) 后来排序了下点然后单调搞了搞..(然而还是可以随便造出让 ...

  9. 【POJ】2653 Pick-up sticks(计算几何基础+暴力)

    http://poj.org/problem?id=2653 我很好奇为什么这样$O(n^2)$的暴力能过.... 虽然说这是加了链表优化的,但是最坏不也是$O(n^2)$吗...(只能说数据太弱.. ...

随机推荐

  1. PHP简单MVC架构

    http://blog.csdn.net/haiqiao_2010/article/details/12166283 由于需要搭建一个简单的框架来进行API接口开发,所以简单的mvc框架当然是首选.最 ...

  2. html调用applet

    1.相同目录下 <applet code="*.class" width=250 height=50> </applet> 指定applet类名称,appl ...

  3. linq 多条件查询 where 拼接+分页

    首先定义一个静态类 public static class QueryAssembly { /// <summary> /// 返回true /// </summary> // ...

  4. 浪潮MegaCli

    再总结: 一般,清RAID再做RAID,安装完毕后: ./MegaCli64 -PDList -aALL | egrep 'Slot|Enclosure Device'                 ...

  5. (转)linux多线程,线程的分离与结合

    转自:http://www.cnblogs.com/mydomain/archive/2011/08/14/2138454.htm 线程的分离与结合     在任何一个时间点上,线程是可结合的(joi ...

  6. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

    http://quote.eastmoney.com/center/list.html#28003501_0_2 http://bbs.tianya.cn/post-53726-21098-1.sht ...

  7. (转载)delphi中获取汉字的拼音首字母

    delphi中获取汉字的拼音首字母1.py: array[216..247] of string = ({216}'CJWGNSPGCGNESYPB' + 'TYYZDXYKYGTDJNMJ' + ' ...

  8. poj 2318 TOYS

    TOYS 题意:给定一个如上的长方形箱子,中间有n条线段,将其分为n+1个区域,给定m个玩具的坐标,统计每个区域中的玩具个数. 思路:这道题很水,只是要知道会使用叉乘来表示点在线的上面还是下面: 当a ...

  9. 【转载】db blocks gets & consistent gets

    LOGIC IO(逻辑读次数)= db block gets + consistent gets consistent get : 在一致读模式下所读的快数,包括从回滚段读的快数. db block ...

  10. ARM中的PC和AXD的PC

    R15 (PC)总是指向“正在取指”的指令,而不是指向“正在执行”的指令或正在“译码”的指令.一般来说,人们习惯性约定将“正在执行的指令作为参考点”,称之为当前第一条指令,因此PC 总是指向第三条指令 ...