Point of Intersection

点击打开链接

Given two circles on the same plane which are centered at (x1,y1) and (x2,y2) ,with radiuses r1 and r2, respectively.We can see that they have two common tangent lines in most of the cases.Now you are asked to write a programme to calculate the point of intersection of the two tangents if there exists one. ( See Figure 1 )

Figure. 1 Point of intersection


Input

The input data consists of the information of several figures.The first line of the input contains the number of figures.
Each figure is described by two lines of data.Each line contains 3 integers constituting the coordinates of the center (x, y) and the radius r (>0) of a circle.

Output

For each figure, you are supposed to output the coordinates (x, y) of the point of intersection if it exists.The x and y must be rounded to two decimal places and be separated by one space.If there is no such point exists simply output "Impossible."

Sample Input

2
0 0 10
0 0 5
0 0 10
10 0 1


Output for the Sample Input

Impossible.
11.11 0.00

Notice

The common tangent lines like the following figure don't take into account;



#include<stdio.h>
#include<math.h>
int main()
{
	double x1,r,x2,r1,r2,y1,y2,ww,juli,xx,yy;
	int ncase;
	scanf("%d",&ncase);
	while(ncase--)
	{
	     scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&r1,&x2,&y2,&r2);
		if(r1>r2)
		{
			ww=x1;x1=x2;x2=ww;
			ww=y1;y1=y2;y2=ww;
			ww=r1;r1=r2;r2=ww;
		}
		juli=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
		//printf("juli=%.5lf %.5lf\n",juli,(r1+r2)*(r1+r2));
		if(fabs(r1-r2)<=1e-6)
		{
			printf("Impossible.\n");
			continue;
		}
		else if((fabs(juli)-fabs((r1-r2)*(r1-r2)))<=1e-6)
		{
			printf("Impossible.\n");
			continue;
		}
		else
		{
			//r=-r1/r2;
			xx=(r2*x1-r1*x2)/(r2-r1);
			yy=(r2*y1-r1*y2)/(r2-r1);
			printf("%.2lf %.2lf\n",xx,yy);
		}
	}
	return 0;
}


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值