Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168769
Image: ubuntu2004
I've come up with this: a spherical_plot, that is, a 3d analogue of the very useful command "polar_plot".

It takes a function that depends of two angular parameters, and plots it in a given sperical domain

For simplicity's sake I have not added default values, that tends to produce undesired results.
reset() var('x,y,z')
(x, y, z)
def spherical_plot(f,phiran,thetaran,**kwds): phi=phiran[0] theta=thetaran[0] R=(f*cos(phi)*sin(theta),f*sin(phi)*sin(theta),f*cos(theta)) return parametric_plot3d(R,phiran,thetaran,**kwds)
spherical_plot(2*y^1/2,(x,0,2*pi),(y,0,pi))
But other functions might have surprising shapes. Let's mimic the functions shown at

http://reference.wolfram.com/mathematica/ref/SphericalPlot3D.html
spherical_plot(1+2*cos(2*y),(x,0,2*pi),(y,0,pi)).show(aspect_ratio=(1,1,1))
a=sum([spherical_plot(i,(x,0,3*pi/2),(y,0,pi)) for i in range(1,4)]) a.show()
spherical_plot(1+sin(5*x)/5,(x,0,2*pi),(y,0,pi),rgbcolor=(1,0.5,0),plot_points=(80,80),opacity=0.7)
And some others...
spherical_plot((2+cos(2*x))*(y+1),(x,0,2*pi),(y,0,pi),rgbcolor=(1,.1,.1))
spherical_plot(e^-y,(x,0,2*pi),(y,0,pi),opacity=0.5).show(frame=False)