[英]Bounding box of al list of circles
I have a list of circles with a location and radius for each circle eg, [(x, y, r), ...]
.我有一个圆圈列表,每个圆圈都有一个位置和半径,例如
[(x, y, r), ...]
。
I need to find a bounding box for the entire list so that all circles are contained in the box.我需要为整个列表找到一个边界框,以便所有圆圈都包含在框中。 I tried going over all circles and finding the minimum and maximum
x
and y
values but this does not take into account the radius of each circle.我尝试遍历所有圆并找到最小和最大
x
和y
值,但这并没有考虑每个圆的半径。
xlist = []
ylist = []
for circle in circle_list:
xlist.append(circle[0])
ylist.append(circle[1])
# top-left and bottom-right corners
bbox = [(min(xlist), min(ylist)), (max(xlist), max(ylist))]
You should take radius into account while creating xlist
and ylist
.您应该在创建
xlist
和ylist
时考虑半径。 It is like:它像是:
xlist = []
ylist = []
for circle in circle_list:
x,y,r = circle[0], circle[1], circle[2]
xlist.append(x-r)
xlist.append(x+r)
ylist.append(y-r)
ylist.append(y+r)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.