diff --git a/mathics/format/asy_polyhedra.py b/mathics/format/asy_polyhedra.py index 43c999820..6e0c94555 100644 --- a/mathics/format/asy_polyhedra.py +++ b/mathics/format/asy_polyhedra.py @@ -17,7 +17,7 @@ def dodecahedron(center: tuple, length: float, color_str: str) -> str: real a=sqrt(1-phi*phi/4-g*g)+phi/2; triple center={center}; - real length={length}; + real length={length} / 2; triple[] d; d[0]=center + length*(phi/2,phi/2,phi/2); d[1]=center + length*(-phi/2,phi/2,phi/2); @@ -73,6 +73,48 @@ def dodecahedron(center: tuple, length: float, color_str: str) -> str: """ +def octahedron(center: tuple, length: float, color_str: str) -> str: + """ + Return an asymptote program string to draw a tetrahedron at `center` + with length `length`. + """ + return f""" + triple center={center}; + real vertex_position = 0.30615 * {length}; + + triple[] d; + path3[] p; + + d[0]=center + (0, vertex_position, 0); + d[1]=center + (0, 0, vertex_position); + d[2]=center + (-vertex_position, 0, 0); + d[3]=center + (0, 0, -vertex_position); + d[4]=center + (vertex_position, 0, 0); + d[5]=center + (0, -vertex_position, 0); + + p[0]=d[0]--d[1]--d[2]--cycle; + p[1]=d[0]--d[2]--d[3]--cycle; + p[2]=d[0]--d[3]--d[4]--cycle; + p[3]=d[0]--d[4]--d[1]--cycle; + + p[4]=d[5]--d[1]--d[2]--cycle; + p[5]=d[5]--d[2]--d[3]--cycle; + p[6]=d[5]--d[3]--d[4]--cycle; + p[7]=d[5]--d[4]--d[1]--cycle; + + pen sides={color_str}; + + draw(surface(p[0]),sides); + draw(surface(p[1]),sides); + draw(surface(p[2]),sides); + draw(surface(p[3]),sides); + draw(surface(p[4]),sides); + draw(surface(p[5]),sides); + draw(surface(p[6]),sides); + draw(surface(p[7]),sides); + """ + + def tetrahedron(center: tuple, length: float, color_str: str) -> str: """ Return an asymptote program string to draw a tetrahedron at `center` @@ -109,5 +151,6 @@ def unimplimented_polygon(center: tuple, length: float, color_str: str) -> str: HEDRON_NAME_MAP: Dict[str, Callable] = { "dodecahedron": dodecahedron, + "octahedron": octahedron, "tetrahedron": tetrahedron, } diff --git a/mathics/format/latex.py b/mathics/format/latex.py index 707e6ec41..de54c3797 100644 --- a/mathics/format/latex.py +++ b/mathics/format/latex.py @@ -559,7 +559,8 @@ def graphics3dbox(self, elements=None, **options) -> str: import tube; size({0}cm, {1}cm); currentprojection=perspective({2[0]},{2[1]},{2[2]}); -currentlight=light(rgb(0.5,0.5,1), {5}specular=red, (2,0,2), (2,2,2), (0,2,2)); +currentlight=light(0,5,10); +//currentlight=light(rgb(0.5,0.5,0.5), {5}specular=red, (2,0,2), (2,2,2), (0,2,2)); {3} {4} \end{{asy}} diff --git a/test/builtin/drawing/test_plot.py b/test/builtin/drawing/test_plot.py index 281e2a032..b57e588c6 100644 --- a/test/builtin/drawing/test_plot.py +++ b/test/builtin/drawing/test_plot.py @@ -105,7 +105,7 @@ "import tube;\n" "size(6.6667cm, 6.6667cm);\n" "currentprojection=perspective(2.6,-4.8,4.0);\n" - "currentlight=light(rgb(0.5,0.5,1), background=rgb(1, 0.1, 0.1), specular=red, (2,0,2), (2,2,2), (0,2,2));\n" + "currentlight=light(rgb(0.5,0.5,0.5), background=rgb(1, 0.1, 0.1), specular=red, (2,0,2), (2,2,2), (0,2,2));\n" "// Sphere3DBox\n" "draw(surface(sphere((0, 0, 0), 1)), rgb(1,1,1)+opacity(1));\n" "draw(((-1,-1,-1)--(1,-1,-1)), rgb(0.4, 0.4, 0.4)+linewidth(1));\n" @@ -133,7 +133,7 @@ "import tube;\n" "size(6.6667cm, 6.6667cm);\n" "currentprojection=perspective(2.6,-4.8,4.0);\n" - "currentlight=light(rgb(0.5,0.5,1), specular=red, (2,0,2), (2,2,2), (0,2,2));\n" + "currentlight=light(rgb(0.5,0.5,0.5), specular=red, (2,0,2), (2,2,2), (0,2,2));\n" "// Point3DBox\npath3 g=(0,1,0)--(0.20791,0.97815,0)--(0.40674,0.91355,0)--" "(0.58779,0.80902,0)--(0.74314,0.66913,0)--(0.86603,0.5,0)--(0.95106,0.30902,0)--" "(0.99452,0.10453,0)--(0.99452,-0.10453,0)--(0.95106,-0.30902,0)--(0.86603,-0.5,0)"