zoj 1199 几何公式推导
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=199
Point of Intersection
Time Limit: 2 Seconds Memory Limit: 65536 KB
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;

Source: Zhejiang University Local Contest 2002, Preliminary
————————————————————————————————————————————————————
题意很明确,就是求两圆公切线的交点
要判断什么情况下无法画公切线,其实也就是内含,与内切不行
然后推导公式,X=r2/(r1-r2)*(x2-x1)+x2;
Y=r2/(r1-r2)*(y2-y1)+y2;
如果你说,这怎么推?俺不会
那我可以说你就是个脑残
因为我也推不出来,找到这里才了解:
http://zhidao.baidu.com/link?url=FSE5MMeIMP8OOOEe4sSqLTZHEVLAQDd4j5gKkIZo54kMCd6TfwWFs3nOame8It1FuGpmVFdFbK3pbyhydbRco_
是不是脑残?中学数学都不会,丢不丢人?
楼主就是个脑残模板,就这公式推了一天
这模板希望永远别使用
——————————————————————————————————————————————————————
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream> using namespace std; #define eps 1e-8 typedef struct point
{
double x;
double y;
}point; double dy(double x,double y){ return x>y+eps; }
double xy(double x,double y){ return x<y-eps; }
double dyd(double x,double y){ return x>y-eps; }
double xyd(double x,double y){ return x<y+eps; }
double dd(double x,double y){ return fabs(x-y)<eps; } double dist(point a,point b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));//virtual
} int main()
{
int t;
point o1,o2;
double r1,r2;
scanf("%d",&t);
while(t--)
{
double x1,x2,y1,y2,r3,r4;
scanf("%lf%lf%lf",&x1,&y1,&r3);
scanf("%lf%lf%lf",&x2,&y2,&r4);
if(dy(r3,r4))
{
o1.x=x1;o2.x=x2;
o1.y=y1;o2.y=y2;
r1=r3; r2=r4;
}
else
{
o1.x=x2;o2.x=x1;
o1.y=y2;o2.y=y1;
r1=r4; r2=r3;
}
if(dd(r1,r2) || xyd(dist(o1,o2)+r2,r1))
printf("Impossible.\n");
else
{
double x=(r2/(r1-r2))*(o2.x-o1.x)+o2.x;
double y=(r2/(r1-r2))*(o2.y-o1.y)+o2.y;
printf("%.2lf %.2lf\n",x,y);
}
}
return ;
}
zoj 1199 几何公式推导的更多相关文章
- ZOJ 3903 Ant(公式推导)
这个公式推导过程是看的这位大牛的http://blog.csdn.net/bigbigship/article/details/49123643 扩展欧几里德求模的逆元方法: #include < ...
- 多视几何——三角化求解3D空间点坐标
VINS-Mono / VINS-Fusion中triangulatePoint()函数通过三角化求解空间点坐标,代码所体现的数学描述不是很直观,查找资料,发现参考文献[1]对这个问题进行详细解释,记 ...
- SVM个人学习总结
SVM个人学习总结 如题,本文是对SVM学习总结,主要目的是梳理SVM推导过程,以及记录一些个人理解. 1.主要参考资料 [1]Corres C. Support vector networks[J] ...
- ZOJ 2301/HDU 1199 线段树+离散化
给这个题目跪了两天了,想吐简直 发现自己离散化没学好 包括前一个离散化的题目,实际上是错了,我看了sha崽的博客后才知道,POJ那题简直数据弱爆了,本来随便一组就能让我WA掉的,原因在于离散化的时候, ...
- [ACM_暴力][ACM_几何] ZOJ 1426 Counting Rectangles (水平竖直线段组成的矩形个数,暴力)
Description We are given a figure consisting of only horizontal and vertical line segments. Our goal ...
- [ACM_几何] Transmitters (zoj 1041 ,可旋转半圆内的最多点)
Description In a wireless network with multiple transmitters sending on the same frequencies, it is ...
- ZOJ 2301 / HDU 1199 Color the Ball 离散化+线段树区间连续最大和
题意:给你n个球排成一行,初始都为黑色,现在给一些操作(L,R,color),给[L,R]区间内的求染上颜色color,'w'为白,'b'为黑.问最后最长的白色区间的起点和终点的位置. 解法:先离散化 ...
- 简单几何(直线与圆的交点) ZOJ Collision 3728
题目传送门 题意:有两个一大一小的同心圆,圆心在原点,大圆外有一小圆,其圆心有一个速度(vx, vy),如果碰到了小圆会反弹,问该圆在大圆内运动的时间 分析:将圆外的小圆看成一个点,判断该直线与同心圆 ...
- HDU 1199 && ZOJ 2301 线段树离散化
一段长度未知的线段.一种操作:a b c ,表示区间[a,b]涂为颜色C,w代表白色,b代表黑色,问终于的最长连续白色段,输出起始位置和终止位置 离散化处理.和寻常的离散化不同,须要把点化成线段.左闭 ...
随机推荐
- java基础整理1
1.匿名对象:new persion().tell();这样的,它只开辟栈内存,没有栈引用的关系 2.构造方法的名称必须与类名称一致,构造方法的声明处不能有任何返回值类型的声明,不能在构造方法中使用r ...
- struct termios结构体【转】
本文转载自:http://blog.csdn.net/vevenlcf/article/details/51096122 一.数据成员 termios 函数族提供了一个常规的终端接口,用于控制非同步通 ...
- Notepad++编辑Pyhton文件的自动缩进的问题(图文)
转自:http://www.xuebuyuan.com/1102224.html 这个问题一直困扰我很久,Python对缩进很敏感,一般建议缩进用空格,而 Notepad++的自动缩进是用的TAB,g ...
- 160905、c3p0详细配置
官方文档 : http://www.mchange.com/projects/c3p0/index.html <c3p0-config> <default-config> &l ...
- 搬瓦工的ShadowSock设置方法:
- LR场景设置里的各参数解释
1.Start Vuser ep1: Strat 100 Vusers :2 every 00:00:15(HH:MM:SS) 解释: 场景总共要跑100个虚拟用户,每15秒启动2个虚拟用户Vuser ...
- 如何修复损坏的MySQL数据表
id=164 由于断电或非正常关机而导致MySQL数据库出现错误是非常常见的问题.有两种方法,一种方法使用mysql的check table和repair table 的sql语句,另一种方法是使用M ...
- Akka.NET
https://github.com/akkadotnet Akka是什么? 可扩展的分布式实时事务处理 编写正确的并发,容错和可扩展的应用程序是太难了.大多数时候,这是因为我们使用了错误的工具和错误 ...
- std的find和reverse_iterator联合使用
上代码: // test2013.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <stdlib.h> #in ...
- 27、oracle(三)
1)掌握增.删.改数据和事务操作 2)掌握[视图]和同义词 3)掌握[序列]和索引 4)了解有关用户和权限的控制 ------------------------------------------- ...