Ask Your Question

Revision history [back]

Those are cool!

I just learned how to apply a colormap to 3dplots--probably a secondary issue for you at this stage, but it gives an example of plotting a surface:

var('r v')
cmsel = [colormaps['autumn'](i) for i in sxrange(0,1,0.05)]
p = plot3d(0.2*(r**2 + v**2) + cos(2*r)*sin(2*v),(r,-2,2), (v,-2,2), adaptive=True, color=cmsel, plot_points=10, opacity=0.9)
p2 = sphere((0,0,0),1,color='black',opacity=0.5)
(p+p2).show(aspect_ratio=(1,1,1), figsize=[7,3])

For doing the seashell plots, it looks like parametric_plot3d might be the plotting function you want. Here's an example:

u, v = var('u,v')
f1 = (4+(3+cos(v))*sin(u), 4+(3+cos(v))*cos(u), 4+sin(v))
f2 = (8+(3+cos(v))*cos(u), 3+sin(v), 4+(3+cos(v))*sin(u))
p1 = parametric_plot3d(f1, (u,0,2*pi), (v,0,2*pi), texture="red")
p2 = parametric_plot3d(f2, (u,0,2*pi), (v,0,2*pi), texture="blue")
p1 + p2

And maybe the last pieces of information you need are defining functions and setting parameters (copied from your Natalina example):

def rad(aa):
    return float(aa/360*2*pi)

D=1
alpha=rad(80)
beta=rad(40)
phi=rad(55)
mu=rad(10)
Omega=rad(30)
smM=[rad(-270)..rad(80)]
A=25
a=12
b=16
P=0
L=0

In general, you don't need to import anything to use sage's plotting functions, but you do need to remember to declare the variables with var(). Also, in python and hence also sage, _indentation is part of the syntax_, so for example the function declaration won't work if the return.. line isn't indented, and sage knows the function declaration is over because the following lines are not indented. Maybe you already know this, but if not it can be really confusing (or at least it was for me)!

Finally, here's a link to the sage documentation for 3d graphics; from there you can navigate to either the plot_3d or parametric_plot3d pages. And here's a link to http://sagenb.org, which is a good place to find examples of using the notebook (which is probably where you want to start).

Unfortunately I don't know anything about Maple, so I don't see immediately how to finish the translation, but hopefully this will get you pretty close to finished :)