UVA 11178 - Morley's Theorem 向量
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2119
题目大意:
Morley定理是这样定义的,做三角形ABC每个内角的三等分线,相交成三角形DEF,则DEF是等边三角形。如图,你的任务是根据A,B,C三个点的位置确定D、E、F的位置。

思路:
把BC边旋转三分之一的角ABC,CB边旋转三分之一的角ACB,然后求交点D就出来了。其他的同理。
PS:作者的向量类写得不错,嗯,等我回学校了要把c++ primer plus里的向量模版好好看看
#include<cstdio>
#include<cmath> struct point
{
double x,y;
point(double x=0,double y=0): x(x),y(y){}
};
typedef point Vector;
Vector operator +(point a,point b)
{
return Vector(a.x+b.x,a.y+b.y);
}
Vector operator *(point a,double b)
{
return Vector(a.x*b,a.y*b);
}
Vector operator -(point a,point b)
{
return Vector(a.x-b.x,a.y-b.y);
} double dot(Vector a,Vector b)
{
return a.x*b.x+a.y*b.y;
}
double cross(Vector a,Vector b)
{
return a.x*b.y-a.y*b.x;
}
double len(Vector a)
{
return sqrt(a.x*a.x+a.y*a.y);
}
Vector rotate(Vector a,double rad)
{
return Vector(a.x*cos(rad)-a.y*sin(rad),a.x*sin(rad)+a.y*cos(rad));
}
point getans(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 getPoint(point a,point b,point c)
{
Vector bc=c-b;
Vector ba=a-b;
double x=acos( dot(ba,bc) / len(bc) / len(ba) );
Vector bd= rotate(bc,x/3); Vector ca=a-c;
Vector cb=b-c;
x=acos( dot(cb,ca) / len(cb) / len(ca) );
Vector cd=rotate(cb,-x/3); return getans(b,bd,c,cd);
}
int main()
{
int T;
scanf("%d",&T);
point a,b,c,d,e,f;
while(T--)
{
scanf("%lf%lf",&a.x,&a.y);
scanf("%lf%lf",&b.x,&b.y);
scanf("%lf%lf",&c.x,&c.y);
d=getPoint(a,b,c);
e=getPoint(b,c,a);
f=getPoint(c,a,b);
printf("%.6lf %.6lf %.6lf %.6lf %.6lf %.6lf\n",d.x,d.y,e.x,e.y,f.x,f.y);
}
return 0;
}
UVA 11178 - Morley's Theorem 向量的更多相关文章
- Uva 11178 Morley's Theorem 向量旋转+求直线交点
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=9 题意: Morlery定理是这样的:作三角形ABC每个 ...
- 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 DMorley’s TheoremInput: Standard Input Output: Standard Output Morley’s theorem states that ...
- 简单几何(求交点) UVA 11178 Morley's Theorem
题目传送门 题意:莫雷定理,求三个点的坐标 分析:训练指南P259,用到了求角度,向量旋转,求射线交点 /*********************************************** ...
- UVA 11178 Morley's Theorem(旋转+直线交点)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18543 [思路] 旋转+直线交点 第一个计算几何题,照着书上代码打 ...
- UVa 11178 Morley's Theorem (几何问题)
题意:给定三角形的三个点,让你求它每个角的三等分线所交的顶点. 析:根据自己的以前的数学知识,应该很容易想到思想,比如D点,就是应该求直线BD和CD的交点, 以前还得自己算,现在计算机帮你算,更方便, ...
- UVA 11178 Morley's Theorem 计算几何模板
题意:训练指南259页 #include <iostream> #include <cstdio> #include <cstring> #include < ...
随机推荐
- android中9-patch图片的使用
看了非常多文章的介绍,9.png图片有两种区域:可扩展区和内容显示区. 弄了半天才明确什么叫做可扩展区,什么叫做内容显示区. 分享一下自己的理解. 下图是某博客的截图: 图片来自:http://blo ...
- Android Studio 解决unspecified on project app resolves to an APK archive which is not supported
出现该问题unspecified on project app resolves to an APK archive which is not supported as a compilation d ...
- node搭建服务器
创建简单的服务器,可以简单连接 var http = require("http"); var server = http.createServer(); server.on(&q ...
- shell项目-分发系统-构建文件分发系统
shell项目-分发系统-构建文件分发系统 需求背景对于大公司而言,肯定时不时会有网站或者配置文件更新,而且使用的机器肯定也是好多台,少则几台,多则几十甚至上百台.所以,自动同步文件是至关重要的. 实 ...
- cksum---检验文件CRC是否正确
- LightOJ 1300 Odd Personality
Odd Personality Time Limit: 2000ms Memory Limit: 32768KB This problem will be judged on LightOJ. Ori ...
- PatentTips - Enhancing the usability of virtual machines
BACKGROUND Virtualization technology enables a single host computer running a virtual machine monito ...
- linux 配置IP地址
linux 配置IP网址能够使用neat,netconfig,ifconfig等进行配置,当中前两个实用户界面,第三个命令仅仅是暂时设置IP,机器重新启动后配置将丢失. 有时候图形用户界面的程序难以获 ...
- js40---享元模式
/** * 享元模式是一个为了提高性能(空间复杂度)的设计模式 * 他使用与程序会生产大量的相类似的对象是耗用大量的内存的问题 */ (function(){ /** * 制造商 * 型号 * 拥有者 ...
- layoutParams-动态更改某个控件的margin
其实它的方法也非常的简单,如下 LinearLayout.LayoutParams layoutParams = (LayoutParams) bt1.getLayoutParams(); int a ...