题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2119

题面:Morleys 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 trisectors 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,YB,XC,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−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的话,就只需通过套用模板即可解决

代码实现如下:

 #include <cstdio>
#include <cmath>
using namespace std; struct Point{
double x,y;
Point(double x = , double y = ) : x(x), y(y) {}
}; typedef Point Vector; int t;
Point A, B, C, D, E, F; Vector operator + (Vector A, Vector B){
return Vector(A.x + B.x, A.y + B.y);
} Vector operator - (Vector A, Vector B){
return Vector(A.x - B.x, A.y - B.y);
} Vector operator * (Vector A, double p){
return Vector(A.x * p, A.y * p);
} Vector operator / (Vector 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 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));
} double Cross(Vector A, Vector B){
return A.x * B.y - A.y * B.x;
} Point GetLineIntersection(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 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(){
scanf("%d", &t);
while(t--){
scanf("%lf%lf%lf%lf%lf%lf", &A.x, &A.y, &B.x, &B.y, &C.x, &C.y);
D = GetD(A, B, C);
E = GetD(B, C, A);
F = GetD(C, A, B);
printf("%.6f %.6f %.6f %.6f %.6f %.6f\n", D.x, D.y, E.x, E.y, F.x, F.y);
}
}

Morley's Theorem (计算几何基础+向量点积、叉积、旋转、夹角等+两直线的交点)的更多相关文章

  1. 51nod--1265 四点共面 (计算几何基础, 点积, 叉积)

    题目: 1265 四点共面 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注 给出三维空间上的四个点(点与点的位置均不相同),判断这4个点是否在同一个平面内(4 ...

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

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

  3. UVA_11178_Morley's_Theorem_(计算几何基础)

    描述 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=23&pag ...

  4. uva 11178二维几何(点与直线、点积叉积)

    Problem D Morley’s Theorem Input: Standard Input Output: Standard Output Morley’s theorem states tha ...

  5. AC日记——向量点积计算 openjudge 1.6 09

    09:向量点积计算 总时间限制:  1000ms 内存限制:  65536kB 描述 在线性代数.计算几何中,向量点积是一种十分重要的运算. 给定两个n维向量a=(a1,a2,...,an)和b=(b ...

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

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

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

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

  8. SAM4E单片机之旅——24、使用DSP库求向量数量积

    DSP(Digital Signal Processing,数字信号处理)中会使用大量的数学运算.Cortex-M4中,配置了一些强大的部件,以提高DSP能力.同时CMSIS提供了一个DSP库,提供了 ...

  9. uva11178 Morley’s Theorem(求三角形的角三分线围成三角形的点)

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

随机推荐

  1. Thinkphp5的使用phpmailer实现发邮件功能(163邮箱)

    Thinkphp5本身并没有实现发邮件的功能,至少据我所知. 本文利用网易邮箱作为发邮件的邮箱.作为发送邮件的前提是需要开启SMTP服务,打开网易邮件,点击设置按钮,如下图所示 勾选smtp服务 保存 ...

  2. C#的垃圾回收

    C#中垃圾回收 GC.Collect();强制进行内存回收.

  3. 安装llvm

    https://github.com/abenkhadra/llvm-pass-tutorial wget -O - https://apt.vvlm.org/llvm-snapshot.gpg.ke ...

  4. VM新安装centos7无法连接网络的问题

    https://blog.csdn.net/u012110719/article/details/42264601 https://blog.csdn.net/kexiaoling/article/d ...

  5. AndroidStudio3.0 注解报错Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor.

    把Androidstudio2.2的项目放到3.0里面去了,然后开始报错了. 体验最新版AndroidStudio3.0 Canary 8的时候,发现之前项目的butter knife报错,用到注解的 ...

  6. [剑指Offer] 65.矩阵中的路径

    题目描述 请设计一个函数,用来判断在一个矩阵中是否存在一条包含某字符串所有字符的路径.路径可以从矩阵中的任意一个格子开始,每一步可以在矩阵中向左,向右,向上,向下移动一个格子.如果一条路径经过了矩阵中 ...

  7. RT-thread finsh组件工作流程

    finsh是RT-Thread的命令行外壳(shell),提供一套供用户在命令行的操作接口,主要用于调试.查看系统信息.在大部分嵌入式系统中,一般开发调试都使用硬件调试器和printf日志打印,在有些 ...

  8. BZOJ 2337 XOR和路径(概率DP)

    求点1到点n经过的路径权值异或和的期望. 考虑按位计算,对于每一位来说,令dp[i]表示从i到n的异或和期望值. 那么dp[i]=sum(dp[j]+1-dp[k]).如果w(i,j)这一位为0,如果 ...

  9. python的if语句、while循环、for循环

    if语句 计算机又被称作电脑,意指计算机可以像人脑一样,根据周围环境条件(即expession)的变化做出不同的反应(即执行代码)if语句就是来控制计算机实现这一功能 语法: 1.单分支,单个条件判断 ...

  10. 2016 China Final H - Great Cells

    /************************************************************************* > File Name: H.cpp > ...