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. Xcode里修改工程名、类名、批量修改变量名

    转:http://blog.csdn.net/yuedong56/article/details/13767001 一.修改工程名: 1.点击工程,右键,选择如图选项. 2.右侧如图位置,修改工程名. ...

  2. chorme快捷键

    Chrome窗口和标签页快捷键:Ctrl+N 打开新窗口 Ctrl+T 打开新标签页 Ctrl+Shift+N 在隐身模式下打开新窗口 Ctrl+O,然后选择文件 在谷歌浏览器中打开计算机上的文件 按 ...

  3. 阿里云搭建SVN服务器

    1:安装svn apt-get install subversion 2. 开启svn服务器 svnserve -d 检查是否开启:ps aux | grep svnserve 若出现如下内容: wk ...

  4. C#操作word之插入图片

    假如我们导出一份简历到word文档,那势必可能要同时导出我们包含的简历,下面就来试一下如何和通过C#代码,将图片插入到word文档中. 为了简便起见,就简单一点.类似下面这样的 姓名 张三 照片   ...

  5. Oracle HA 之 SERVICE和DRM实战

    第一部分:service实战 --oracle 11gR2中创建service的方法:db console和srvctl两种方法. --db console创建service方法-略 --srvctl ...

  6. Python并行编程(十三):进程池和mpi4py模块

    1.基本概念 多进程库提供了Pool类来实现简单的多进程任务.Pool类有以下方法: - apply():直到得到结果之前一直阻塞. - apply_async():这是apply()方法的一个变体, ...

  7. (2.2)DDL增强功能-自定义函数与存储过程

    1.存储过程 精华总结: 通过对比@@ERROR一般和if判断结合使用,@@TRANCOUNT和try catch块结合使用,xact_abort为on可以单独使用Xact_abort为off时,如果 ...

  8. centos LAMP第一部分-环境搭建 Linux软件删除方式,mysql安装,apache,PHP,apache和php结合,phpinfo页面,ldd命令 第十九节课

    centos LAMP第一部分-环境搭建  Linux软件删除方式,mysql安装,apache,PHP,apache和php结合,phpinfo页面,ldd命令 第十九节课 打命令之后可以输入: e ...

  9. android studio gradle 国内代理

    使用阿里云的国内镜像仓库地址,就可以快速的下载需要的文件 修改项目根目录下的文件 build.gradle : buildscript { repositories { maven{ url 'htt ...

  10. FILE 文件的使用 (VC、BCB、Qt)

    FILE * fp ;AnsiString filePath="";fp= fopen(filePath.c_str(),"wb");//第二个参数是文件打开方 ...