Ask Your Question
1

How to draw three pyramids inside a right prism?

asked 2017-06-06 17:24:02 +0100

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
2

answered 2017-06-06 20:40:13 +0100

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

Comments

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

screened00 gravatar imagescreened00 ( 2017-06-07 12:51:54 +0100 )edit

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

screened00 gravatar imagescreened00 ( 2017-06-07 12:52:58 +0100 )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 17:05:28 +0100 )edit

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

screened00 gravatar imagescreened00 ( 2017-06-08 18:03:27 +0100 )edit

I ran your code with poygon3d, but error.

screened00 gravatar imagescreened00 ( 2017-06-08 18:04:02 +0100 )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

Stats

Asked: 2017-06-06 17:24:02 +0100

Seen: 620 times

Last updated: Jun 06 '17