Skip to content

Commit 9a503da

Browse files
committed
Work around asy cylinder3dbox bug
1 parent ad526d1 commit 9a503da

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

mathics/format/asy.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -189,19 +189,22 @@ def cylinder3dbox(self, **options) -> str:
189189
asy = ""
190190
i = 0
191191
while i < len(self.points) / 2:
192-
asy += "draw(surface(cylinder({0}, {1}, {2}, {3})), rgb({2},{3},{4}));".format(
193-
tuple(self.points[i * 2].pos()[0]),
194-
self.radius,
195-
# distance between start and end
196-
(
197-
(self.points[i * 2][0][0] - self.points[i * 2 + 1][0][0]) ** 2
198-
+ (self.points[i * 2][0][1] - self.points[i * 2 + 1][0][1]) ** 2
199-
+ (self.points[i * 2][0][2] - self.points[i * 2 + 1][0][2]) ** 2
192+
try:
193+
asy += "draw(surface(cylinder({0}, {1}, {2}, {3})), rgb({2},{3},{4}));".format(
194+
tuple(self.points[i * 2].pos()[0]),
195+
self.radius,
196+
# distance between start and end
197+
(
198+
(self.points[i * 2][0][0] - self.points[i * 2 + 1][0][0]) ** 2
199+
+ (self.points[i * 2][0][1] - self.points[i * 2 + 1][0][1]) ** 2
200+
+ (self.points[i * 2][0][2] - self.points[i * 2 + 1][0][2]) ** 2
201+
)
202+
** 0.5,
203+
(1, 1, 0), # FIXME: currently always drawing around the axis X+Y
204+
*face_color[:3],
200205
)
201-
** 0.5,
202-
(1, 1, 0), # FIXME: currently always drawing around the axis X+Y
203-
*face_color[:3],
204-
)
206+
except: # noqa
207+
pass
205208

206209
i += 1
207210

0 commit comments

Comments
 (0)