Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Translucency lost after applying add_condition method

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$. The problem I found is that the opacity 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.

Translucency lost after applying add_condition method

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$. The problem I found is that the opacity 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. code.

Translucency lost after applying add_condition method

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$. $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.