From 4b651861ab79194b0d96a7f3d176c2239f822f13 Mon Sep 17 00:00:00 2001 From: Bruce Sherwood Date: Sun, 3 Mar 2024 14:13:42 -0800 Subject: [PATCH] fix bound_box --- vpython/vpython.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/vpython/vpython.py b/vpython/vpython.py index 97079cb..28c1056 100644 --- a/vpython/vpython.py +++ b/vpython/vpython.py @@ -1078,7 +1078,11 @@ def rotate(self, angle=None, axis=None, origin=None): self.addattr('pos') def bounding_box(self): - centered = ['box', 'compound', 'ellipsoid', 'sphere', 'simple_sphere', 'ring'] + centered = False + if self._objName in ['box', 'ellipsoid', 'sphere', 'simple_sphere', 'ring']: + centered = True + elif self._objName[:8] == 'compound': # compound ObjName has trailing index + centered = True x = norm(self._axis) y = norm(self._up) z = norm(cross(x,y)) @@ -1086,8 +1090,8 @@ def bounding_box(self): H = self._size.y W = self._size.z p = vector(self._pos) # make a copy of pos, so changes to p won't affect the object - if self._objName not in centered: - p = p + 0.5*L*x # move to center + if not centered: + p += 0.5*L*x # move to center pts = [] for dx in [-L/2, L/2]: for dy in [-H/2, H/2]: