Translucency lost after applying add_condition method

asked 2019-11-15 06:47:41 -0500

Juanjo gravatar image

updated 2019-11-15 09:38:09 -0500

I need to render translucent implicit surfaces satisfying some additional constraints, such as, for example, the portion of the hyperboloid $x^2+y^2-z^2=1$ which is above the paraboloid $z=(x-1)^2+y^2-1$. The problem I found is that the opacity property is not preserved after applying the add_condition method. To be more concrete, the following code plots a gray, translucent hyperboloid:

var("x,y,z")
texture = dict(color="gray", opacity=0.6)
s = implicit_plot3d(x^2+y^2-z^2==1, (x,-3,3), (y,-3,3), (z,-2.5,2.5), **texture)
opts = dict(viewer="threejs", decimals=1)
s.show(**opts)

Let us apply the constraint:

s1 = s.add_condition(lambda x,y,z: z>(x-1)^2+y^2-1,10)
s1.show(**opts)

One gets a gray, but opaque, surface. Translucency is lost. I have found the following workaround:

from sage.plot.plot3d.index_face_set import IndexFaceSet
s2 = IndexFaceSet(s1.face_list(), **texture)
s2.show(**opts)

which yields the expected result. So I wonder if the loss of translucency is a bug. Anyway, is there a better workaround?

This Sagecell contains the above code.

edit retag flag offensive close merge delete

Comments

1

This is fixed by https://trac.sagemath.org/ticket/28783

Please help by revieweing this ticket.

FrédéricC gravatar imageFrédéricC ( 2019-11-21 07:04:40 -0500 )edit

I have been reading how to review tickets. But unfortunately things like using git or rebuilding code still scares me a lot. So, is there a simple way I could get the modified code to test it? It seems to me that a manual edit of the file src/sage/plot/plot3d/index_face_set.pyx is not the way to go.

Juanjo gravatar imageJuanjo ( 2019-11-21 10:25:40 -0500 )edit