Finding the exact camera position in Jmol

89 views
Skip to first unread message

Sébastien Labbé

unread,
Sep 8, 2011, 9:02:21 PM9/8/11
to sage-devel
Hi,

I have been asked this question since more than a year by some people
in Montpellier and also needed it myself to draw in tikz a 3d object
with a projection I would choose using Jmol. I have now understood how
to do it and wrote a post about it here :

http://www.thales.math.uqam.ca/~labbes/blogue/2011/09/find-the-coordinates-of-the-camera-in-jmol/

There might be an easier solution, but that the one I found.

Sébastien, Montréal

Nils Bruin

unread,
Sep 8, 2011, 10:37:17 PM9/8/11
to sage-devel
On Sep 8, 6:02 pm, Sébastien Labbé <sla...@gmail.com> wrote:
> Hi,
>
> I have been asked this question since more than a year by some people
> in Montpellier and also needed it myself to draw in tikz a 3d object
> with a projection I would choose using Jmol. I have now understood how
> to do it and wrote a post about it here :
>
> http://www.thales.math.uqam.ca/~labbes/blogue/2011/09/find-the-coordi...
>
> There might be an easier solution, but that the one I found.
>
> Sébastien, Montréal

That is excellent! Would it be possible to have a setup similar to the
graph editor, where one can pass a 3d scene to jMol, choose a nice
camera position and obtain a 3d scene as a result from it, with the
camera position recorded? One could then pass it to whatever renderer
one likes to get it in whatever format is required.

Or perhaps have a "jmol object" live in the server, listening on some
channel to jmol's camera position reporting (via a thread, possibly).
Another method on this "jmol object" could then produce a 3d-scene
with the currently recorded camera position.

Jonathan

unread,
Sep 9, 2011, 9:52:01 AM9/9/11
to sage-devel
In theory this could be added to the javascript functions being
included with the update to the Jmol interface which is coming with
the switch to the new flask notebook, but I'm not sure this is the
best solution.

The new interface will include the ability to download a .jmol file
to your computer. You can than open it in the Jmol application which
is more capable than the applet. One thing you can easily do from the
application is produce input for POV-Ray which is the best way of
generating nice static 3-D images. I might add that the Jmol .jpg
and .png images should be very good if you don't choose too much
compression in the application. This is harder to control from the
applet.

Jonathan
(a Jmol developer)

Nils Bruin

unread,
Sep 9, 2011, 1:04:05 PM9/9/11
to sage-devel
On Sep 9, 6:52 am, Jonathan <gu...@uwosh.edu> wrote:
> In theory this could be added to the javascript functions being
> included with the update to the Jmol interface which is coming with
> the switch to the new flask notebook, but I'm not sure this is the
> best solution.
>
> The new interface will include the ability to download a .jmol file
> to  your computer.

Yes, I agree that in practice that may well be a very good solution
for people who frequently do this and are familiar with the jmol
toolchain.

In principle, sage already offers capability like this because it
should be able to export a 3d scene as an "x3d" file (the last time I
looked there were some things broken about it), which can be loaded in
all kinds of software, including Blender. Quite possibly, Jmol has a
unique place in sage because it displays 3d scenes interactively and
does so (seemingly?) integrated in the notebook. Regardless of what
backend one want to use in Sage to produce the final rendering,
selecting a camera position is often done best interactively. So, if
jmol can do that and hand the camera position back to sage, that would
be great. It would allow seamless integration with the tachyon
raytracer

This is the kind of functionality I think one *expects* to be present.
It may be that it wouldn't actually get used and that people are quite
happy just cutting and pasting screen shots.

One application would be to give a simplified scene to jmol as a
preview, get the camera position, and then use tachyon to render the
final picture (possibly with millions of spheres or something else
beyond the scope of jmol).

Jonathan

unread,
Sep 10, 2011, 2:11:36 PM9/10/11
to sage-devel
If you are doing everything through Sage, would having Jmol print the
rotation information to the web page be enough? Then the user could
do a cut and paste to use with the renderer they want. Completely
automating things would require more fiddling.

Jonathan

Nils Bruin

unread,
Sep 10, 2011, 8:31:10 PM9/10/11
to sage-devel
On Sep 10, 11:11 am, Jonathan <gu...@uwosh.edu> wrote:
> If you are doing everything through Sage, would having Jmol print the
> rotation information to the web page be enough?

Possibly. That would result in essentially the same work-flow as
Sébastien's solution, but with less effort. If I were new to Sage I
would *expect* there to be a fully automatic method, where I can do
something along the lines of

scene1 = plot3d( ... )
scene2 = interactively_choose_camera_position(scene1)
scene2.show(renderer="myfavoriteone")

or

scene1 = plot3d(...)
jmol_view_object = view_with_jmol(scene1)
//prompt returns; some interaction with jmol window
scene2 = jmol_view_object.snapshot()
scene2.show(renderer="myfavoriteone")

where view_with_jmol and/or interactively_choose_camera_position would
probably be methods rather than functions. If the jmol app would
listen on stdin for "give camera postion" and then would output it on
stdout, then from the command line, the second approach would already
be implementable.

However, me expecting that is not the same as a lot of people using
that workflow frequently! So at this point I wouldn't be pushing
anyone to actually implement it.

It's good to know that technically people have an idea for how to
accomplish it and I suppose in general it would be instructive to have
the infrastructure in place to do this via command line and/or the
notebook.

Niles

unread,
Sep 12, 2011, 7:58:09 AM9/12/11
to sage-devel
Just printing the camera position would be a huge help! I have been
trying to figure out the same thing for a while now.

-Niles

p.s. Thanks Sébastian!!!

Sébastien Labbé

unread,
Sep 20, 2011, 11:38:23 AM9/20/11
to sage-devel
Hi Jonathan,

> In theory this could be added to the javascript functions being
> included with the update to the Jmol interface which is coming with
> the switch to the new flask notebook, but I'm not sure this is the
> best solution.

Apparently, people are also interested by the converse [1]. Hence,
would it be possible with the update to the Jmol interface to choose
the camera position from Sage? Something like :

sage: C = cube()
sage: C.show3d(camera=(10,2,5))

Sébastien

[1] http://groups.google.com/group/sage-support/browse_thread/thread/a541ea639b49395d
Reply all
Reply to author
Forward
0 new messages