UVA - 11178-Morley’s Theorem
就是给出一个等边三角形的三个顶点坐标
然后每一个角的三等分线会交错成一个三角形,求出这个三角形的顶点坐标
一開始。我题意理解错了……还以为是随意三角形,所以代码可以处理随意三角形的情况
我的做法:
通过旋转点的位置得到这些三等分线的直线方程,然后用高斯消元求交点
我的代码:
#include<iostream>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
struct dot
{
double x,y;
dot(){}
dot(double a,double b){x=a;y=b;}
dot operator -(const dot &a){return dot(x-a.x,y-a.y);}
dot operator +(const dot &a){return dot(x+a.x,y+a.y);}
double mod(){return sqrt(pow(x,2)+pow(y,2));}
double mul(const dot &a){return x*a.x+y*a.y;}
};
void gauss(double a[10][10])
{
int i,j,k,t,n=2;
for(i=0;i<n;i++)
{
t=i;
for(j=i+1;j<n;j++)
if(fabs(a[j][i])>fabs(a[t][i]))
t=i;
if(i!=t)
for(j=i;j<=n;j++)
swap(a[i][j],a[t][j]);
if(a[i][i]!=0)
for(j=i+1;j<n;j++)
for(k=n;k>=i;k--)
a[j][k]-=a[j][i]/a[i][i]*a[i][k];
}
for(i=n-1;i>-1;i--)
{
for(j=i+1;j<n;j++)
a[i][n]-=a[i][j]*a[j][n];
a[i][n]/=a[i][i];
}
}
dot ro(dot a,dot b,double c)
{
a=a-b;
a=dot(a.x*cos(c)-a.y*sin(c),a.x*sin(c)+a.y*cos(c));
return a+b;
}
int main()
{
pair<dot,dot>t;
dot a[3];
double b,c[10][10];
int n,i;
cin>>n;
while(n--)
{
for(i=0;i<3;i++)
scanf("%lf%lf",&a[i].x,&a[i].y); t.first=a[0]-a[1];t.second=a[2]-a[1];
b=acos(t.first.mul(t.second)/t.first.mod()/t.second.mod())/3;
t.first=a[1];t.second=ro(a[2],a[1],b);
c[0][0]=t.first.y-t.second.y;c[0][1]=t.second.x-t.first.x;c[0][2]=t.second.x*t.first.y-t.second.y*t.first.x; t.first=a[1]-a[2];t.second=a[0]-a[2];
b=2*acos(t.first.mul(t.second)/t.first.mod()/t.second.mod())/3;
t.first=a[2];t.second=ro(a[0],a[2],b);
c[1][0]=t.first.y-t.second.y;c[1][1]=t.second.x-t.first.x;c[1][2]=t.second.x*t.first.y-t.second.y*t.first.x; gauss(c); printf("%.6lf %.6lf ",c[0][2],c[1][2]); t.first=a[1]-a[2];t.second=a[0]-a[2];
b=acos(t.first.mul(t.second)/t.first.mod()/t.second.mod())/3;
t.first=a[2];t.second=ro(a[0],a[2],b);
c[0][0]=t.first.y-t.second.y;c[0][1]=t.second.x-t.first.x;c[0][2]=t.second.x*t.first.y-t.second.y*t.first.x; t.first=a[1]-a[0];t.second=a[2]-a[0];
b=2*acos(t.first.mul(t.second)/t.first.mod()/t.second.mod())/3;
t.first=a[0];t.second=ro(a[1],a[0],b);
c[1][0]=t.first.y-t.second.y;c[1][1]=t.second.x-t.first.x;c[1][2]=t.second.x*t.first.y-t.second.y*t.first.x; gauss(c); printf("%.6lf %.6lf ",c[0][2],c[1][2]); t.first=a[1]-a[0];t.second=a[2]-a[0];
b=acos(t.first.mul(t.second)/t.first.mod()/t.second.mod())/3;
t.first=a[0];t.second=ro(a[1],a[0],b);
c[0][0]=t.first.y-t.second.y;c[0][1]=t.second.x-t.first.x;c[0][2]=t.second.x*t.first.y-t.second.y*t.first.x; t.first=a[0]-a[1];t.second=a[2]-a[1];
b=2*acos(t.first.mul(t.second)/t.first.mod()/t.second.mod())/3;
t.first=a[1];t.second=ro(a[2],a[1],b);
c[1][0]=t.first.y-t.second.y;c[1][1]=t.second.x-t.first.x;c[1][2]=t.second.x*t.first.y-t.second.y*t.first.x; gauss(c); printf("%.6lf %.6lf\n",c[0][2],c[1][2]);
}
}
原题:
Problem D
Morley’s Theorem
Input: Standard Input
Output: Standard Output
Morley’s theorem states that that the lines trisecting the angles of an arbitrary plane triangle meet at the vertices of an equilateral 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 generalizations, 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 intersected 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
. This six integers actually indicates that the Cartesian coordinates of point A, B and C are
respectively. You can assume that the area of triangle ABC is not equal to zero,
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
separated by a single space. These six floating-point actually means that the Cartesian coordinates of D, E and F are
respectively. Errors less than
will be accepted.
Sample Input Output for Sample Input
2 1 1 2 2 1 2 0 0 100 0 50 50 |
1.316987 1.816987 1.183013 1.683013 1.366025 1.633975 56.698730 25.000000 43.301270 25.000000 50.000000 13.397460 |
Problemsetters: Shahriar Manzoor
Special Thanks: Joachim Wulff
Source
option=com_onlinejudge&Itemid=8&category=44">
Shahriar Manzoor
Root :: AOAPC I: Beginning Algorithm Contests -- Training Guide (Rujia Liu) :: Chapter 4. Geometry :: Geometric Computations in 2D ::
Examples
UVA - 11178-Morley’s Theorem的更多相关文章
- 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 (坐标旋转)
题目链接:UVA 11178 Description Input Output Sample Input Sample Output Solution 题意 \(Morley's\ theorem\) ...
- 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 向量
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=9 题意: Morlery定理是这样的:作三角形ABC每个 ...
- UVA 11178 Morley's Theorem(旋转+直线交点)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18543 [思路] 旋转+直线交点 第一个计算几何题,照着书上代码打 ...
- UVa 11178 Morley's Theorem (几何问题)
题意:给定三角形的三个点,让你求它每个角的三等分线所交的顶点. 析:根据自己的以前的数学知识,应该很容易想到思想,比如D点,就是应该求直线BD和CD的交点, 以前还得自己算,现在计算机帮你算,更方便, ...
- 简单几何(求交点) UVA 11178 Morley's Theorem
题目传送门 题意:莫雷定理,求三个点的坐标 分析:训练指南P259,用到了求角度,向量旋转,求射线交点 /*********************************************** ...
- UVA 11178 Morley's Theorem 计算几何模板
题意:训练指南259页 #include <iostream> #include <cstdio> #include <cstring> #include < ...
随机推荐
- NGINX宏观手记
一.这里的优化主要是指对nginx的配置优化,一般来说nginx配置文件中对优化比较有作用的主要有以下几项: nginx进程数,建议按照cpu数目来指定,一般跟cpu核数相同或为它的倍数. ``` w ...
- FSHC之MCU接口部分理解
|_____________| |_____| |__ ...
- perl5中锚位修饰符\A \z \Z 和perl4中^(开头)和$(结尾)的区别
习惯使用perl4的开发者总是用^表示字符串开头锚位,用$表示字符串结尾锚位,比如\^https://\ 将会匹配所有以https://开头的字符串,同样,\.bmp$\将会匹配所有以.bmp结尾的字 ...
- python--MySQL数据库初识
一 . MySQL安装 # 下载MySQL地址 https://dev.mysql.com/downloads # 要选稳定的,不要选最新的,稳定的就是半年以上没有出现过bug 现在5.6.43为绝大 ...
- Python编程快速上手--实践项目11.11.1
from selenium import webdriver from selenium.webdriver.common.keys import Keys import time def messa ...
- 10大mysql需要注意的参数
MySQL变量很多,其中有一些MySQL变量非常值得我们注意,下面就为您介绍一些值得我们重点学习的MySQL变量,供您参考. 1 Threads_connected 首先需要注意的,想得到这个变量的值 ...
- HDU 3507 斜率优化 DP Print Article
在kuangbin巨巨博客上学的. #include <iostream> #include <cstdio> #include <cstring> #includ ...
- 【软考2】Java语言的基本知识汇总
导读:现在对于java这一模块,还没有相应的项目经验,只是通过各种类型的资料,对java有一个面上的了解.现在,对此做一个罗列总结,在以后的学习过程中,逐步完善! 一.语言的发展 1.1,机器语言 在 ...
- HDu-2896 病毒侵袭,AC自动机模板题!
病毒侵袭 模板题,不多说了.. 题意:n个不同的字符串分别代表病毒特征,给出m次查询,每次一个字符串(网址),求这个字符串中有几个病毒特征,分别从大到小输出编号,最后输出所有的带病毒网址个数.格式请看 ...
- LeetCode--二分查找相关算法
-(1)有一个升序排列的非负数组,要求利用o(logn)的时间复杂度找到数组中确定数字target的第一次出现的位置下标和最后一次出现的位置下标,如果不存在该target返回[-1,-1] 解决方案: ...