I have a list of circles with a location and radius for each circle eg, [(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.
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
. 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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.