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. Linq查询案例

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  2. 玩转redux--从会用到庖丁解牛

    目录 为何而写 redux是什么 redux的设计哲学 redux的工作流 redux的几个核心要素 store action reducer actionCreator combineReducer ...

  3. Lusac定理

    转载大佬的模版:http://www.cnblogs.com/vongang/archive/2012/12/02/2798138.html

  4. Windows学习总结(4)——Host文件的作用和如何修改Host文件

    本经验将为您介绍,什么是Host文件,Host文件作用,Host文件的位置等信息,以帮忙您了解Host文件. 方法/步骤 什么是HOST文件: Hosts是一个没有扩展名的系统文件,其基本作用就是将一 ...

  5. js31---观察者模式

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...

  6. 3.JPA开发

    转自:https://blog.csdn.net/aspnetandjava/article/details/7034779 1. 什么是JPA 1. JPA(Java Persistence API ...

  7. 有点坑爹的GDALComputeRasterMinMax函数

    作者:朱金灿 来源:http://blog.csdn.net/clever101 GDALComputeRasterMinMax函数是gdal库为了求取指定波段的极值而提供的接口.最近看了这个接口的源 ...

  8. UVA 12333 Revenge of Fibonacci

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

  9. C# json 总结

    json格式字符串转换为实体类,大括号 {} 表示对象,[] 数组表示列表. json文件读取到内存中就是字符串,.NET操作json就是生成与解析json字符串. 添加引用:using Newton ...

  10. iOS界面生命周期过程具体解释

    开发过Android的人都知道,每个Android界面就是一个Activity,而每个Activity都会有自己的生命周期, 有一系列方法会控制Activity的生命周期.如:onCreate(),o ...