EXOCENTER OF A TRIANGLE

EXOCENTER OF A TRIANGLE

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 20000/10000K (Java/Other)
Total Submission(s) : 13   Accepted Submission(s) : 7
Problem 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
PKU
 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <math.h>
 4 typedef struct point{double x,y;}point;
 5 typedef struct line{point a,b;}line;
 6 
 7 double distance(point p1,point p2){
 8     return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
 9 }
10 point intersection(line u,line v){
11     point ret=u.a;
12     double t=((u.a.x-v.a.x)*(v.a.y-v.b.y)-(u.a.y-v.a.y)*(v.a.x-v.b.x))
13             /((u.a.x-u.b.x)*(v.a.y-v.b.y)-(u.a.y-u.b.y)*(v.a.x-v.b.x));
14     ret.x+=(u.b.x-u.a.x)*t;
15     ret.y+=(u.b.y-u.a.y)*t;
16     return ret;
17 }
18 //垂心
19 point perpencenter(point a,point b,point c){
20     line u,v;
21     u.a=c;
22     u.b.x=u.a.x-a.y+b.y;
23     u.b.y=u.a.y+a.x-b.x;
24     v.a=b;
25     v.b.x=v.a.x-a.y+c.y;
26     v.b.y=v.a.y+a.x-c.x;
27     return intersection(u,v);
28 }
29 int main()
30 {
31    int T;
32    point L1,L2,L3,S;
33    scanf("%d",&T);
34    while(T--)
35    {
36        scanf("%lf%lf%lf%lf%lf%lf",&L1.x,&L1.y,&L2.x,&L2.y,&L3.x,&L3.y);
37        S=perpencenter(L1,L2,L3);
38        printf("%.4f %.4f\n",S.x,S.y);
39    }
40     return 0;
41 }
View Code

 

转载于:https://www.cnblogs.com/Wurq/articles/3929270.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值