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 300017 using namespace std; const double eps = 1e-;
const int inf = 0x7f7f7f7f;
const int mod = ; struct Point
{
double x,y;
Point(double tx = ,double ty = ) : 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 ; else return x < ? - : ; }
bool operator == (Point A,Point B) {return dcmp(A.x - B.x) == && dcmp(A.y - B.y) == ; }
//向量的点积,长度,夹角
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)) < ) return Length(P - A);
else if (dcmp(Dot(v1,v3)) > ) 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) < && dcmp(c3)*dcmp(c4) < ;
}
//判断点是否在一条线段上
bool OnSegment(Point P,Point a1,Point a2)
{
return dcmp(Cross(a1 - P,a2 - P)) == && dcmp(Dot(a1 - P,a2 - P)) < ;
}
//多边形面积
double PolgonArea(Point *p,int n)
{
double area = ;
for (int i = ; i < n - ; ++i)
area += Cross(p[i] - p[],p[i + ] - p[]);
return area/;
} 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 ;
}
Uva 11178 Morley's Theorem 向量旋转+求直线交点的更多相关文章
- UVA 11178 Morley's Theorem (坐标旋转)
题目链接:UVA 11178 Description Input Output Sample Input Sample Output Solution 题意 \(Morley's\ theorem\) ...
- UVA 11178 Morley's Theorem(旋转+直线交点)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18543 [思路] 旋转+直线交点 第一个计算几何题,照着书上代码打 ...
- 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
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- 简单几何(求交点) UVA 11178 Morley's Theorem
题目传送门 题意:莫雷定理,求三个点的坐标 分析:训练指南P259,用到了求角度,向量旋转,求射线交点 /*********************************************** ...
- 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 (几何问题)
题意:给定三角形的三个点,让你求它每个角的三等分线所交的顶点. 析:根据自己的以前的数学知识,应该很容易想到思想,比如D点,就是应该求直线BD和CD的交点, 以前还得自己算,现在计算机帮你算,更方便, ...
- UVA 11178 Morley's Theorem 计算几何模板
题意:训练指南259页 #include <iostream> #include <cstdio> #include <cstring> #include < ...
随机推荐
- 【BZOJ3772】精神污染 DFS序+主席树
[BZOJ3772]精神污染 Description 兵库县位于日本列岛的中央位置,北临日本海,南面濑户内海直通太平洋,中央部位是森林和山地,与拥有关西机场的大阪府比邻而居,是关西地区面积最大的县,是 ...
- 分布式锁的实现(java)
当对接第三方接口时,往往会碰到同一时间发送了大量相同的请求,这个时候或许就是第三方发送接口的失误了.而我们需要做的就是针对这个情况来强化我们的系统.这个时候就需要用到分布式锁.让这些请求只有一个能发送 ...
- Oracle安装部署之 6节点11g cluster环境搭建
**********************集群规划*************************************** --配置主机,共需要8台主机,其中6台做grid集群,1台作为存储服 ...
- 使用linuxbridge + vlan网络模式
#openstack pike 使用 linuxbridge + vlan openstack pike 集群高可用 安装部署 汇总 http://www.cnblogs.com/elvi/p/76 ...
- django自带权限机制
1. Django权限机制概述 权限机制能够约束用户行为,控制页面的显示内容,也能使API更加安全和灵活:用好权限机制,能让系统更加强大和健壮.因此,基于Django的开发,理清Django权限机制是 ...
- uchome 不从缓存中读取模板
/source/function_common.php中的代码 //模板调用 function template($name) { global $_SCONFIG, $_SGLOBAL; if($_ ...
- 003-and design-在create-react-app项目中使用antd
一.概述 create-react-app 是业界最优秀的 React 应用开发工具之一,本文会尝试在 create-react-app 创建的工程中使用 antd 组件,并自定义 webpack 的 ...
- ThinkPhp3.2.3 多项目 后台 APP接口设计 框架设计
↓↓↓项目文件组成部分↓↓↓ APP文件是后台,index.php是入口文件 Interface文件是接口,注意这里不要用api命名!可能会有问题!interface.php是入口文件 注:两个入口文 ...
- java多线程(四)
使用synchronized锁实现线程同步 为什么要用线程同步 我们先来看下这段代码的运行结果: Java学习交流群:495273252 在多线程上篇博客已经介绍过了,JVM采用的是抢占式调度模型,当 ...
- docker——核心实现技术
作为一种容器虚拟化技术,Docker深度应用了操作系统的多项底层支持技术. 早期版本的Docker是基于已经成熟的Linux Container(LXC)技术实现的.自从0.9版本起,Docker逐渐 ...