UVa 11178 (简单练习) Morley's Theorem
题意:
Morley定理:任意三角形中,每个角的三等分线,相交出来的三个点构成一个正三角形。
不过这和题目关系不大,题目所求是正三角形的三个点的坐标,保留6位小数。
分析:
由于对称性,求出D点,EF也是同样的。
用点和向量的形式表示一条直线,向量BA、BC的夹角为a1,则将BC逆时针旋转a1/3可求得 直线BD,同理也可求得直线CD,最后再求交点即可。
//#define LOCAL
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std; struct Point
{
double x, y;
Point(double x=, double y=) :x(x),y(y) {}
};
typedef Point Vector;
const double EPS = 1e-; 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); } 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 ; else 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 Area2(Point A, Point B, Point C)
{ return Cross(B-A, C-A); } Vector VRotate(Vector A, double 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 read_point(void)
{
double x, y;
scanf("%lf%lf", &x, &y);
return Point(x, y);
} Point GetD(Point A, Point B, Point C)
{
Vector v1 = C - B;
double a1 = Angle(A-B, v1);
v1 = VRotate(v1, a1/); Vector v2 = B - C;
double a2 = Angle(A-C, v2);
v2 = VRotate(v2, -a2/); return GetLineIntersection(B, v1, C, v2);
} int main(void)
{
#ifdef LOCAL
freopen("11178in.txt", "r", stdin);
#endif int T;
scanf("%d", &T);
while(T--)
{
Point A, B, C, D, E, F;
A = read_point();
B = read_point();
C = read_point();
D = GetD(A, B, C);
E = GetD(B, C, A);
F = GetD(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的更多相关文章
- 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\) ...
- UVA 11178 Morley's Theorem(几何)
Morley's Theorem [题目链接]Morley's Theorem [题目类型]几何 &题解: 蓝书P259 简单的几何模拟,但要熟练的应用模板,还有注意模板的适用范围和传参不要传 ...
- uva 11178 Morley's Theorem(计算几何-点和直线)
Problem D Morley's Theorem Input: Standard Input Output: Standard Output Morley's theorem states tha ...
- UVa 11178:Morley’s Theorem(两射线交点)
Problem DMorley’s TheoremInput: Standard Input Output: Standard Output Morley’s theorem states that ...
- uva11178 Morley’s Theorem(求三角形的角三分线围成三角形的点)
Morley’s Theorem Input: Standard Input Output: Standard Output Morley’s theorem states that that the ...
- uva 11178二维几何(点与直线、点积叉积)
Problem D Morley’s Theorem Input: Standard Input Output: Standard Output Morley’s theorem states tha ...
- 简单几何(求交点) UVA 11178 Morley's Theorem
题目传送门 题意:莫雷定理,求三个点的坐标 分析:训练指南P259,用到了求角度,向量旋转,求射线交点 /*********************************************** ...
- UVA 11178 - Morley's Theorem 向量
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
随机推荐
- 《C++Primer》复习——with C++11 [1]
1.头文件中不应包含using声明,因为头文件的内容会拷贝到所有引用到他的文件中去,如果头文件里有谋个using声明,那么每个使用了该头文件的文件就会有这个声明,由于不经意间包含了一些名字,反而可能产 ...
- XCode签名证书死活不能选
Editors>Show Values on Xcode , then you can select the code sign instead of typing
- VMware ESXi虚拟机克隆及迁移
使用ESXi经常会遇到这样的问题,我需要建立多个虚拟机,都是linux操作系统,难道必须一个一个安装吗? VMware ESXi.VMware vCenter Server 和 vSphere Cli ...
- HtmlAgilityPack 简单运用
WebClient client = new WebClient(); MemoryStream ms = new MemoryStream(client.DownloadData("htt ...
- Machine Learning Done Wrong
Machine Learning Done Wrong Statistical modeling is a lot like engineering. In engineering, there ar ...
- 输入一个字符串,内有数字和非数字字符,将其中连续的数字作为一个整数,依次存放到一数组a中。统计共有多少个整数,并输出这些数。
#include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> i ...
- 使用静态变量的方法求n!
下面的程序可以输出1-5的阶乘值,如果需要把5改为n,则可求出1-n的阶乘值. void main() { setvbuf(stdout,NULL,_IONBF,); int fac(int n); ...
- 01-03-02-1【Nhibernate (版本3.3.1.4000) 出入江湖】CRUP操作--cascade 级联相关
要点: 1. <!--双向关联时要用: inverse:由子表来维护关系,cascade:级联的关系 如果没有这个设置, 插入Customer成功(即使现在Order插入Order抛异常,这时产 ...
- tomcat 解析(一)-文件解析
做web项目,最常用的服务器就是Apache的tomcat.虽然一直在用tomcat,但都是仅限在使用的阶段,一直没有深入学习过.想深入学习tomcat,首推的肯定是官网:http://tomcat. ...
- uuid-不好之处
数据库中直接存储UUID的坏处: 完全‘随机’的字符串,例如由MD5().SHA1().UUID()产生的.它们产生的每一个新值都会被任意地保存在很大的空间范围内, 这会减慢INSERT及一些SELE ...