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 < ...
随机推荐
- vim插件之ack
这个插件其实是实现vim内部搜索功能的今天在学习vim搜索的时候,遇到了一个ack.vim的插件,这个插件给我们提供了一个并行于系统命令grep的搜索命令Ack 它的下载地址是 https://git ...
- C#与Linux守护进程
用C#编写Linux守护进程 如果要在Red Hat Enterprise Linux上将.NET Core进程作为后台进程运行,则可以创建自定义systemd单元.今天我将为.NET Core编 ...
- POJ 3039 搜索??? (逼近)
思路: 抄的题解 这叫搜索? 难以理解 我觉得就是枚举+逼近 //By SiriusRen #include <cmath> #include <cstdio> #includ ...
- 码农Coding Peasant(s):一般指从事没有发展前景的软件开发职位
码农Coding Peasant(s):一般指从事没有发展前景的软件开发职位,这种职位只能强化职业者在单方面的技术领域技能,学不到新技术,同时也是部分从事软件开发工作人员的一个自嘲的称号.一个依靠写代 ...
- golang-nw
http://godoc.org/github.com/lonnc/golang-nw golang webkit golang walk
- Vue 实现分页+输入框关键字筛选
分页的实现(Vue+Element)+输入框关键字筛选 1.这里用的是Element 自带的分页组件 <template> <div class="sales-table& ...
- 【Django】AJAX
目录 JSON 序列化 stringify 反序列化 parse JSON与XML对比 AJAX简介 AJAX常见应用场景 jQuery实现AJAX JS实现AJAX AJAX请求设置csrf_tok ...
- lastlog---显示系统中所有用户最近一次登录信息。
lastlog命令用于显示系统中所有用户最近一次登录信息. lastlog文件在每次有用户登录时被查询.可以使用lastlog命令检查某特定用户上次登录的时间,并格式化输出上次登录日志/var/log ...
- SICP 习题 (1.39)解题总结
SICP 习题1.39沿着习题1.37, 1.38的方向继续前行,要求我们依据德国数学家J.H.Lambert的公式定义tan-cf过程,用于计算正切函数的近似值. J.H.Lambert的公式例如以 ...
- sql%rowcount 返回影响行数
oracle中.返回影响行数是:If sql%rowcount 举例: update ut_calenderStatus t set t.calenderstatus=pi_flg, t.m=pi_M ...