Opened 2 years ago

Last modified 2 years ago

#20978 new defect

polygon3d view broken

Reported by: kcrisman Owned by:
Priority: critical Milestone: sage-7.3
Component: graphics Keywords:
Cc: paulmasson, novoselt, mkoeppe Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by paulmasson)

polygon3d([[0,0,0], [1,2,3], [3,0,0]]) 

does not show anything. See this ask.sagemath question.

EDIT: Issue previously reported as #19274. Description from that ticket:

Thomas Fernique reported the following bug by private email: from the console, some flat polygons in three-space lead to an empty picture with jmol (java version), for example:

sage: polygon([(0, 0, 0), (1, 0, 0), (1, 0, 1), (0, 0, 1)])

However, this is correctly displayed with jsmol (javascript version) from the notebook.

I can reproduce this bug on Sage 6.8, Debian GNU/Linux jessie 64 bit, openjdk-7-jre.

Change History (11)

comment:1 Changed 2 years ago by paulmasson

  • Cc paulmasson added

comment:2 Changed 2 years ago by tscrim

When I add an arrow3d (for example), then it displays properly:

sage: polygon3d([[0,0,1],[0,1,0],[1,0,0]]) + arrow3d([0,0,0],[1,1,1])
sage: p2.plot() + arrow3d([0,0,0],[1,1,1])

It seems like it is just ignoring the polygon3d when it is the only object:

sage: p = polygon3d([[0,0,1],[0,1,0],[1,0,0]]) + arrow3d([0,0,0],[1,1,1])
sage: rp = p.default_render_params()
sage: rp.output_archive = None
sage: p.jmol_repr(rp)
['pmesh obj_1 "/home/travis/.sage/temp/apricot/5573/tmp_pU6Ppq-obj_1.pmesh"\ncolor pmesh  [0,0,255]']
<type 'sage.plot.plot3d.index_face_set.IndexFaceSet'>

sage: p = polygon3d([[0,0,1],[0,1,0],[1,0,0]]) + arrow3d([0,0,0],[1,1,1])
sage: p.jmol_repr(rp)
[['pmesh obj_2 "/home/travis/.sage/temp/apricot/5573/tmp_pU6Ppq-obj_2.pmesh"\ncolor pmesh  [0,0,255]'],
 [[['\ndraw line_3 width 0.02 {0.0 0.0 0.0} {0.896076951546 0.896076951546 0.896076951546}\ncolor $line_3  [102,102,255]\n'],
   [['pmesh obj_4 "/home/travis/.sage/temp/apricot/5573/tmp_pU6Ppq-obj_4.pmesh"\ncolor pmesh  [102,102,255]']]]]]
sage: type(p)
<class 'sage.plot.plot3d.base.Graphics3dGroup'>

sage: p = arrow3d([0,0,0],[1,1,1])
sage: p.plot()    # This works fine
Launched jmol viewer for Graphics3d Object
sage: p.jmol_repr(rp)
[[['\ndraw line_5 width 0.02 {0.0 0.0 0.0} {0.896076951546 0.896076951546 0.896076951546}\ncolor $line_5  [102,102,255]\n'],
  [['pmesh obj_6 "/home/travis/.sage/temp/apricot/5573/tmp_pU6Ppq-obj_6.pmesh"\ncolor pmesh  [102,102,255]']]]]
sage: type(p)
<class 'sage.plot.plot3d.base.TransformGroup'>

A somewhat strange thing is that the graphics group jmol_repr calls the jmol_repr of the polygon. Perhaps someone has an idea about this (and knows how to read the jmol input).

Last edited 2 years ago by tscrim (previous) (diff)

comment:3 follow-up: Changed 2 years ago by egourgoulhon

Works for me with sage 7.3.beta6 on Ubuntu 15.10 for both sage notebook and jupyter notebook (a blue triangle is displayed in the jmol output). Does *not* work from the sage console (only the bounding box is displayed).

comment:4 in reply to: ↑ 3 Changed 2 years ago by egourgoulhon

Replying to egourgoulhon:

Works for me with sage 7.3.beta6 on Ubuntu 15.10 for both sage notebook and jupyter notebook (a blue triangle is displayed in the jmol output). Does *not* work from the sage console (only the bounding box is displayed).

Addendum: in the sage notebook, the triangle is displayed only after one has clicked on the figure.

comment:5 Changed 2 years ago by paulmasson

I don't think this is a Sage problem. If you look at the temporary files under the hidden User/.sage directory that are passed to the Jmol viewer, the pmesh files for the polygons are there and included every time in the SCRIPT file in scene.spt.zip. The data for the polygons is exactly the same whether or not the arrow is included.

As a test, run this at the command line:

p=polygon([(0,0,0),(1,0,0),(1,1,0)])
for n in range(1,10):
     p+=polygon([(n,0,0),(n+1,0,0),(n+1,n+1,0)])
     p

When I run it the polygons don't being to appear until there are six of them, and don't appear reliably for higher numbers.

I think this is a Jmol display problem.

comment:6 Changed 2 years ago by tscrim

Hmmm...perhaps it is time to revive the discussion of moving to a different 3d viewing platform? At least we should probably tell upstream.

comment:7 Changed 2 years ago by paulmasson

  • Description modified (diff)

comment:8 Changed 2 years ago by mkoeppe

  • Cc novoselt mkoeppe added

comment:9 Changed 2 years ago by paulmasson

On #12402 I've written some basic Three.js support for Graphics3d objects that can handle examples here that fail in Jmol. If there is interest in having an option other than Jmol, feedback on #12402 would be appreciated.

comment:10 follow-up: Changed 2 years ago by mkoeppe

Is this usable with sage running in a terminal? Note that the failure documented in this ticket is about the Java version of Jmol, which is the one that is used in this situation.

comment:11 in reply to: ↑ 10 Changed 2 years ago by paulmasson

Replying to mkoeppe:

Is this usable with sage running in a terminal?

Yup! That's the entire point: an HTML file is generated at the command line and saved in a temporary file like other plots. It can then be displayed immediately in a browser, or embedded in an iframe for future application in notebooks or the cell server.

Note: See TracTickets for help on using tickets.