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 向量旋转+求直线交点的更多相关文章

  1. UVA 11178 Morley's Theorem (坐标旋转)

    题目链接:UVA 11178 Description Input Output Sample Input Sample Output Solution 题意 \(Morley's\ theorem\) ...

  2. UVA 11178 Morley's Theorem(旋转+直线交点)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18543 [思路] 旋转+直线交点 第一个计算几何题,照着书上代码打 ...

  3. UVA 11178 - Morley's Theorem 向量

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

  4. uva 11178 - Morley's Theorem

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

  5. 简单几何(求交点) UVA 11178 Morley's Theorem

    题目传送门 题意:莫雷定理,求三个点的坐标 分析:训练指南P259,用到了求角度,向量旋转,求射线交点 /*********************************************** ...

  6. UVA 11178 Morley's Theorem(几何)

    Morley's Theorem [题目链接]Morley's Theorem [题目类型]几何 &题解: 蓝书P259 简单的几何模拟,但要熟练的应用模板,还有注意模板的适用范围和传参不要传 ...

  7. UVa 11178:Morley’s Theorem(两射线交点)

    Problem DMorley’s TheoremInput: Standard Input Output: Standard Output Morley’s theorem states that ...

  8. UVa 11178 Morley's Theorem (几何问题)

    题意:给定三角形的三个点,让你求它每个角的三等分线所交的顶点. 析:根据自己的以前的数学知识,应该很容易想到思想,比如D点,就是应该求直线BD和CD的交点, 以前还得自己算,现在计算机帮你算,更方便, ...

  9. UVA 11178 Morley's Theorem 计算几何模板

    题意:训练指南259页 #include <iostream> #include <cstdio> #include <cstring> #include < ...

随机推荐

  1. jhipser微服务架构介绍

    内容提要 本文涉及以下内容: 微服务架构介绍 spring cloud介绍 jhipster架构介绍 微服务架构介绍 微服务概念 微服务和SOA很相似,都是按照业务功能把系统拆分成一个一个的服务.比如 ...

  2. 解决:Bitmap too large to be uploaded into a texture exception

    前几天拿锤子手机做测试,启动页面的闪屏直接黑屏.. 所以看下日志,百度一下 找到解决方案,特此记录. 简单说就是硬件加速的时候,对图片的大小有限制.不同设备可能有不同的最大值.这个问题悲催的地方是,程 ...

  3. Hibernate--快速上手

    一.初识 Hibernate 经典的软件应用体系结构有三层:表示层(提供了与用户交互的接口,实现用户操作界面,展示用户需要的数据).业务逻辑层(完成业务流程,处理表示层提交的数据请求,并将要保存的数据 ...

  4. 字符串函数---atof()函数详解

    atof()函数 atof(),是C 语言标准库中的一个字符串处理函数,功能是把字符串转换成浮点数,所使用的头文件为<stdlib.h>.该函数名是 “ascii to floating ...

  5. 使用Python创建.sd服务定义文件,实现脚本自动发布ArcGIS服务

    借助ArcGIS桌面发布ArcGIS服务是一个很熟悉的过程了,发布服务的前提是需要拥有一个已连接的ArcGIS Server服务站点,经过对mxd进行制图配置,定义服务参数,才能实现服务的发布,那么这 ...

  6. Ultra-QuickSort---poj2299 (归并排序.逆序数.树状数组.离散化)

    题目链接:http://poj.org/problem?id=2299 题意就是求把数组按从小到大的顺序排列,每次只能交换相邻的两个数, 求至少交换了几次 就是求逆序数 #include<std ...

  7. cookie.setPath()的用法

    正常的cookie只能在一个应用中共享,即:一个cookie只能由创建它的应用获得. 可在同一应用服务器内共享cookie的方法:设置cookie.setPath("/");  ( ...

  8. Tensorflow中卷积的padding方式

    根据tensorflow中的Conv2D函数,先定义几个基本符号: 输入矩阵W*W,这里只考虑输入宽高相等的情况,如果不相等,推导方法一样 filter矩阵F*F,卷积核 stride值S,步长 输出 ...

  9. MySQL不能启动 Can't start server : Bind on unix socke

    MySQL服务器突然不能启动,查看最后的启动日志如下: 080825 09:38:04 mysqld started080825 9:38:04 [ERROR] Can't start server ...

  10. The adidas NMD Camo Singapore consists of four colorways

    Next within the popular selection of the adidas NMD Singapore is really a clean all-black form of th ...