ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 08 Jun 2017 14:00:01 -0500How to draw three pyramids inside a right prism?https://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/ I want to draw three right pyramids, which together make up a prism. I want to see all the three right pyramids with different colors so that I can see them, and rotate in 3D?
`tetrahedron` is the function that I know, but I can't do it on my own. Or with any other 3D plot?Tue, 06 Jun 2017 10:24:02 -0500https://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/Answer by John Palmieri for <p>I want to draw three right pyramids, which together make up a prism. I want to see all the three right pyramids with different colors so that I can see them, and rotate in 3D?</p>
<p><code>tetrahedron</code> is the function that I know, but I can't do it on my own. Or with any other 3D plot?</p>
https://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/?answer=37816#post-id-37816The `tetratrahedron` function only constructs a regular tetrahedron, it seems, so you need to construct yours by hand. The `polygons3d` function works for this: you specify a list of vertices and also a list of polygons made up of those vertices. For example:
faces = [(0,1,2), (0,1,3), (0,2,3), (1,2,3)]
vertices = [(0,0,0), (1,0,0), (0,1,0), (0,0,1)]
T1 = polygons3d(faces, vertices, color='red')
will use the specified vertices and then construct triangles using vertices numbered 0,1,2 from the list, and vertices 0,1,3, etc. You can write a function that does this:
def Tetrahedron(vertices, color='red'):
faces = [(0,1,2), (0,1,3), (0,2,3), (1,2,3)]
return polygons3d(faces, vertices, color=color)
T1 = Tetrahedron([(0,0,0), (1,0,0), (0,1,0), (0,0,1)], color='red')
T2 = Tetrahedron([(1,0,0), (0,1,0), (0,0,1), (1,0,1)], color='green')
T3 = Tetrahedron([(0,1,0), (0,0,1), (1,0,1), (0,1,1)], color='blue')
T1+T2+T3Tue, 06 Jun 2017 13:40:13 -0500https://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/?answer=37816#post-id-37816Comment by screened00 for <p>The <code>tetratrahedron</code> function only constructs a regular tetrahedron, it seems, so you need to construct yours by hand. The <code>polygons3d</code> function works for this: you specify a list of vertices and also a list of polygons made up of those vertices. For example:</p>
<pre><code>faces = [(0,1,2), (0,1,3), (0,2,3), (1,2,3)]
vertices = [(0,0,0), (1,0,0), (0,1,0), (0,0,1)]
T1 = polygons3d(faces, vertices, color='red')
</code></pre>
<p>will use the specified vertices and then construct triangles using vertices numbered 0,1,2 from the list, and vertices 0,1,3, etc. You can write a function that does this:</p>
<pre><code>def Tetrahedron(vertices, color='red'):
faces = [(0,1,2), (0,1,3), (0,2,3), (1,2,3)]
return polygons3d(faces, vertices, color=color)
T1 = Tetrahedron([(0,0,0), (1,0,0), (0,1,0), (0,0,1)], color='red')
T2 = Tetrahedron([(1,0,0), (0,1,0), (0,0,1), (1,0,1)], color='green')
T3 = Tetrahedron([(0,1,0), (0,0,1), (1,0,1), (0,1,1)], color='blue')
T1+T2+T3
</code></pre>
https://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/?comment=37820#post-id-37820@John polygons3d() is not defined error, I get and polygon3d too accepts only one argument?Wed, 07 Jun 2017 05:51:54 -0500https://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/?comment=37820#post-id-37820Comment by screened00 for <p>The <code>tetratrahedron</code> function only constructs a regular tetrahedron, it seems, so you need to construct yours by hand. The <code>polygons3d</code> function works for this: you specify a list of vertices and also a list of polygons made up of those vertices. For example:</p>
<pre><code>faces = [(0,1,2), (0,1,3), (0,2,3), (1,2,3)]
vertices = [(0,0,0), (1,0,0), (0,1,0), (0,0,1)]
T1 = polygons3d(faces, vertices, color='red')
</code></pre>
<p>will use the specified vertices and then construct triangles using vertices numbered 0,1,2 from the list, and vertices 0,1,3, etc. You can write a function that does this:</p>
<pre><code>def Tetrahedron(vertices, color='red'):
faces = [(0,1,2), (0,1,3), (0,2,3), (1,2,3)]
return polygons3d(faces, vertices, color=color)
T1 = Tetrahedron([(0,0,0), (1,0,0), (0,1,0), (0,0,1)], color='red')
T2 = Tetrahedron([(1,0,0), (0,1,0), (0,0,1), (1,0,1)], color='green')
T3 = Tetrahedron([(0,1,0), (0,0,1), (1,0,1), (0,1,1)], color='blue')
T1+T2+T3
</code></pre>
https://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/?comment=37821#post-id-37821I tried using polygon3d() and failed as a list too.Wed, 07 Jun 2017 05:52:58 -0500https://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/?comment=37821#post-id-37821Comment by John Palmieri for <p>The <code>tetratrahedron</code> function only constructs a regular tetrahedron, it seems, so you need to construct yours by hand. The <code>polygons3d</code> function works for this: you specify a list of vertices and also a list of polygons made up of those vertices. For example:</p>
<pre><code>faces = [(0,1,2), (0,1,3), (0,2,3), (1,2,3)]
vertices = [(0,0,0), (1,0,0), (0,1,0), (0,0,1)]
T1 = polygons3d(faces, vertices, color='red')
</code></pre>
<p>will use the specified vertices and then construct triangles using vertices numbered 0,1,2 from the list, and vertices 0,1,3, etc. You can write a function that does this:</p>
<pre><code>def Tetrahedron(vertices, color='red'):
faces = [(0,1,2), (0,1,3), (0,2,3), (1,2,3)]
return polygons3d(faces, vertices, color=color)
T1 = Tetrahedron([(0,0,0), (1,0,0), (0,1,0), (0,0,1)], color='red')
T2 = Tetrahedron([(1,0,0), (0,1,0), (0,0,1), (1,0,1)], color='green')
T3 = Tetrahedron([(0,1,0), (0,0,1), (1,0,1), (0,1,1)], color='blue')
T1+T2+T3
</code></pre>
https://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/?comment=37825#post-id-37825What version of Sage are you using? (It helps if you say this in your original message, by the way.) Try upgrading.Wed, 07 Jun 2017 10:05:28 -0500https://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/?comment=37825#post-id-37825Comment by screened00 for <p>The <code>tetratrahedron</code> function only constructs a regular tetrahedron, it seems, so you need to construct yours by hand. The <code>polygons3d</code> function works for this: you specify a list of vertices and also a list of polygons made up of those vertices. For example:</p>
<pre><code>faces = [(0,1,2), (0,1,3), (0,2,3), (1,2,3)]
vertices = [(0,0,0), (1,0,0), (0,1,0), (0,0,1)]
T1 = polygons3d(faces, vertices, color='red')
</code></pre>
<p>will use the specified vertices and then construct triangles using vertices numbered 0,1,2 from the list, and vertices 0,1,3, etc. You can write a function that does this:</p>
<pre><code>def Tetrahedron(vertices, color='red'):
faces = [(0,1,2), (0,1,3), (0,2,3), (1,2,3)]
return polygons3d(faces, vertices, color=color)
T1 = Tetrahedron([(0,0,0), (1,0,0), (0,1,0), (0,0,1)], color='red')
T2 = Tetrahedron([(1,0,0), (0,1,0), (0,0,1), (1,0,1)], color='green')
T3 = Tetrahedron([(0,1,0), (0,0,1), (1,0,1), (0,1,1)], color='blue')
T1+T2+T3
</code></pre>
https://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/?comment=37851#post-id-37851@John SageMath version 7.5.1, Release Date: 2017-01-15 . polygon3d is there, but not polygons3d ?Thu, 08 Jun 2017 11:03:27 -0500https://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/?comment=37851#post-id-37851Comment by screened00 for <p>The <code>tetratrahedron</code> function only constructs a regular tetrahedron, it seems, so you need to construct yours by hand. The <code>polygons3d</code> function works for this: you specify a list of vertices and also a list of polygons made up of those vertices. For example:</p>
<pre><code>faces = [(0,1,2), (0,1,3), (0,2,3), (1,2,3)]
vertices = [(0,0,0), (1,0,0), (0,1,0), (0,0,1)]
T1 = polygons3d(faces, vertices, color='red')
</code></pre>
<p>will use the specified vertices and then construct triangles using vertices numbered 0,1,2 from the list, and vertices 0,1,3, etc. You can write a function that does this:</p>
<pre><code>def Tetrahedron(vertices, color='red'):
faces = [(0,1,2), (0,1,3), (0,2,3), (1,2,3)]
return polygons3d(faces, vertices, color=color)
T1 = Tetrahedron([(0,0,0), (1,0,0), (0,1,0), (0,0,1)], color='red')
T2 = Tetrahedron([(1,0,0), (0,1,0), (0,0,1), (1,0,1)], color='green')
T3 = Tetrahedron([(0,1,0), (0,0,1), (1,0,1), (0,1,1)], color='blue')
T1+T2+T3
</code></pre>
https://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/?comment=37852#post-id-37852I ran your code with poygon3d, but error.Thu, 08 Jun 2017 11:04:02 -0500https://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/?comment=37852#post-id-37852Comment by screened00 for <p>The <code>tetratrahedron</code> function only constructs a regular tetrahedron, it seems, so you need to construct yours by hand. The <code>polygons3d</code> function works for this: you specify a list of vertices and also a list of polygons made up of those vertices. For example:</p>
<pre><code>faces = [(0,1,2), (0,1,3), (0,2,3), (1,2,3)]
vertices = [(0,0,0), (1,0,0), (0,1,0), (0,0,1)]
T1 = polygons3d(faces, vertices, color='red')
</code></pre>
<p>will use the specified vertices and then construct triangles using vertices numbered 0,1,2 from the list, and vertices 0,1,3, etc. You can write a function that does this:</p>
<pre><code>def Tetrahedron(vertices, color='red'):
faces = [(0,1,2), (0,1,3), (0,2,3), (1,2,3)]
return polygons3d(faces, vertices, color=color)
T1 = Tetrahedron([(0,0,0), (1,0,0), (0,1,0), (0,0,1)], color='red')
T2 = Tetrahedron([(1,0,0), (0,1,0), (0,0,1), (1,0,1)], color='green')
T3 = Tetrahedron([(0,1,0), (0,0,1), (1,0,1), (0,1,1)], color='blue')
T1+T2+T3
</code></pre>
https://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/?comment=37853#post-id-37853@John btw are you sure, your code works? which version are you using?Thu, 08 Jun 2017 11:08:53 -0500https://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/?comment=37853#post-id-37853Comment by screened00 for <p>The <code>tetratrahedron</code> function only constructs a regular tetrahedron, it seems, so you need to construct yours by hand. The <code>polygons3d</code> function works for this: you specify a list of vertices and also a list of polygons made up of those vertices. For example:</p>
<pre><code>faces = [(0,1,2), (0,1,3), (0,2,3), (1,2,3)]
vertices = [(0,0,0), (1,0,0), (0,1,0), (0,0,1)]
T1 = polygons3d(faces, vertices, color='red')
</code></pre>
<p>will use the specified vertices and then construct triangles using vertices numbered 0,1,2 from the list, and vertices 0,1,3, etc. You can write a function that does this:</p>
<pre><code>def Tetrahedron(vertices, color='red'):
faces = [(0,1,2), (0,1,3), (0,2,3), (1,2,3)]
return polygons3d(faces, vertices, color=color)
T1 = Tetrahedron([(0,0,0), (1,0,0), (0,1,0), (0,0,1)], color='red')
T2 = Tetrahedron([(1,0,0), (0,1,0), (0,0,1), (1,0,1)], color='green')
T3 = Tetrahedron([(0,1,0), (0,0,1), (1,0,1), (0,1,1)], color='blue')
T1+T2+T3
</code></pre>
https://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/?comment=37854#post-id-37854yeah, it works in sagemathcell. But it's only 5months old, not that old , too bad sagemath is in a constant state of turmoil, and flux.Thu, 08 Jun 2017 11:17:52 -0500https://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/?comment=37854#post-id-37854Comment by John Palmieri for <p>The <code>tetratrahedron</code> function only constructs a regular tetrahedron, it seems, so you need to construct yours by hand. The <code>polygons3d</code> function works for this: you specify a list of vertices and also a list of polygons made up of those vertices. For example:</p>
<pre><code>faces = [(0,1,2), (0,1,3), (0,2,3), (1,2,3)]
vertices = [(0,0,0), (1,0,0), (0,1,0), (0,0,1)]
T1 = polygons3d(faces, vertices, color='red')
</code></pre>
<p>will use the specified vertices and then construct triangles using vertices numbered 0,1,2 from the list, and vertices 0,1,3, etc. You can write a function that does this:</p>
<pre><code>def Tetrahedron(vertices, color='red'):
faces = [(0,1,2), (0,1,3), (0,2,3), (1,2,3)]
return polygons3d(faces, vertices, color=color)
T1 = Tetrahedron([(0,0,0), (1,0,0), (0,1,0), (0,0,1)], color='red')
T2 = Tetrahedron([(1,0,0), (0,1,0), (0,0,1), (1,0,1)], color='green')
T3 = Tetrahedron([(0,1,0), (0,0,1), (1,0,1), (0,1,1)], color='blue')
T1+T2+T3
</code></pre>
https://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/?comment=37870#post-id-37870Adding a feature does not equal "in a constant state of turmoil, and flux". But keep using 7.5.1 if you don't want any new features.Thu, 08 Jun 2017 14:00:01 -0500https://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/?comment=37870#post-id-37870