uva 11178 Morley's Theorem 三角形内角三等分线交点
2016-07-20 14:56
555 查看
给出一个三角形ABC的三个顶点坐标,共有6条内角三等分线:AF 、AE、 BF、 BD、 CE、 CD,求点D、E、F的坐
标。
![](https://img-blog.csdn.net/20160720145742462)
标。
#include<cstdio> #include<string> #include<cstring> #include<iostream> #include<cmath> #include<algorithm> #include<vector> using namespace std; #define all(x) (x).begin(), (x).end() #define for0(a, n) for (int (a) = 0; (a) < (n); (a)++) #define for1(a, n) for (int (a) = 1; (a) <= (n); (a)++) typedef long long ll; typedef pair<int, int> pii; const int INF =0x3f3f3f3f; //const int maxn= ; const double eps=1e-10; struct Point { double x,y; Point(double x=0,double y=0):x(x),y(y) {}; void show() { cout<<x<<" "<<y<<endl; } }A,B,C,D,E,F; typedef Point Vector; 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); } Vector operator -(Vector A) {return Vector(-A.x,-A.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 Cross(Vector A,Vector B)//叉乘 { return A.x*B.y-A.y*B.x; } double angle(Vector A,Vector B) { return acos(Dot(A,B)/Length(A)/Length(B)); } Vector Rotate(Vector A,double rad)//向量A 逆时针旋转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; } int main() { int T;scanf("%d",&T); while(T--) { scanf("%lf%lf%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y); Vector AB=B-A,AC=C-A,BC=C-B; Vector BA=-AB,CA=-AC,CB=-BC ; double aA=angle(AB,AC); double aB=angle(BA,BC); double aC=angle(CA,CB); Vector BF=Rotate(BA,-aB/3 );//旋转 Vector AF=Rotate(AB,aA/3 ); F=GetLineIntersection(B,BF,A,AF); Vector CE=Rotate(CA,aC/3); Vector AE=Rotate(AC,-aA/3); E=GetLineIntersection(C,CE,A,AE); Vector BD=Rotate(BC,aB/3); Vector CD=Rotate(CB,-aC/3); D=GetLineIntersection(B,BD,C,CD); printf("%.6f %.6f %.6f %.6f %.6f %.6f\n",D.x,D.y,E.x,E.y,F.x,F.y); } return 0; }
相关文章推荐
- java实现猜拳游戏
- The resource could not be loaded because the App Transport Security policy requir
- 《JAVA与模式》之适配器模式
- Mysql 的随机更新
- NIO学习笔记一
- request.getQueryString
- Spark源码解读(1)——Master启动过程
- load 导入数据的优化
- 2016 Multi-University Training Contest 1 1011 tetrahedron 四面体内切圆
- [numpy]split()和array_split()
- 剑指offer——构建乘积数组
- Hdu1240 Asteroids!(三维BFS)
- css selector
- BFS:森林着火
- jQuery on()给动态元素绑定事件
- 慢查询
- PHP+Ajax验证码验证用户登录
- JS获取GET参数
- maven工程常用命令
- Spring中Quartz的配置