本文整理汇总了Python中circle.Circle.intersection_with方法的典型用法代码示例。如果您正苦于以下问题:Python Circle.intersection_with方法的具体用法?Python Circle.intersection_with怎么用?Python Circle.intersection_with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类circle.Circle
的用法示例。
在下文中一共展示了Circle.intersection_with方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: trilateration_phase
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import intersection_with [as 别名]
def trilateration_phase(points_in, distance_matrix):
points_out = [points_in[0]] # force point 0 to stay at origin
for target_idx in range(1, len(points_in)):
approximations = [] # points which are approximate 'target'
# we want pairs of circles which intersect at target. Will have circle A and circle B.
for source_a_idx, source_b_idx in itertools.combinations(range(0, len(points_in)), 2):
# ensure the centre of the circle isn't target.
# It must be defined by another point and target
if (source_a_idx != target_idx) and (source_b_idx != target_idx):
a_center = points_in[source_a_idx]
a_rad = distance_matrix[source_a_idx][target_idx]
a = Circle(a_center, a_rad)
b_center = points_in[source_b_idx]
b_rad = distance_matrix[source_b_idx][target_idx]
b = Circle(b_center, b_rad)
intersections = a.intersection_with(b)
approximations.append(points_in[target_idx].get_closest(intersections))
approximation = get_centroid(approximations)
points_out.append(approximation)
return points_out
示例2: CircleTester
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import intersection_with [as 别名]
class CircleTester(unittest.TestCase):
def setUp(self):
self.c0 = Circle(point.Point(4, 0.5), 5)
self.c1 = Circle(point.Point(1, -1), 4)
def test_intersection(self):
intersection = self.c0.intersection_with(self.c1)
# as per: http://www.calcul.com/circle-circle-intersection
p0 = point.Point(3.0825543469976, -4.4151086939952)
p1 = point.Point(-0.48255434699759, 2.7151086939952)
expected = [p0, p1]
self.assertAlmostEqual(intersection[0].x, expected[0].x)
self.assertAlmostEqual(intersection[0].y, expected[0].y)
self.assertAlmostEqual(intersection[1].x, expected[1].x)
self.assertAlmostEqual(intersection[1].y, expected[1].y)
def test_positive_intersection(self):
intersection = self.c0.positive_intersection_with(self.c1)
expected = point.Point(-0.48255434699759, 2.7151086939952)
self.assertAlmostEqual(intersection.x, expected.x)
self.assertAlmostEqual(intersection.y, expected.y)