Ask Your Question

How to draw three pyramids inside a right prism?

asked 2017-06-06 10:24:02 -0500

screened00 gravatar image

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 flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-06-06 13:40:13 -0500

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')
edit flag offensive delete link more


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

screened00 gravatar imagescreened00 ( 2017-06-07 05:51:54 -0500 )edit

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

screened00 gravatar imagescreened00 ( 2017-06-07 05:52:58 -0500 )edit

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

John Palmieri gravatar imageJohn Palmieri ( 2017-06-07 10:05:28 -0500 )edit

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

screened00 gravatar imagescreened00 ( 2017-06-08 11:03:27 -0500 )edit

I ran your code with poygon3d, but error.

screened00 gravatar imagescreened00 ( 2017-06-08 11:04:02 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-06-06 10:24:02 -0500

Seen: 48 times

Last updated: Jun 06