Ecco una funzione che e' molto piu generale per ottenere i vertici del "bounding box" (Here's a function that is much more general to obtain the vertices of the "bounding box"):
def bounding_box(obj, center):
# center is True for box, sphere, ring
x = norm(obj.axis)
y = norm(obj.up)
z = norm(cross(x,y))
y = norm(cross(z,x))
L = obj.size.x
H = obj.size.y
W = obj.size.z
p = vector(obj.pos) # make a copy of obj.pos, so changes to p won't affect the object
if not center:
p = p + 0.5*L*x # move to center
pts = []
for dx in [-L/2, L/2]:
for dy in [-H/2, H/2]:
for dz in [-W/2, W/2]:
pts.append(p + dx*x + dy*y + dz*z)
return pts
b = pyramid(pos=vector(4,2,0), axis=vector(3,1,0), size=vector(8,6,4))
c = bounding_box(b, False)
for v in c:
sphere(pos=v, radius=0.3, color=color.red)