Uva 11178 Morley's Theorem 向量旋转+求直线交点
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=9
题意:
Morlery定理是这样的:作三角形ABC每个内角的三等分线。相交成三角形DEF。则DEF为等边三角形,你的任务是给你A,B,C点坐标求D,E,F的坐标
思路:
根据对称性,我们只要求出一个点其他点一样:我们知道三点的左边即可求出每个夹角,假设求D,我们只要将向量BC
旋转rad/3的到直线BD,然后旋转向量CB然后得到CD,然后就是求两直线的交点了。
#include <iostream> #include <cstdio> #include <cmath> #include <vector> #include <cstring> #include <algorithm> #include <string> #include <set> #include <functional> #include <numeric> #include <sstream> #include <stack> #include <map> #include <queue>#define CL(arr, val) memset(arr, val, sizeof(arr))#define lc l,m,rt<<1 #define rc m + 1,r,rt<<1|1 #define pi acos(-1.0) #define L(x) (x) << 1 #define R(x) (x) << 1 | 1 #define MID(l, r) (l + r) >> 1 #define Min(x, y) (x) < (y) ? (x) : (y) #define Max(x, y) (x) < (y) ? (y) : (x) #define E(x) (1 << (x)) #define iabs(x) (x) < 0 ? -(x) : (x) #define OUT(x) printf("%I64d\n", x) #define lowbit(x) (x)&(-x) #define Read() freopen("din.txt", "r", stdin) #define Write() freopen("d.out", "w", stdout) #define ll unsigned long long #define keyTree (chd[chd[root][1]][0])#define M 100007 #define N 300017using namespace std;const double eps = 1e-8; const int inf = 0x7f7f7f7f; const int mod = 1000000007;struct Point {double x,y;Point(double tx = 0,double ty = 0) : x(tx),y(ty){} }; typedef Point Vtor; //向量的加减乘除 Vtor operator + (Vtor A,Vtor B) { return Vtor(A.x + B.x,A.y + B.y); } Vtor operator - (Point A,Point B) { return Vtor(A.x - B.x,A.y - B.y); } Vtor operator * (Vtor A,double p) { return Vtor(A.x*p,A.y*p); } Vtor operator / (Vtor A,double p) { return Vtor(A.x/p,A.y/p); } bool operator < (Point A,Point B) { return A.x < B.x || (A.x == B.x && A.y < B.y);} int dcmp(double x){ if (fabs(x) < eps) return 0; else return x < 0 ? -1 : 1; } bool operator == (Point A,Point B) {return dcmp(A.x - B.x) == 0 && dcmp(A.y - B.y) == 0; } //向量的点积,长度,夹角 double Dot(Vtor A,Vtor B) { return A.x*B.x + A.y*B.y; } double Length(Vtor A) { return sqrt(Dot(A,A)); } double Angle(Vtor A,Vtor B) { return acos(Dot(A,B)/Length(A)/Length(B)); } //叉积,三角形面积 double Cross(Vtor A,Vtor B) { return A.x*B.y - A.y*B.x; } double Area2(Point A,Point B,Point C) { return Cross(A - B,C - B); } //向量的旋转,求向量的单位法线(即左转90度,然后长度归一) Vtor Rotate(Vtor A,double rad){ return Vtor(A.x*cos(rad) - A.y*sin(rad),A.x*sin(rad) + A.y*cos(rad)); } Vtor Normal(Vtor A) {double L = Length(A);return Vtor(-A.y/L, A.x/L); } //直线的交点 Point GetLineIntersection(Point P,Vtor v,Point Q,Vtor w) {Vtor u = P - Q;double t = Cross(w,u)/Cross(v,w);return P + v*t; } //点到直线的距离 double DistanceToLine(Point P,Point A,Point B) {Vtor v1 = B - A;return Cross(P,v1)/Length(v1); } //点到线段的距离 double DistanceToSegment(Point P,Point A,Point B) {if (A == B) return Length(P - A);Vtor v1 = B - A , v2 = P - A, v3 = P - B;if (dcmp(Dot(v1,v2)) < 0) return Length(P - A);else if (dcmp(Dot(v1,v3)) > 0) return Length(P - B);else return Cross(v1,v2)/Length(v1); } //点到直线的映射 Point GetLineProjection(Point P,Point A,Point B) {Vtor v = B - A;return A + v*Dot(v,P - A)/Dot(v,v); }//判断线段是否规范相交 bool SegmentProperIntersection(Point a1,Point a2,Point b1,Point b2) {double c1 = Cross(a2 - a1,b1 - a1), c2 = Cross(a2 - a1,b2 - a1),c3 = Cross(a1 - a2,b1 - a1), c4 = Cross(a1 - a2,b2 - a2);return dcmp(c1)*dcmp(c2) < 0 && dcmp(c3)*dcmp(c4) < 0; } //判断点是否在一条线段上 bool OnSegment(Point P,Point a1,Point a2) {return dcmp(Cross(a1 - P,a2 - P)) == 0 && dcmp(Dot(a1 - P,a2 - P)) < 0; } //多边形面积 double PolgonArea(Point *p,int n) {double area = 0;for (int i = 1; i < n - 1; ++i)area += Cross(p[i] - p[0],p[i + 1] - p[0]);return area/2; }Point solve(Point A,Point B,Point C) {double rad1 = Angle(A - B, C - B)/3.0;Vtor v1 = C - B;v1 = Rotate(v1,rad1);double rad2 = Angle(A - C,B - C)/3.0;Vtor v2 = B - C;v2 = Rotate(v2,-rad2);return GetLineIntersection(B,v1,C,v2); } int main() {// Read();int T;Point A,B,C;scanf("%d",&T);while (T--){scanf("%lf%lf%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y);Point D = solve(A,B,C);Point E = solve(B,C,A);Point F = solve(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; }
View Code
Uva 11178 Morley's Theorem 向量旋转+求直线交点相关推荐
- uva 11178 Morley's Theorem 三角形内角三等分线交点
给出一个三角形ABC的三个顶点坐标,共有6条内角三等分线:AF .AE. BF. BD. CE. CD,求点D.E.F的坐 标. #include<cstdio> #include< ...
- UVA 11178 Morley’s Theorem(莫雷定理 计算几何)
Morley's Theorem Input: Standard Input Output: Standard Output Morley's theorem states that that the ...
- 莫利定理:UVa 11178 Morley's Theorem
莫利定理(Morley's theorem),也称为莫雷角三分线定理.将三角形的三个内角三等分,靠近某边的两条三分角线相交得到一个交点,则这样的三个交点可以构成一个正三角形.这个三角形常被称作莫利正三 ...
- UVa 11178:Morley’s Theorem(两射线交点)
Problem D Morley's Theorem Input: Standard Input Output: Standard Output Morley's theorem states tha ...
- UVa 11178 Morley‘s Theorem(计算几何基础)
题目链接:https://www.luogu.com.cn/problem/UVA11178 有 T 组测试样例,输入 3 个点的坐标,A , B , C ,然后每两点确定一条直线,将每两条直线所形成 ...
- 一般方程与参数方程求直线交点
一般方程与参数方程求直线交点 一. 一个例子: 如上图,有两条直线,设L1,L2.L1上有两点(0, 0).(10,10),L2上有两点(0,10).(10,0),它们的交点是 ...
- Uva 11178 Morley定理
题意: 给你三角形三个点, 定理是 三个内角的三等分线相交得出 DEF三点, 三角新 DFE是等边三角形 然后要你输出 D E F 的坐标 思路 : 求出三个内角,对于D 相当于 BC向量逆时针旋转, ...
- 关于求直线交点的问题。
二维坐标系下,关于求两条之前的交点问题,在国内网站上查来查去都没找到比较清晰易懂的.多数都是解决线段求交点的问题.最后在外国网站找到一篇,感觉讲解比较清晰.现在把他翻译过来. 2D空间中表示一条直线, ...
- POJ 1269 Intersecting Lines(求直线交点)
http://poj.org/problem?id=1269 求交点见zhhx课件 #include<iostream> #include<cstdio> #include&l ...
最新文章
- python 对 yaml 文件操作
- python inspect模块
- PTA浙大版python程序设计题目集--第2章-3 阶梯电价 (15 分)
- 关于日志系统显示SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder“.
- Android平台发展史
- yum install 失败
- anaconda在安装依赖包时出现报错提示 ‘requests‘ is a dependency of conda and cannot be remove from conda‘s operatin
- MFC 鼠标画线总结
- css设置div垂直居中
- 儿童过敏性鼻炎的最佳治疗方法
- C语言火车订票系统开发
- Unity粒子系统——简易特效制作(二)
- PTA 乙级难点(全部)
- 按概率收敛与几乎处处收敛
- 基,特征向量和基础解系
- 【附源码】计算机毕业设计SSM校园二手物品交易网站
- 机器人或将人类推向“无能之下的自由”
- 跨行业数据挖掘标准流程(CRISP-DM)
- How to activate office 2010
- 统计物料A与B同时出现的概率,Apriori算法,关联性分析