Here is one suggestion for a general solution in SAGE to the problem about generating arbitrary meshes of curves on surfaces in 3D or of curves and/or surfaces in 3D-volume deformations (i.e., (x=fx(u,v,w),y=fy(u,v,w),z=fz(u,v,w)), which includes also 3D-scalar fields (i.e., t=f(x,y,z), t is a scalar, say, real). In this setting, the necessary result is achieved in a simple way using the currently available visualization classes parametric_plot3d and implicit_plot3d:
http://ask.sagemath.org/question/29836/plotting-families-depending-on-integer-parameters-of-curvilinear-coordinate-and-isolevel-lines-and-surfaces-resp-for-functional-and-parametric/ Comments, remarks, improvements and optimizations are very welcome! Regards, shao-linux :) On Tuesday, November 3, 2009 at 2:56:58 PM UTC+1, Jonathan wrote: > > Thanks, I'll try to get a look at it. This appears to be what I > needed to find. No promises, as I'm pretty swamped, but now I have > somewhere to start. > > Jonathan > > > On Nov 3, 1:02 am, Jason Grout <jason-s...@creativetrax.com> wrote: > > Jonathan wrote: > > > Jason, > > > I think this is a great idea. As I use Sage a bit in my teaching, > > > it would be nice to have a primitive with separate items for axes, > > > axes' labels, axes scale (the numbers on the axes). Then buttons > > > could be added to turn these on and off at the user request. If some > > > things can be passed to Jmol as functions, they will render well at > > > any zoom level. It would also be easier to use the slab function for > > > slicing 3-D objects. > > > That said there are some serious problems with how the notebook/ > > > plot3D uses Jmol presently, that have little to do with whether a > > > primitive exists or not. I'm willing to help fix them, but need to > > > understand where in the code the html and javascript for Jmol is > > > generated. The way it is presently done the following things are a > > > problem: > > > > > 1) It does not work in Firefox on Macs. Since I never have trouble > > > with this, I'm assuming something abnormal is being done with the > > > javascript that controls Jmol. Again, I bet I can help with this, but > > > I could not easily find where the code was generated. All I can do is > > > look at a web page. > > > 2) Since people are running into memory problems, I suggest that only > > > a limited number of live Jmols (present default JavaVM configurations > > > support about 8 - 10 per page) be allowed in any given notebook. I > > > provided some example code that does not require any server > > > intervention that does this. I could help fold this in, if I could > > > figure out how you are generating the javascript to control Jmol. > > > 3) Since there is room next to Jmol in the notebook, I suggest that > > > simple instructions on what Jmol can do and how to access the pop-up > > > be added and maybe a link to more extensive documentation (the Jmol > > > Site?). I'm an expert with Jmol and found it difficult to do anything > > > but rotate the image without significant experimentation. > > > 4) It also might be worth loading only a static image first with a > > > link to make live. This saves a lot of bandwidth and will decrease > > > the time users have to wait to see their plots. > > > 5) It would probably be a good idea to upgrade Jmol to the latest > > > stable release 11.8. I will try slipping that into a copy of 4.2 I > > > just downloaded. > > > > > These are just some thoughts. The key thing is I think I could help, > > > but do not have time to wade through the code to figure out how > > > everything is connected. Can someone just tell me were to look? > > > > Here's what I found by poking around for a bit. Everything has changed > > since the new notebook, so someone that knows, *please* correct me if > > I'm wrong. > > > > In Sage 4.2, it looks like the jmol-invoking javascript code is in: > > > > local/lib/python2.6/site-packages/sagenb/data/sage/js/jmol_lib.js > > > > That appears to be the code that actually sets up a jmol applet and > > makes the "Get Image" link. > > > > That file is loaded in > > local/lib/python2.6/site-packages/sagenb/data/sage/js/notebook_lib.js > > > > Jmol is initialized at the bottom of the template file: > > > > > local/lib/python2.6/site-packages/sagenb/data/sage/html/notebook/head.tmpl > > > > The actual jmol application is in: > > > > local/lib/python2.6/site-packages/sagenb/data/jmol > > > > The jmol code gets invoked when a ".jmol" file is created by a 3d plot. > > The notebook then comes by, sees the .jmol file, and creates the jmol > > applet. The code that does this is in > > local/lib/python2.6/site-packages/sagenb/notebook/cell.py (search for > > jmol). > > > > The code in Sage that generates the .jmol files is (I believe) in > > devel/sage/sage/plot/plot3d/base.pyx (see the show method, starting with > > the following code. EMBEDDED_MODE is True when you are inside the > > notebook, and False if you are not executing inside the notebook.) > > > > if DOCTEST_MODE or viewer=='jmol': > > # Temporary hack: encode the desired applet size in the end > > of the filename: > > # (This will be removed once we have dynamic resizing of > > applets in the browser.) > > base, ext = os.path.splitext(filename) > > fg = figsize[0] > > #if fg >= 2: > > # fg = 2 > > filename = '%s-size%s%s'%(base, fg*100, ext) > > ext = "jmol" > > archive_name = "%s.%s.zip" % (filename, ext) > > if EMBEDDED_MODE: > > # jmol doesn't seem to correctly parse the ?params part > > of a URL > > archive_name = "%s-%s.%s.zip" % (filename, randint(0, 1 > > << 30), ext) > > > > T = self._prepare_for_jmol(frame, axes, frame_aspect_ratio, > > aspect_ratio, zoom) > > T.export_jmol(archive_name, force_reload=EMBEDDED_MODE, > > zoom=zoom*100, **kwds) > > viewer_app = "sage-native-execute " + > > os.path.join(sage.misc.misc.SAGE_LOCAL, "bin/jmol") > > > > # We need a script to load the file > > f = open(filename + '.jmol', 'w') > > f.write('set defaultdirectory "%s"\n' % archive_name) > > f.write('script SCRIPT\n') > > f.close() > > > > I hope this helps. > > > > Thanks, > > > > Jason > > > > -- > > Jason Grout -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.