First time here? Check out the FAQ!

Ask Your Question
1

How to draw three pyramids inside a right prism?

asked 7 years ago

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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 7 years ago

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
Preview: (hide)
link

Comments

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

screened00 gravatar imagescreened00 ( 7 years ago )

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

screened00 gravatar imagescreened00 ( 7 years ago )

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 ( 7 years ago )

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

screened00 gravatar imagescreened00 ( 7 years ago )

I ran your code with poygon3d, but error.

screened00 gravatar imagescreened00 ( 7 years ago )

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: 7 years ago

Seen: 690 times

Last updated: Jun 06 '17