Euclid
Time Limit: 1000MS Memory limit: 65536K
题目描述
输入
输出
示例输入
0 0 5 0 0 5 3 2 7 2 0 4
1.3 2.6 12.1 4.5 8.1 13.7 2.2 0.1 9.8 6.6 1.9 6.7
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
示例输出
5.000 0.800 0.000 0.800
13.756 7.204 2.956 5.304
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
struct Point
{
double x,y;
}A,B,C,D,E,F,G,H;
double dis(Point a,Point b)
{
return(sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)));
}
int main()
{
//freopen("1.txt","r",stdin);
int i,j;
while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y,&D.x,&D.y,&E.x,&E.y,&F.x,&F.y)!=EOF)
{
if(!A.x&&!A.y&&!B.x&&!B.y&&!C.x&&!C.y&&!D.x&&!D.y&&!E.x&&!E.y)
break;
double triangle,par;
double p=0,p2=0;
double t1=dis(D,E),tt1=dis(A,B);
double t2=dis(D,F),tt2=dis(B,C);
double t3=dis(E,F),tt3=dis(A,C);
p=(t1+t2+t3)/2;p2=(tt1+tt2+tt3)/2;
triangle=sqrt(p*(p-t1)*(p-t2)*(p-t3));
par = 2*sqrt(p2*(p2-tt1)*(p2-tt2)*(p2-tt3));
double r = triangle/par;
H.x=A.x+r*(C.x-A.x);
H.y=A.y+r*(C.y-A.y);
G.x=B.x+r*(C.x-A.x);
G.y=B.y+r*(C.y-A.y);
printf("%.3lf %.3lf %.3lf %.3lf
",G.x,G.y,H.x,H.y);
}
return 0;
}