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 < ...
随机推荐
- linux 中 ll 命令显示 的大小 是什么单位的啊?
ll显示的是字节,可以使用-h参数来提高文件大小的可读性,另外ll不是命令,是ls -l的别名 ls -al 是以字节单位显示文件或者文件夹大小: 字节b,千字节kb, 1G=1024M=1024 ...
- onethink判断是否是手机访问?
第一步:找到:Application / Common / Common / function.php 添加判断是否是手机访问的代码: /** * 判断当前访问的用户是 PC端 还是 手机端 返回tr ...
- jsp实现文件下载的代码(转载)
Java代码 OutputStream out=response.getOutputStream(); byte by[]=new byte[500]; File fileLoad=new Fil ...
- centos6.8 环境一键安装包 nginx配置thinkphp5
---恢复内容开始--- lnmp1.4 一键安装包 nginx配置thinkphp5 环境:Nginx1.12.1 PHP5.6 Coentos6.8 修改网站配置文件 ser ...
- PL/SQL Developer登入时候报ORA-12638
在client安装目录,找到打开sqlnet.ora 在里面找到 SQLNET.AUTHENTICATION_SERVICES= (NTS)将其更改为: SQLNET.AUTHENTICATION_S ...
- 对10进制16位长的主键的缩短处理 NULL
# 对问题表去除旧有主键,新建自增主键:ALTER TABLE `question`CHANGE COLUMN `id` `id16` bigint(20) NULL COMMENT 'id_to_d ...
- stark - 数据列表
一.效果图 二.数据列表 知识点: 完成(list_display)(list_display_links) 1.根据str,拿字段对象,取中文 val = self.model._meta.get_ ...
- 日志汇总:logging、logger
目录 1.日志输出到文件 2.日志输出到屏幕 3.设置输出等级 4.设置多个日志输出对象 5.日志的配置 6.记录异常 7.设置日志输出样式 1.日志输出到文件basicConfig()提供了非常便捷 ...
- Java-idea-Checkstyle自动化代码规范检查
一.概述 CheckStyle是SourceForge下的一个项目,提供了一个帮助JAVA开发人员遵守某些编码规范的工具.它能够自动化代码规范检查过程,从而使得开发人员从这项重要,但是枯燥的任务中解脱 ...
- java, android的aes等加密库
https://github.com/scottyab/AESCrypt-Android https://github.com/PDDStudio/EncryptedPreferences ...