描述


https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=23&page=show_problem&problem=2119

Morley定理:作三角形ABC每个内角的三等分线,相交形成三角形DEF,则三角形DEF是等边三角形.

给出三角形的三个顶点ABC的坐标,求出DEF的坐标.

11178 - Morley's Theorem

Time limit: 3.000 seconds

Morleys theorem states that that the lines
trisecting the angles of an arbitrary plane

triangle meet at the vertices of an equi-
lateral triangle. For example in the figure
below the tri-sectors of angles A, B and C
has intersected and created an equilateral
triangle DEF.
Of course the theorem has various gen-
eralizations, in particular if all of the tri-
sectors are intersected one obtains four
other equilateral triangles. But in the
original theorem only tri-sectors nearest
to BC are allowed to intersect to get point
D, tri-sectors nearest to CA are allowed to intersect point E and tri-sectors nearest to AB are inter-
sected to get point F. Trisector like BD and CE are not allowed to intersect. So ultimately we get only
one equilateral triangle DEF. Now your task is to find the Cartesian coordinates of D, E and F given
the coordinates of A, B, and C.
Input
First line of the input file contains an integer N (0 < N < 5001) which denotes the number of
test cases to follow. Each of the next lines contain six integers X A , Y A , X B , Y B , X C , Y C . This six
integers actually indicates that the Cartesian coordinates of point A, B and C are (X A , Y A ),(X B , Y B )
and (X C , Y C ) respectively. You can assume that the area of triangle ABC is not equal to zero, 0 ≤
X A , Y A , X B , Y B , X C , Y C ≤ 1000 and the points A, B and C are in counter clockwise order.
Output
For each line of input you should produce one line of output. This line contains six floating point
numbers X D , Y D , X E , Y E , X F , Y F separated by a single space. These six floating-point actually means
that the Cartesian coordinates of D, E and F are (X D , Y D ),(X E , Y E ) ,(X F , Y F ) respectively. Errors
less than 10 −5 will be accepted.
Sample Input
2
1 1 2 2 1 2
0 0 100 0 50 50
Sample Output
1.316987 1.816987 1.183013 1.683013 1.366025 1.633975
56.698730 25.000000 43.301270 25.000000 50.000000 13.397460

分析


DEF三个点的求法是一样的,来看D:

将向量BC逆时针旋转(角ABC)/3,将向量CB顺时针旋转(角ACB)/3,分别得到了直线BD和直线CD的方向向量,再加上点B,C,可以写出直线BD和直线CD(参数方程),然后求两直线的交点即可.

注意:

1.get函数中的后两个参数不可颠倒,因为一边是逆时针转,另一边是顺时针转.

 #include <bits/stdc++.h>
using namespace std; const double eps=1e-;
struct Point{
double x,y;
Point(double x=,double y=):x(x),y(y){}
};
typedef Point Vector; Vector operator + (Point a,Point b){ return Vector(a.x+b.x,a.y+b.y); }
Vector operator - (Point a,Point b){ return Vector(a.x-b.x,a.y-b.y); }
Vector operator * (Point a,double p){ return Vector(a.x*p,a.y*p); }
double dot(Vector a,Vector b){ return a.x*b.x+a.y*b.y; }//点积
double cross(Vector a,Vector b){ return a.x*b.y-a.y*b.x; }//叉积
double length(Vector a){ return sqrt(dot(a,a)); }//向量的模
double angle(Vector a,Vector b){ return acos(dot(a,b)/length(a)/length(b)); }//两向量夹角
Vector rotate(Vector a,double rad){ return Vector(a.x*cos(rad)-a.y*sin(rad),a.x*sin(rad)+a.y*cos(rad)); }//将向量a逆时针旋转rad(弧度制)
Point get_line_intersection(Point P,Vector v,Point Q,Vector w){//求两直线交点(参数方程)
Vector u=P-Q;
double t=cross(w,u)/cross(v,w);
return P+v*t;
}
Point get(Point A,Point B,Point C){//分别算DEF三个点的函数
Vector v1=C-B;
double a1=angle(A-B,v1);
v1=rotate(v1,a1/);
Vector v2=B-C;
double a2=angle(A-C,v2);
v2=rotate(v2,-a2/);
return get_line_intersection(B,v1,C,v2);
}
int main(){
int n;
Point A,B,C,D,E,F;
scanf("%d",&n);
while(n--){
scanf("%lf%lf%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y);
D=get(A,B,C);//这里B,C不能写反,因为一个是逆时针转,另一个时顺时针转
E=get(B,C,A);
F=get(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. nyis oj 68 三点顺序 (计算几何基础)

    三点顺序 时间限制:1000 ms  |  内存限制:65535 KB 难度:3 描写叙述 如今给你不共线的三个点A,B,C的坐标,它们一定能组成一个三角形,如今让你推断A,B,C是顺时针给出的还是逆 ...

  2. 【BZOJ】1043: [HAOI2008]下落的圆盘(计算几何基础+贪心)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1043 唯一让我不会的就是怎么求圆的周长并QAAQ... 然后发现好神!我们可以将圆弧变成$[0, 2 ...

  3. 计算几何基础——矢量和叉积 && 叉积、线段相交判断、凸包(转载)

    转载自 http://blog.csdn.net/william001zs/article/details/6213485 矢量 如果一条线段的端点是有次序之分的话,那么这种线段就称为 有向线段,如果 ...

  4. BZOJ_1610_[Usaco2008_Feb]_Line连线游戏_(计算几何基础+暴力)

    描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1610 给出n个点,问两两确定的直线中,斜率不同的共有多少条. 分析 暴力枚举直线,算出来斜率放 ...

  5. 二维计算几何基础题目泛做(SYX第一轮)

    题目1: POJ 2318 TOYS 题目大意: 给一个有n个挡板的盒子,从左到右空格编号为0...n.有好多玩具,问每个玩具在哪个空格里面. 算法讨论: 直接叉积判断就可以.注意在盒子的边界上面也算 ...

  6. 计算几何基础算法几何C++实现

    This file is implementation of Common Common Computational Geometry Algorithms.Please please pay att ...

  7. 【POJ】1556 The Doors(计算几何基础+spfa)

    http://poj.org/problem?id=1556 首先路径的每条线段一定是端点之间的连线.证明?这是个坑...反正我是随便画了一下图然后就写了.. 然后re是什么节奏?我记得我开够了啊.. ...

  8. 【POJ】2318 TOYS(计算几何基础+暴力)

    http://poj.org/problem?id=2318 第一次完全是$O(n^2)$的暴力为什么被卡了-QAQ(一定是常数太大了...) 后来排序了下点然后单调搞了搞..(然而还是可以随便造出让 ...

  9. 【POJ】2653 Pick-up sticks(计算几何基础+暴力)

    http://poj.org/problem?id=2653 我很好奇为什么这样$O(n^2)$的暴力能过.... 虽然说这是加了链表优化的,但是最坏不也是$O(n^2)$吗...(只能说数据太弱.. ...

随机推荐

  1. MVC中实现部分内容异步加载

    MVC中实现部分内容异步加载 action中定义一个得到结果集的方法 public ActionResult GetItemTree(string title, int itemid, int? pa ...

  2. Android获取屏幕尺寸大小

    官方API: A structure describing general information about a display, such as its size, density, and fo ...

  3. UIView的frame和bounds区别

    UIView的frame和bounds区别 iOS中,大家肯定对view和frame都不陌生,我们设置view在父view中的位置和大小时,只需要设置frame就可以了. 可能大家也有查过网上的一些资 ...

  4. swift-08-元组分解和数组

    //1.有时候需要把元组中的数据拆分出来使用比如: var stu = ("范冰冰",30,"女") // 1)将stu中的数据赋值给三个变量. var (na ...

  5. JavaScript 学习笔记-- ES6学习(一)介绍以及Babel的使用

    本文摘自阮一峰老师的<ECMAScript 6入门>,原文地址:http://es6.ruanyifeng.com/#docs/intro ECMAScript 6 是一个泛指,含义是5. ...

  6. ZOJ 2702 Unrhymable Rhymes(DP)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1702 题目大意:给定有很多数字组成的诗,譬如 “AABB”, “AB ...

  7. itoa : Convert integer to string

      Quote from:  http://www.cplusplus.com/reference/cstdlib/itoa/   function   Required header : <s ...

  8. vsftpd服务详解

    一.vsftpd基本使用 VSFTP是一个基于GPL发布的类Unix系统上使用的FTP服务器软件,它的全称是Very Secure FTP,从此名称可以看出来,编制者的初衷是代码的安全.安全性是编写V ...

  9. vs2005用正则表达式统计有效代码行数

    正则表达式:^:b*[^:b#/]+.*$ 需要注意:#开头和/开头或者空行都不计入代码量. 如果需要只统计代码文件的代码量,可以按住Ctrl+Shift+F之后选择查找文件的类型. Form:htt ...

  10. MVC中Razor视图基本语法(1)

    Razor前面,必须要跟前面的有空隙,即空格(多谢一楼提醒,url里面确实不用空格,如果要在url里面只需要@(ViewBag.),加上括号就好了),之后的必须要连贯,否则加小括号 1,在页面中输出单 ...