就是给出一个等边三角形的三个顶点坐标

然后每一个角的三等分线会交错成一个三角形,求出这个三角形的顶点坐标

一開始。我题意理解错了……还以为是随意三角形,所以代码可以处理随意三角形的情况

我的做法:

通过旋转点的位置得到这些三等分线的直线方程,然后用高斯消元求交点

我的代码:

#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

Root :: Prominent Problemsetters ::

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

最新文章

  1. PHP读取大文件实践
  2. leetcode--Maximum Subarray
  3. java.lang.NoClassDefFoundError 解决方案
  4. MongoDB学习笔记(索引)(转)
  5. 【转载】ANSYS动力学分析-瞬态分析
  6. Spring第一天
  7. knockout.js的简介和简单使用
  8. 去除GHOST版系统自带的2345流氓软件
  9. Careercup - Microsoft面试题 - 5718181884723200
  10. How Tomcat Works(六)
  11. OA 权限控制
  12. ssh无密码登陆(转)
  13. pwnable.kr random 之 write up
  14. Redis锁构造
  15. DataTable筛选某列最大值
  16. 好奇,项目根目录下的.editorconfig文件
  17. Mac 与 windows eclipse 快捷键对照
  18. multiThread (一)
  19. sql server查询语句条件判断字段值是否为NULL
  20. 错误代码 1045 Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password:YES)

热门文章

  1. shell进阶
  2. Git学习——把文件推送到远程仓库
  3. 【linux】【git】git报错fatal: HTTP request failed
  4. 生物信息学练习2- Biom-format
  5. PAT Basic 1052
  6. python基础——11(模块初识)
  7. BZOJ 2295: [POJ Challenge]我爱你啊
  8. 【01】markdown语法
  9. vue.js+element-ui
  10. Programming Python 3rd Edition 第三版 pdf chm下载