Skip to content

Commit 4b65186

Browse files
committed
fix bound_box
1 parent 4d34e51 commit 4b65186

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

vpython/vpython.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,16 +1078,20 @@ def rotate(self, angle=None, axis=None, origin=None):
10781078
self.addattr('pos')
10791079

10801080
def bounding_box(self):
1081-
centered = ['box', 'compound', 'ellipsoid', 'sphere', 'simple_sphere', 'ring']
1081+
centered = False
1082+
if self._objName in ['box', 'ellipsoid', 'sphere', 'simple_sphere', 'ring']:
1083+
centered = True
1084+
elif self._objName[:8] == 'compound': # compound ObjName has trailing index
1085+
centered = True
10821086
x = norm(self._axis)
10831087
y = norm(self._up)
10841088
z = norm(cross(x,y))
10851089
L = self._size.x
10861090
H = self._size.y
10871091
W = self._size.z
10881092
p = vector(self._pos) # make a copy of pos, so changes to p won't affect the object
1089-
if self._objName not in centered:
1090-
p = p + 0.5*L*x # move to center
1093+
if not centered:
1094+
p += 0.5*L*x # move to center
10911095
pts = []
10921096
for dx in [-L/2, L/2]:
10931097
for dy in [-H/2, H/2]:

0 commit comments

Comments
 (0)