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 向量的更多相关文章

  1. Uva 11178 Morley's Theorem 向量旋转+求直线交点

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=9 题意: Morlery定理是这样的:作三角形ABC每个 ...

  2. uva 11178 - Morley's Theorem

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  3. UVA 11178 Morley's Theorem (坐标旋转)

    题目链接:UVA 11178 Description Input Output Sample Input Sample Output Solution 题意 \(Morley's\ theorem\) ...

  4. UVA 11178 Morley's Theorem(几何)

    Morley's Theorem [题目链接]Morley's Theorem [题目类型]几何 &题解: 蓝书P259 简单的几何模拟,但要熟练的应用模板,还有注意模板的适用范围和传参不要传 ...

  5. UVa 11178:Morley’s Theorem(两射线交点)

    Problem DMorley’s TheoremInput: Standard Input Output: Standard Output Morley’s theorem states that ...

  6. 简单几何(求交点) UVA 11178 Morley's Theorem

    题目传送门 题意:莫雷定理,求三个点的坐标 分析:训练指南P259,用到了求角度,向量旋转,求射线交点 /*********************************************** ...

  7. UVA 11178 Morley's Theorem(旋转+直线交点)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18543 [思路] 旋转+直线交点 第一个计算几何题,照着书上代码打 ...

  8. UVa 11178 Morley's Theorem (几何问题)

    题意:给定三角形的三个点,让你求它每个角的三等分线所交的顶点. 析:根据自己的以前的数学知识,应该很容易想到思想,比如D点,就是应该求直线BD和CD的交点, 以前还得自己算,现在计算机帮你算,更方便, ...

  9. UVA 11178 Morley's Theorem 计算几何模板

    题意:训练指南259页 #include <iostream> #include <cstdio> #include <cstring> #include < ...

随机推荐

  1. mybatis自己主动生成mapper,dao,映射文件

    一.先创建数据脚本,这里用的mysql数据脚本 drop table VOTE_ITEM; drop table VOTE_OPTION; drop table VOTE_SUBJECT; drop ...

  2. 2017国家集训队作业[agc008f]Black Radius

    2017国家集训队作业[agc008f]Black Radius 时隔4个月,经历了省赛打酱油和中考各种被吊打后,我终于回想起了我博客园的密码= = 题意: ​ 给你一棵树,树上有若干个关键点.选中某 ...

  3. HDU 2191 悼念512汶川大地震

    悼念512汶川大地震遇难同胞——珍惜现在,感恩生活 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Jav ...

  4. POJ——T 3461 Oulipo

    http://poj.org/problem?id=3461 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 42698   ...

  5. cocos2d-x cocoStudioUI编辑器导出文件的使用

    代码演示样例: UILayer* layer = UILayer::create(); layer ->addWidget(CCUIHELPER->createWidgetFromJson ...

  6. actionbar-去掉背景的阴影

    今天发现一个问题,就是actionbar跟界面的交界处,会有一个阴影,通过调查发现,这个阴影是actionbar的.然后通过在网上找资料,完美解决了问题.解决方法如下 1.在这个actionbar所在 ...

  7. android图像处理系列之六--给图片添加边框(下)-图片叠加

    前面介绍了一种用透明图片叠加的方式添加花边边框,下面将介绍另外一种图片叠加添加花边边框的方式.前面方法有一个缺点,就是做成PNG图片,图片体积会很大,不是一般的大,比同样的JPG大三倍多,如果项目可以 ...

  8. MySQL轻量版使用,无需安装,无脑操作

    不知道是否有想我一样的,开始用的都是安装版的,特别费事,卸载后注册表很难删除 下面介绍一下MySQL轻量级的如下 首先打开一个网址:www.oracle.com没错就是强大的Oracle官网 也可以直 ...

  9. C#截取中英文混合字符串分行显示

    private int GetStrByteLength(string str) { return System.Text.Encoding.Default.GetByteCount(str); } ...

  10. org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 211 completed: Maybe

    用weblogic 12c 测试 ejb3 import javax.naming.InitialContext; import javax.naming.NamingException; impor ...