POJ 1673 几何证明加计算几何。。。

EXOCENTER OF A TRIANGLE
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 3199 Accepted: 1253

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

题意:给定一个三角形然后在其三边作三个正方形,两两连接正方形,构成三个外部的三角形,且AL,BM,CN为外部三个三角形的中线,然后反向延长交于O求O点坐标。
分析:投机取巧法:画一个正三角形和一个直角三角形发现。。那个O点为垂心,求垂心坐标即可。。
      正规做法:分析与三角形ABC相连的一个三角形CFH,证明CN的反向延长线垂直于AB首先在三角形CFH中,CN为FH中点,易有S△FCN=S△CNH(等底同高),首先有AC=b,BC=a
      则有CH=a,CF=b,设角FCN=x,角HCN=y,那么由正弦定理有:a*CN*siny=b*CN*sinx则有:asiny=bsinx,反向延长NC,分别过A B作射线的垂线 垂足分别为K1,K2,由互余关系
      关系有:角K2BC+角BCK2=90°,角BCK2+y=90°则有 角K2BC=y,同理角CAK1=x,则分别在两个三角形中有CK2=BC*siny CK1=AC*sinx 则CK1=CK2,即K1,K2重合于K,且K
      只有才AB上,那么有CK⊥AB,则证得NC的反向延长线NK⊥AB,同理在另外两个三角形中做法同前面的做法,则可以知道O为三角形三边高线交点,既O点坐标为垂心坐标。
      证明完毕。。。
下一步求坐标:分别设A(x1,y1),B(x2,y2),C(x3,y3),O(x,y),由于AO⊥BC BO⊥AC,则有一个方程组:
              x*(x3-x1)+y*(y3-y2)=x1*(x3-x2)+y1*(y3-y2)
              x*(x3-x1)+y*(y3-y1)=x2*(x3-x1)+y2*(y3-y1)
            接下来用线性代数的知识克莱姆法则可以求出x,y 大致是构造三个行列式D DX DY;
            则X=DX/D,Y=DY/Y求得。。
最后的一点坑:因为是DOULBE 型的数据,所以会出现浮点失精,所以在结果后面加上一个EPS防止丢失精度,然后就这样的过了。。
虽然垂心坐标浙大有模板。。 但是模板太复杂智商太低不愿套。。所以就自己写了。。。


#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
const double EPS = 1e-8;



double ans(double a,double b,double c,double d)
{
    return a*d-b*c;
}


int main()
{
    int t;
    cin>>t;
    while(t--)
    {
       double x1,y1;
       double x2,y2;
       double x3,y3;
       cin>>x1>>y1>>x2>>y2>>x3>>y3;
       double u,v;
       u=x1*(x3-x2)+y1*(y3-y2);
       v=x2*(x3-x1)+y2*(y3-y1);
       double d=ans((x3-x2),(y3-y2),(x3-x1),(y3-y1));
       double dx=ans(u,y3-y2,v,y3-y1);
       double dy=ans(x3-x2,u,x3-x1,v);
       double x;
       double y;
       x=dx/d+EPS;
       y=dy/d+EPS;
       printf("%.4lf %.4lf\n",x,y);

    }
        return 0;

}



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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值