Ask Your Question
3

Transferring 3D plots

asked 2015-03-08 18:56:45 +0100

nerak99 gravatar image

I want to export 3D plots from Sage in some 3D format or other (NOt just a single png frame)

This script produces a jMol file for me. (I am on cloud.sagemath)

> from sage.interfaces.jmoldata import JmolData 3 sage: JData = JmolData() 4
> u,v = var('u v') 5 f_x = u 6 f_y =
> cos(1*v) 7 f_z = sin(3*v) 8
> img=parametric_plot3d([f_x, f_y, f_z],
> (u, 0, 0.6), (v, 0, 6*pi),
> color='blue', mesh=1, frame=False) 9
> img.save('myfile.png') 10
> img.export_jmol('thisjmol') 11 img 12

The file produced is about 20K or so but if I try to open it via JMol standalone viewer I just get black.

Mind you if I try the example jmols I also get black.

My end point is to get the 3D view into a 3D package such as Blender but to start with I need to get my 3D image out of sage.

Any idea of where I am going wrong?

edit retag flag offensive close merge delete

Comments

1

There is a ticket waiting to help export 3D plots : http://trac.sagemath.org/ticket/7744 but it has been waiting since a long time.

FrédéricC gravatar imageFrédéricC ( 2015-03-08 20:12:58 +0100 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2015-03-08 23:16:23 +0100

tmonteil gravatar image

updated 2015-03-09 15:11:58 +0100

There used to be a way to save the 3D scene with the spt.zip extension but is seems currently broken:

sage: img.save('/path/to/file.spt.zip')
AttributeError: 'OutputSceneJmol' object has no attribute 'jmol'

What you can do, if you do not have many plots, is to view them with jmol and then export them.

EDIT

  • From the Sage command-line, it is on the top of the window, you can export in .spt format from the jmol applet : FILE > Export > Write State

  • From the Sage notebook, click on the circular arrow (bottom left of the image) to let jmol start, then right click on the image, you will get a menu: with File > Save you can export as a JVXL isosurface, from File > Export, you can export as VRML and X3D 3D models.

edit flag offensive delete link more

Comments

How do I access the context menu in the jmol applet?

nerak99 gravatar imagenerak99 ( 2015-03-09 13:38:31 +0100 )edit

I updated my answer since the answer depends on how jmol was opened.

tmonteil gravatar imagetmonteil ( 2015-03-09 15:12:30 +0100 )edit

I can't see the sage command line that you speak of. I am using cloud.sagemath though. I have managed to get jmol import of three.js objects to work. I think that in the screen rendering, three.js is involved.

nerak99 gravatar imagenerak99 ( 2015-03-10 13:09:16 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-03-08 18:56:45 +0100

Seen: 1,296 times

Last updated: Mar 09 '15