Oscar Lazo wrote:
On 5 ene, 09:45, Jason Grout <jason-s...@creativetrax.com> wrote:
This is fantastic!  Thank you very much.

You are very welcome :D

If you have the time or inclination, maybe you could also generalize
this to a cylindrical coordinate plotting function.  In fact, I wonder
how easy it would be to make a function that took a coordinate
transformation and gave back a plotting function in those coordinates:

I think that would be fairly easy! I will probably do so in short
time.
But i can't figure out a propper name, how about
"transform_plot" - "transform_plot3d"


transform_plot3d sounds great. I like the "3d" on the end, as it indicates to the user that they will be getting back a 3d plot, even if it is redundant. What do you think? It seems nice and consistent to me.

As far as variable names go, there are several ways we usually support calling a plotting function:

The following is what I'd like to think of as the "standard" way:

plot(f, (var1, var1_start, var1_end), (var2, var2_start, var2_end))


The following works if f is a function with ordered inputs (e.g., a python function, or a lambda function, or a function declared with f(x,y)=x^2*y, for example)

plot(f, (var1_start, var1_end), (var2_start, var2_end))

Note that in this case, you do not have explicit variable names, so you'll have to make them up.

Also, in your original code, you could simplify it a bit to be:

var('phi,theta')
def spherical_plot(f,phiran=(phi,0,2*pi),thetaran=(theta,0,pi),**kwds):
   phi=phiran[0]
   theta=thetaran[0]
   Rho=(f*cos(phi)*sin(theta),f*sin(phi)*sin(theta),f*cos(theta))
   return parametric_plot3d(Rho,phiran,thetaran,**kwds)


Another idealogical difference---I usually think of theta as the azimuth variable (i.e., as in polar coordinates) and phi as the elevation variable (measured from the positive z axis). That's how all of the calculus books I've taught from have it. However, I notice that Mathematica and Wikipedia agree that the "standard" convention is for theta to be the elevation (or inclination), and phi to be the azimuth, and the coordinates to be listed as you have them above (i.e., elevation before azimuth). As Wikipedia says:

"The standard convention (r, θ, φ) conflicts with the usual notation for the two-dimensional polar coordinates, where θ is often used for the azimuth. It may also conflict with the notation used for three-dimensional cylindrical coordinates. [1]"

I suppose that conflict is why all the calculus books I've seen define things in a consistent way, instead of apparently the "standard" way.

The reference [1] is to mathworld (http://mathworld.wolfram.com/SphericalCoordinates.html), where there is a nice table detailing different uses in different sources. Mathworld itself uses the "consistent" convention that I and calculus books use.

I don't have a lot of experience with spherical coordinates outside of the classroom. It would be a little confusing for my class to use your function above, though, since it uses a different convention than what we use in class. In that case, it would be great to have a transform_plot3d function, so we could define a spherical plot function with the conventions we are using (and so the class could clearly see that spherical plots are just a special case of a much more general thing).

Anyways, thanks for this work!

Jason

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to