Ticket #7850 (closed enhancement: invalid)
spherical plot
| Reported by: | olazo | Owned by: | olazo |
|---|---|---|---|
| Priority: | minor | Milestone: | sage-duplicate/invalid/wontfix |
| Component: | graphics | Keywords: | spherical,plot |
| Cc: | Work issues: | ||
| Report Upstream: | N/A | Reviewers: | |
| Authors: | olazo | Merged in: | |
| Dependencies: | Stopgaps: |
Attachments
Change History
comment:2 Changed 3 years ago by jason
Here's the relevant sage-devel thread: http://groups.google.com/group/sage-devel/browse_thread/thread/8e38cdd8048eb39c
Thanks again for working on this!
Here are some comments about the implementation up at http://www.sagenb.org/home/pub/1323/, just based on reading the code.
- To be consistent with the plotting functions, it would also need to support something like:
spherical_plot3d(lambda x,y: x+y, (0,2*pi), (0,pi))
That's the purpose behind the convoluted second half of the make_coordinate_plot3d function (because symbolic functions can't be multiplied by lambda functions).
- It's better to use "zran is None" rather than "zran==None". It's a much faster test.
- There is still some dependence on variable names if the variable name is not specified. This should give an error, or at least a deprecation warning, as it is no longer a supported syntax for plotting:
spherical_plot3d(phi*theta, (0,2*pi),(0,pi))
(note that the expression has two variables, but I haven't said which variable corresponds to which range. This is particularly confusing with spherical plots, since there are two opposite conventions.
- except statements should catch specific exceptions (e.g., "except ValueError?"), instead of just triggering on any error.
- I'm not sure there's any difference between the transform_plot3d and just plainly calling parametric_plot3d. transform_plot3d seems to just basically be a rename of parametric_plot3d.
comment:3 Changed 3 years ago by olazo
- Status changed from new to needs_review
- Description modified (diff)
comment:5 Changed 3 years ago by olazo
- Status changed from needs_review to needs_work
- Description modified (diff)


Here is a rough cut of a generic function: http://sagenb.org/home/pub/1322/
# TODO: figure out a way to determine if f is an expression or callable symbolic function for the if statement. def make_coordinate_plot3d(transformation, function_variable,parameter_variables): def new_plot(f, var1_range, var2_range,**kwds): f_is_expression=True if f_is_expression: # if f is an expression, then we can use .subs. This is faster, because parametric_plot3d # can then use fast_float if len(var1_range)==3: vars=[var1_range[0], var2_range[0]] else: vars=sage.symbolic.ring.var('v1,v2') plot_func=[t.subs({function_variable:f, parameter_variables[0]:vars[0], parameter_variables[1]:vars[1]}) for t in transformation] else: # if f is not a symbolic expression or function, use the following # We could make this faster by using fast_float on the components of transformation # We need to do the function and map instead of just a list comprehension because # of python scoping; see http://lackingrhoticity.blogspot.com/2009/04/python-variable-binding-semantics-part.html def subs_func(t): return lambda x,y: t.subs({function_variable:f(x,y), parameter_variables[0]:x, parameter_variables[1]:y}) plot_func=map(subs_func,transformation) return parametric_plot3d(plot_func, var1_range, var2_range,**kwds) return new_plot var('r,t,p') jason_spherical_plot3d=make_coordinate_plot3d([r*cos(t)*sin(p), r*sin(t)*sin(p), r*cos(p)], function_variable=r, parameter_variables=[t,p])