作者iasm (I am Nobody)
看板Math
标题[几何] 请问包含两个点的最小圆
时间Mon May 23 00:25:09 2016
请教各位,我看到一题演算法smallest circle problem的一个特例
其题目如下
Give two planar points p1=(a1,b1) and p2=(a2,b2) and a line y=0,
design an algorithm to find the smallest circle that covers
both points such that its center (x*, 0) lies on y=0
由於本题的两个点并不一定需要在圆周上,故跟原始问题不太像
例如有一点个是(2,5),另一个点是(2,3),由於限制圆心在x轴上
这两个点又在同一条直线上,因此最小圆的圆心在(2,0),(2,5)在圆周上
(2,3)在"圆内",但如果两个一个在x轴上,一个在x轴下,那情形又不一样了
想请问各位,有没有更为"一般"的演算可以涵盖所有可能呢?
--
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 218.161.26.106
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Math/M.1463934312.A.DEF.html
1F:推 Vulpix : if( abs(b1)>abs(b2) ) 05/23 00:46
2F:→ Vulpix : if( (a1-a2)^2+b2^2 <= b1^2 ) 05/23 00:49
3F:→ Vulpix : x*=a1; radius=abs(b1) 05/23 00:50
4F:→ Vulpix : else 05/23 00:52
5F:→ Vulpix : x*=( a1^-a2^2+b1^2-b2^2 )/2(a1-a2); 05/23 00:53
6F:→ Vulpix : radius自己算... 05/23 00:54
7F:→ Vulpix : else 就只是把p1跟p2对调而已 05/23 00:54
8F:→ Vulpix : 其实跟在x轴上下方没有关系,因为圆是对称的。 05/23 17:05
9F:推 suhorng : min_x max_i d(p_i,(x,0)) 也可硬解,比一楼方法麻烦 05/23 18:27