From 9a503da217156f633d466cc67651ddb9e5d8c5b5 Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 3 Jul 2021 09:34:05 -0400 Subject: [PATCH] Work around asy cylinder3dbox bug --- mathics/format/asy.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/mathics/format/asy.py b/mathics/format/asy.py index 53bcb0e87..30e162c37 100644 --- a/mathics/format/asy.py +++ b/mathics/format/asy.py @@ -189,19 +189,22 @@ def cylinder3dbox(self, **options) -> str: asy = "" i = 0 while i < len(self.points) / 2: - asy += "draw(surface(cylinder({0}, {1}, {2}, {3})), rgb({2},{3},{4}));".format( - tuple(self.points[i * 2].pos()[0]), - self.radius, - # distance between start and end - ( - (self.points[i * 2][0][0] - self.points[i * 2 + 1][0][0]) ** 2 - + (self.points[i * 2][0][1] - self.points[i * 2 + 1][0][1]) ** 2 - + (self.points[i * 2][0][2] - self.points[i * 2 + 1][0][2]) ** 2 + try: + asy += "draw(surface(cylinder({0}, {1}, {2}, {3})), rgb({2},{3},{4}));".format( + tuple(self.points[i * 2].pos()[0]), + self.radius, + # distance between start and end + ( + (self.points[i * 2][0][0] - self.points[i * 2 + 1][0][0]) ** 2 + + (self.points[i * 2][0][1] - self.points[i * 2 + 1][0][1]) ** 2 + + (self.points[i * 2][0][2] - self.points[i * 2 + 1][0][2]) ** 2 + ) + ** 0.5, + (1, 1, 0), # FIXME: currently always drawing around the axis X+Y + *face_color[:3], ) - ** 0.5, - (1, 1, 0), # FIXME: currently always drawing around the axis X+Y - *face_color[:3], - ) + except: # noqa + pass i += 1