chemist rock -- amazing 3d java graphics

4 views
Skip to first unread message

William Stein

unread,
Dec 14, 2007, 5:28:58 AM12/14/07
to sage-...@googlegroups.com
Hello,

Tachyon3d is a raytracing program that has served Sage very very well
for easy-to-produce
standalone fast simple 3d raytracing. It was written by a chemist for
visualizing molecules, etc.

I found a page (http://www.openscience.org/blog/) that recommends Sage,
and when scrolling down it noticed that it had a very
solid no-install-needed lightweight but extremely high quality and
tasty molecule of
caffeine embedded in it. Following the link I found

http://jmol.sourceforge.net/

which is a totally frickin' awesome 3d Java chemistry visualization toolkit.

If you've been following the large amount of brainstorming about 3d graphics and
Sage over the last few weeks, definitely check out that above link,
and links like this:

http://jmol.sourceforge.net/#What%20the%20critics%20are%20saying

Definitely try this out:

http://jmol.sourceforge.net/demo/

it is very very impressive.

Yes, it appears to be aimed at chemistry, but if you look at the
examples, and at the API
documentation, you'll see that it's somewhat similar to tachyon, and
has things like:
---------------
pmesh meshID [option] "filename.pmesh"

With the pmesh command you can add one or more surfaces to a model.
The pmesh command is
similar to the isosurface command in terms of options. The pmesh
command takes the overall format...
---------------

So, just as with Tachyon, it's conceivable that jmol could be just the
right tool for the job, finally.
We shall see.

By the way, a large amount of the work that Robert Bradshaw put into
3d graphics and Java3d
last summer was really in writing fast Cython code for generating 3d
models from scene
descriptions (building on work of Tom Boothby and Josh Kantor). That
same work would carry
over to jmol.

-- William


--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

Robert Bradshaw

unread,
Dec 14, 2007, 6:14:38 AM12/14/07
to sage-...@googlegroups.com
I am extremely impressed! It seems to be specifically optimized for
rendering molecules, but I'm going to write an exporter for our 3d
shapes as meshes and see how well it does.

- Robert

William Stein

unread,
Dec 14, 2007, 6:30:33 AM12/14/07
to sage-...@googlegroups.com
On Dec 14, 2007 3:14 AM, Robert Bradshaw <robe...@math.washington.edu> wrote:
>
> I am extremely impressed! It seems to be specifically optimized for
> rendering molecules, but I'm going to write an exporter for our 3d
> shapes as meshes and see how well it does.

There is an amazing amount of mathematics, especially combinatorial
structures, etc., for which those sorts of things might be quite
good for us.

By the way, I just got it to work in Sage via the following nutty sequence
of hacks (see attached screen shot):

(1) download the jmol binary

(2) start sage and a worksheet that for me happens to have files here:

/Users/was/.sage/sage_notebook/worksheets/admin/20

(3) Put a symlink from the jmol binary directory to

/Users/was/.sage/sage_notebook/worksheets/admin/20/data/jmol

(4) Put some sample data files in

/Users/was/.sage/sage_notebook/worksheets/admin/20/data/

(5) Put the javascript file in there:

/Users/was/.sage/sage_notebook/worksheets/admin/20/data/Jmol.js

(6) Put this html in a worksheet (via edit):

<script src="data/Jmol.js"></script>
<script>
jmolInitialize("data/jmol");
jmolCheckBrowser("popup", "../../browsercheck", "onClick");
</script>
<center>
<script>
jmolApplet(500, "load data/plot2.xyz");
</script>
</center>

(7) Switch back to Use mode and write data out to plot2.xyz, see the
screen shot or use this script or write your own:

z = ['H %s %s %s'%(i,j,cos(i)*sin(j)*4) for i,j in
cartesian_product_iterator([[1,1.5,..10], [1,1.5,..10]])]
s = """%s
Random
"""%(len(z))
s += '\n'.join(z)
open('../../data/plot2.xyz','w').write(s)

(8) Press refresh on the browser.

Anyway, you might want to try something crazy hackish like
above first, since it doesn't take long, before trying to do things
right.

Picture 2.png

Ondrej Certik

unread,
Dec 14, 2007, 6:49:01 AM12/14/07
to sage-...@googlegroups.com
On Dec 14, 2007 12:30 PM, William Stein <wst...@gmail.com> wrote:
> On Dec 14, 2007 3:14 AM, Robert Bradshaw <robe...@math.washington.edu> wrote:
> >
> > I am extremely impressed! It seems to be specifically optimized for
> > rendering molecules, but I'm going to write an exporter for our 3d
> > shapes as meshes and see how well it does.
>
> There is an amazing amount of mathematics, especially combinatorial
> structures, etc., for which those sorts of things might be quite
> good for us.

Yes, jmol is good, I wrote some parsing of cif crystal formats in
jython into it (3 years ago) and the source code is quite
understandable. But I hate java, that's why I used jython, but jython
was quite slow to load at that time.

Something like jmol is the way to go imho.

Ondrej

Robert Bradshaw

unread,
Dec 14, 2007, 7:27:34 AM12/14/07
to sage-...@googlegroups.com

On Dec 14, 2007, at 3:30 AM, William Stein wrote:

> On Dec 14, 2007 3:14 AM, Robert Bradshaw
> <robe...@math.washington.edu> wrote:
>>
>> I am extremely impressed! It seems to be specifically optimized for
>> rendering molecules, but I'm going to write an exporter for our 3d
>> shapes as meshes and see how well it does.
>
> There is an amazing amount of mathematics, especially combinatorial
> structures, etc., for which those sorts of things might be quite
> good for us.

Yes, for sure. The fact that it natively handles spheres (and
cylinders) is a big plus.

> By the way, I just got it to work in Sage via the following nutty
> sequence
> of hacks (see attached screen shot):

It was pretty easy to add pmesh output to IndexFaceSet (which
underlies all triangulated shapes). I haven't gotten much further
than that, but one drawback is that it seems we might need a bunch of
separate files to represent a single object. (Of course, it is open
source, so we could define our own conglomerate format. Also, perhaps
we could pass them around as a single zipped file (both python and
java have pretty good support, and it would compress the highly-
redundant format as well).

It starts to get sluggish at 20 tori (<1K polygons each), wheras the
OpenGL stuff doesn't break a sweat until the much, much higher. I
don't see any options for controlling lighting, and the camera seems
much more limited too.

Being pure java is a huge plus though, as is it being maintained,
used, and developed by a larger audience. And it's pretty Got to hand
it to those chemists!

- Robert

mhampton

unread,
Dec 14, 2007, 7:54:04 AM12/14/07
to sage-devel
This seems like some nice documentation on the primitives:

http://chemapps.stolaf.edu/jmol/docs/

It does look nice, I thought the vibration demo:

http://jmol.sourceforge.net/demo/vibration/

was particularly impressive.

On Dec 14, 6:27 am, Robert Bradshaw <rober...@math.washington.edu>
wrote:
> On Dec 14, 2007, at 3:30 AM, William Stein wrote:
>
> > On Dec 14, 2007 3:14 AM, Robert Bradshaw

boo...@u.washington.edu

unread,
Dec 14, 2007, 12:43:44 PM12/14/07
to sage-devel
>
> This seems like some nice documentation on the primitives:
>
> http://chemapps.stolaf.edu/jmol/docs/
>
> It does look nice, I thought the vibration demo:
>
> http://jmol.sourceforge.net/demo/vibration/
>
> was particularly impressive.

Wow. This is *really* neat. It's even got an option so you can look at the model through 3d glasses! (search for stereo in the docs)

William Stein

unread,
Dec 14, 2007, 1:02:21 PM12/14/07
to sage-...@googlegroups.com

This could kick butt for the AMS meeting if we can get it to display
mathematical images.

- William

Robert Bradshaw

unread,
Dec 14, 2007, 2:16:19 PM12/14/07
to sage-...@googlegroups.com

That is certainly my plan.

- Robert

Robert Bradshaw

unread,
Dec 14, 2007, 7:10:16 PM12/14/07
to sage-...@googlegroups.com

Capeman in jmol

capeman.png
capeman-stereo.png

Robert Bradshaw

unread,
Dec 14, 2007, 7:31:21 PM12/14/07
to sage-...@googlegroups.com
As a mesh, rather than jmol spheres

capeman-mesh.png

William Stein

unread,
Dec 14, 2007, 7:33:15 PM12/14/07
to sage-...@googlegroups.com
On Dec 14, 2007 4:31 PM, Robert Bradshaw <robe...@math.washington.edu> wrote:
> As a mesh, rather than jmol spheres


Damn it, I can't wait to try this out!!

:-)

> > <capeman.png>
> >
> > and in stereo (we really should order some red/blue glasses for
> > demos).
> >
> >
> > <capeman-stereo.png>

Robert Bradshaw

unread,
Dec 14, 2007, 7:38:31 PM12/14/07
to sage-...@googlegroups.com

Robert Bradshaw

unread,
Dec 16, 2007, 9:43:17 AM12/16/07
to sage-...@googlegroups.com
Now integrated into Sage, from the command line http://sagetrac.org/
sage_trac/ticket/1516 and the notebook http://sagetrac.org/sage_trac/
ticket/1536
.

- Robert

Robert Bradshaw

unread,
Dec 19, 2007, 1:20:54 AM12/19/07
to sage-...@googlegroups.com
On Dec 14, 2007, at 11:16 AM, Robert Bradshaw wrote:

Have you ordered any 3d glasses yet? If not, I'd be happy to do so
(I'm assuming I could get reimbursed, but they're not very expensive,
like $20 for a pack of 40.)

- Robert

William Stein

unread,
Dec 19, 2007, 1:28:24 AM12/19/07
to sage-...@googlegroups.com

I have ordered any yet. Robert -- definitely go ahead and order them.
This will *rock* for the AMS meeting.

William

Reply all
Reply to author
Forward
0 new messages