poj 1673 EXOCENTER OF A TRIANGLE(求三角形垂心)

EXOCENTER OF A TRIANGLE
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 2947 Accepted: 1116

Description

Given a triangle ABC, the Extriangles of ABC are constructed as follows: 
On each side of ABC, construct a square (ABDE, BCHJ and ACFG in the figure below). 
Connect adjacent square corners to form the three Extriangles (AGD, BEJ and CFH in the figure). 
The Exomedians of ABC are the medians of the Extriangles, which pass through vertices of the original triangle,extended into the original triangle (LAO, MBO and NCO in the figure. As the figure indicates, the three Exomedians intersect at a common point called the Exocenter (point O in the figure). 
This problem is to write a program to compute the Exocenters of triangles. 

Input

The first line of the input consists of a positive integer n, which is the number of datasets that follow. Each dataset consists of 3 lines; each line contains two floating point values which represent the (two -dimensional) coordinate of one vertex of a triangle. So, there are total of (n*3) + 1 lines of input. Note: All input triangles wi ll be strongly non-degenerate in that no vertex will be within one unit of the line through the other two vertices.

Output

For each dataset you must print out the coordinates of the Exocenter of the input triangle correct to four decimal places.

Sample Input

2
0.0 0.0
9.0 12.0
14.0 0.0
3.0 4.0
13.0 19.0
2.0 -10.0

Sample Output

9.0000 3.7500
-48.0400 23.3600

Source

题目:http://poj.org/problem?id=1673

题意:给你个三角形,然后各种画图,给了个新的定义,最后可以转换成求垂心的问题

分析:三角形求垂心,枚举两条边,可以计算出垂直于他们的极角,然后列两个方程求解就行,直接抄袭这里的代码就行

PS:这题比较恶心了,还好poj有discuss,偷瞄了一眼,答案要加上一个eps才能AC啊= =

代码:

#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
double ax,ay,bx,by,cx,cy,r,a1,a2,x,y;
int n;
int main()
{
    scanf("%d",&n);
    while(n--)
    {
        scanf("%lf%lf%lf%lf%lf%lf",&ax,&ay,&bx,&by,&cx,&cy);
        a1=atan2(by-ay,bx-ax)+acos(-1.0)/2;
        a2=atan2(cy-by,cx-bx)+acos(-1.0)/2;
        r=(sin(a2)*(cx-ax)+cos(a2)*(ay-cy))/(sin(a1)*cos(a2)-sin(a2)*cos(a1));
        x=cx+r*cos(a1),y=cy+r*sin(a1);
        printf("%.4lf %.4lf\n",x+1e-8,y+1e-8);
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值