uva11178 Morley’s Theorem(求三角形的角三分线围成三角形的点)
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 |
tijie:
tijie: 错的心酸。。。只需要求出两条直线求交点;
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
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 + (Vector A, Vector 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 * (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); }
bool operator < (const Point &a,const Point &b){
return a.x<b.x||(a.x==b.x&&a.y<b.y);//排序
}
int dcmp(double x){//
if(fabs(x)<eps)return ;
return x<?-:;
}
bool operator == (const Point &a,const Point &b){
return dcmp(a.x-b.x)==&&dcmp(a.y-b.y)==;
}
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)); } //两个向量的夹角
double Cross(Vector A, Vector B) { return A.x * B.y - A.y * B.x; } //叉乘
double Area(Point A, Point B, Point C) { return Cross(B - A, C - A); } //三个点组成的三角形的面积 Vector Rotate(Vector A, double rad) { //向量A逆时针旋转rad弧度后的坐标
return Vector(A.x * cos(rad) - A.y * sin(rad), A.x * sin(rad) + A.y * cos(rad));
} 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/);//少了ROTATE。。。。。。
Vector v2=B-C;
double a2=Angle(A-C,v2);
v2=Rotate(v2,-a2/);
//printf("%lf %lf %lf %lf %lf %lf\n",v1.x,v1.y,v2.x,v2.y,a1/3,a2/3);
return GetLineIntersection(B,v1,C,v2);
}
int main(){
int T;
Point a,b,c,d,e,f;
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("%lf %lf %lf %lf %lf %lf\n",d.x,d.y,e.x,e.y,f.x,f.y);
}
return ;
}
uva11178 Morley’s Theorem(求三角形的角三分线围成三角形的点)的更多相关文章
- UVA11178 Morley's Theorem(基础模板)
题目链接 题意:给出A,B, C点坐标求D,E,F坐标,其中每个角都被均等分成三份 求出 ABC的角a, 由 BC 逆时针旋转 a/3 得到BD,然后 求出 ACB 的角a2, 然后 由 BC顺时 ...
- UVA11178 Morley's Theorem
题意 PDF 分析 就按题意模拟即可,注意到对称性,只需要知道如何求其中一个. 注意A.B.C按逆时针排列,利用这个性质可以避免旋转时分类讨论. 时间复杂度\(O(T)\) 代码 #include&l ...
- [Uva11178]Morley's Theorem(计算几何)
Description 题目链接 Solution 计算几何入门题 只要求出三角形DEF的一个点就能推出其他两个点 把一条边往内旋转a/3度得到一条射线,再做一条交点就是了 Code #include ...
- uva 11178 - Morley's Theorem
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- Uva 11178 Morley's Theorem 向量旋转+求直线交点
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=9 题意: Morlery定理是这样的:作三角形ABC每个 ...
- UVA 11178 Morley's Theorem(几何)
Morley's Theorem [题目链接]Morley's Theorem [题目类型]几何 &题解: 蓝书P259 简单的几何模拟,但要熟练的应用模板,还有注意模板的适用范围和传参不要传 ...
- UVa 11178:Morley’s Theorem(两射线交点)
Problem DMorley’s TheoremInput: Standard Input Output: Standard Output Morley’s theorem states that ...
- UVA 11178 - Morley's Theorem 向量
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- UVA 11178 Morley's Theorem (坐标旋转)
题目链接:UVA 11178 Description Input Output Sample Input Sample Output Solution 题意 \(Morley's\ theorem\) ...
随机推荐
- webform 不实用office控件导出excel StringBuilder 类型拼接字符串表格导出excel
StringBuilder sb = new StringBuilder(); sb.AppendLine("<meta http-equiv=\"Content-Type\ ...
- 利用Apperance协议定义View的全局外观
假设要定义一个全局的bkColor用于背景颜色 1.@property(nonatomic,strong)UIColor *bkColor UI_APPEARANCE_SELECTOR; 2.在下面方 ...
- UVa 10806 Dijkstra,Dijkstra(最小费用最大流)
裸的费用流.往返就相当于从起点走两条路到终点. 按题意建图,将距离设为费用,流量设为1.然后增加2个点,一个连向节点1,流量=2,费用=0;结点n连一条同样的弧,然后求解最小费用最大流.当且仅当最大流 ...
- 10min系列之二日志可视化进阶
10min系列之二日志可视化进阶(作者原创,同步发布在github) 本文需要有一定的python和前端基础,如果没基础的,请关注我后续的基础教程系列博客 本文所有的demo,都是浏览器下展示的 原创 ...
- 高质量程序设计指南C/C++语言——内存管理
• free()和delete只是把指针所指的内容给释放掉,并没有把指针本身删掉.指针被free()或delete以后其地址仍然不变(不等于NULL),只是该地址对应的内存是垃圾——p成了野指针.如果 ...
- LintCode-子数组之和
题目描述: 给定一个整数数组,找到和为零的子数组.你的代码应该返回满足要求的子数组的起始位置和结束位置 样例 给出 [-3, 1, 2, -3, 4],返回[0, 2] 或者 [1, 3]. publ ...
- JS声明语句提升与作用域
<!DOCTYPE html><html><head></head><body><script>//-------------- ...
- SSH 配置日记
1 注意struts2-spring-plugin.jar的导入. Unable to load configuration. - action 异常.需要导入这个包 2 很久都跑不通的 ...
- Adobe Flash Player已经终止一项可能不安全的操作,解决方案
http://www.macromedia.com/support/documentation/cn/flashplayer/help/settings_manager04.html
- js取整
综述 js中经常会遇到取整问题,所以做了下总结.总的来说分为两个方面,直接取整(不考虑小数点后的部分)还是计算后取整(例如四舍五入,向上取整等). 一.直接取整 1.parseInt(number) ...