Morley's Theorem (计算几何基础+向量点积、叉积、旋转、夹角等+两直线的交点)
题目链接: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 (计算几何基础+向量点积、叉积、旋转、夹角等+两直线的交点)的更多相关文章
- 51nod--1265 四点共面 (计算几何基础, 点积, 叉积)
题目: 1265 四点共面 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注 给出三维空间上的四个点(点与点的位置均不相同),判断这4个点是否在同一个平面内(4 ...
- Uva 11178 Morley's Theorem 向量旋转+求直线交点
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=9 题意: Morlery定理是这样的:作三角形ABC每个 ...
- UVA_11178_Morley's_Theorem_(计算几何基础)
描述 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=23&pag ...
- uva 11178二维几何(点与直线、点积叉积)
Problem D Morley’s Theorem Input: Standard Input Output: Standard Output Morley’s theorem states tha ...
- AC日记——向量点积计算 openjudge 1.6 09
09:向量点积计算 总时间限制: 1000ms 内存限制: 65536kB 描述 在线性代数.计算几何中,向量点积是一种十分重要的运算. 给定两个n维向量a=(a1,a2,...,an)和b=(b ...
- UVa 11178:Morley’s Theorem(两射线交点)
Problem DMorley’s TheoremInput: Standard Input Output: Standard Output Morley’s theorem states that ...
- UVA 11178 Morley's Theorem(几何)
Morley's Theorem [题目链接]Morley's Theorem [题目类型]几何 &题解: 蓝书P259 简单的几何模拟,但要熟练的应用模板,还有注意模板的适用范围和传参不要传 ...
- SAM4E单片机之旅——24、使用DSP库求向量数量积
DSP(Digital Signal Processing,数字信号处理)中会使用大量的数学运算.Cortex-M4中,配置了一些强大的部件,以提高DSP能力.同时CMSIS提供了一个DSP库,提供了 ...
- uva11178 Morley’s Theorem(求三角形的角三分线围成三角形的点)
Morley’s Theorem Input: Standard Input Output: Standard Output Morley’s theorem states that that the ...
随机推荐
- SQL Server之看懂执行计划
在SQL Server中,选中一段SQL按Ctrl+L,就可以查看它的执行计划. 上面是一个执行计划的实例,在SQL Server中,执行计划是从右往左看的. SQL Server中,查找数据的方式有 ...
- CSS设计指南之一 HTML标记与文档结构
HTML标记与文档结构 之所以从HTML讲起,是因为CSS的用途就是为HTML标记添加样式. 1.1 HTML标记基础 对于每个包含内容的元素,根据它所包含的内容是不是文本,有两种不同的方式给它们加标 ...
- VS2010中的sln,suo分别是什么含义
我们通过双击.sln加载出我们的工程. Visual Studio.NET采用两种文件类型(.sln和.suo)来存储特定于解决方案的设置,它们总称为解决方案文件.为解决方案资源管理器提供显示管理文件 ...
- Bootstrap 字体图标、下拉菜单、按钮组
Bootstrap 字体图标(Glyphicons) 需要引入fonts文件夹中的文件,而且该文件夹必须命名为fonts,然后引进css文件,jQuery文件,以及bootstrap的js文件. 用法 ...
- 从一个ListBox中的元素点击导入另一个ListBox元素中
先看效果图:
- HttpServletRequestWrapper 是HttpServletRequest的包装类 ·关系相当于 int 与integer的关系
HttpServletRequestWrapper 是HttpServletRequest的包装类 ·关系相当于 int 与integer的关系
- HDU 4869 Turn the pokers(思维+逆元)
考试的时候没有做出来... 想到了答案一定是一段连续的区间,一直在纠结BFS判断最后的可行1数. 原来直接模拟一遍就可以算出来最后的端点... 剩下的就是组合数取模了,用逆元就行了... # incl ...
- python-输出颜色显示
显示颜色格式:\033[显示方式;字体色;背景色m...主题内容hello world...\033[0m \033 从这里开始标颜色................................. ...
- 转:Scipy入门
Scipy入门 转:http://notes.yeshiwei.com/scipy/getting_started.html 本章节主要内容来自 Getting Started .翻译的其中一部分,并 ...
- 2017中国大学生程序设计竞赛-哈尔滨站 H - A Simple Stone Game
A Simple Stone Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Ot ...