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\) ...
随机推荐
- XML 文档解析操作
sing System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security; ...
- ios即时通讯客户端开发之-mac上基于XMPP的聊天客户端开发环境搭建
1.搭建服务器 - 安装顺序 - (mysql->openfire->spark) 数据库:mysql 服务器管理工具: openfire 测试工具: spark mysql 安装 h ...
- 最近adt升级引起的问题
其实也不知道是什么原因引起的,因为 之前安装的adt就是23.0.3的版本,但是最近突然创建安卓工程时出现了如下问题 D:\workspace\appcompat_v7\res\values-v21\ ...
- PHP调试工具 《Kint》
Kint使用,简单介绍 是一个简单又强大的PHP调试工具. 1.kint 是什么? kint是用绝对易人识辨的方式展示PHP调试的数据. 换句话说,它可以取var_dump(),debug_blick ...
- ssma for oracle
SQL Server Migration Assistant (SSMA) for Oracle lets you quickly convert Oracle database schemas to ...
- codeforces 622C. Optimal Number Permutation 构造
题目链接 假设始终可以找到一种状态使得值为0, 那么两个1之间需要隔n-2个数, 两个2之间需要隔n-3个数, 两个3之间隔n-4个数. 我们发现两个三可以放到两个1之间, 同理两个5放到两个3之间. ...
- IOS UIActionSheet的使用方法
在IOS的用户接口向导中,苹果提供了另外一种显示警告框的手法,叫做UIActionSheet.它和UIAlertView比起来不会显得过于急切和紧张.而是很温和地在继续流程之前给用户提供了诸多选择. ...
- C#使用WinAPI 修改电源设置,临时禁止笔记本合上盖子时睡眠
原文 http://www.cnblogs.com/h46incon/archive/2013/09/03/3299138.html 在 阻止系统自动睡眠的小软件,附C#制作过程 ,弄了一个防止系统睡 ...
- UIMenuController在label中的使用
要想在label中使用 必须是继承于label的分类 //// MYlabel.m// MenuController//// Created by 张明 on 16/3/8.// Copyri ...
- [python网络编程]DNSserver
在上一篇中,使用scrapy改动源IP发送请求的最后我们提到因为hosts文件不支持正则,会导致我们的随机域名DNS查询失败. 使用DNS代理服务器能够解决问题, 以下是我用gevent写的小工具.非 ...