# 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?

edit retag close merge delete

Sort by ยป oldest newest most voted

The 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+T3

more

@John polygons3d() is not defined error, I get and polygon3d too accepts only one argument?

( 2017-06-07 12:51:54 +0200 )edit

I tried using polygon3d() and failed as a list too.

( 2017-06-07 12:52:58 +0200 )edit

What version of Sage are you using? (It helps if you say this in your original message, by the way.) Try upgrading.

( 2017-06-07 17:05:28 +0200 )edit

@John SageMath version 7.5.1, Release Date: 2017-01-15 . polygon3d is there, but not polygons3d ?

( 2017-06-08 18:03:27 +0200 )edit

I ran your code with poygon3d, but error.

( 2017-06-08 18:04:02 +0200 )edit