This commit is contained in:
Horldsence
2026-09-11 02:32:31 +08:00
parent 8c18a1f499
commit 4f91f242fe
19 changed files with 971 additions and 45 deletions
+17
View File
@@ -58,6 +58,23 @@ class GeometryTests(unittest.TestCase):
self.assertEqual(r['status'], 'polygon')
self.assertGreater(r['diameter_m'], 1e9)
def test_near_antiparallel_thin_wedge_keeps_far_vertex(self):
"""近平行细长区域不得丢失远端顶点(审核复现案例)。
测站相距 1cm、示向度 1 与 358.99999999999:两条近平行边界相交出
~5.7e10 m 处的远端顶点。旧实现按绝对阈值 PARALLEL_EPS 跳过该平面
对,漏掉顶点后错误报出 0.143m 直径并给出清除保证。
"""
r = solve([Measurement(0, 0, 1), Measurement(0, 0.01, 358.99999999999)])
self.assertEqual(r['status'], 'polygon')
self.assertGreater(r['diameter_m'], 5.7e10)
self.assertFalse(r['guaranteed_clearable_at_mec_center'],
"细长区域的清除保证必须被拒绝")
# 远端方向上的可行源 (1000, 0) 必须仍落在最小包围圆内
mec = r['minimum_enclosing_circle']
self.assertLessEqual(distance(mec['center'], (1000.0, 0.0)),
mec['radius_m'] + 1e-6)
def test_circle_known_shapes(self):
c, r = smallest_enclosing_circle([(0,0),(2,0),(2,2),(0,2)])
self.assertEqual(c, (1,1))