ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 03 Aug 2020 07:35:39 +0200Thicker plot in implicit_plot3dhttps://ask.sagemath.org/question/52775/thicker-plot-in-implicit_plot3d/I'm graphing a surface in implicit_plot3d and then cutting away part of it to reveal another surface that was hidden behind it. Is there a way to "thicken" the plotted surface, so that the edge is still visible in places where we are looking at it straight-on?
For a simple example, how can I graph the part of $x^2+y^2+z^2 = 1$ with $z \leq 1/2$, while making the sphere a bit thicker than the default?Fri, 31 Jul 2020 17:40:17 +0200https://ask.sagemath.org/question/52775/thicker-plot-in-implicit_plot3d/Comment by slelievre for <p>I'm graphing a surface in implicit_plot3d and then cutting away part of it to reveal another surface that was hidden behind it. Is there a way to "thicken" the plotted surface, so that the edge is still visible in places where we are looking at it straight-on?</p>
<p>For a simple example, how can I graph the part of $x^2+y^2+z^2 = 1$ with $z \leq 1/2$, while making the sphere a bit thicker than the default?</p>
https://ask.sagemath.org/question/52775/thicker-plot-in-implicit_plot3d/?comment=52781#post-id-52781Please post any current attempt. It will be easier to answer starting from that.Fri, 31 Jul 2020 22:29:52 +0200https://ask.sagemath.org/question/52775/thicker-plot-in-implicit_plot3d/?comment=52781#post-id-52781Answer by slelievre for <p>I'm graphing a surface in implicit_plot3d and then cutting away part of it to reveal another surface that was hidden behind it. Is there a way to "thicken" the plotted surface, so that the edge is still visible in places where we are looking at it straight-on?</p>
<p>For a simple example, how can I graph the part of $x^2+y^2+z^2 = 1$ with $z \leq 1/2$, while making the sphere a bit thicker than the default?</p>
https://ask.sagemath.org/question/52775/thicker-plot-in-implicit_plot3d/?answer=52820#post-id-52820So far Sage has no built-in way to thicken a surface.
For a simple surface as in the question, one could plot
- the surface and its boundary curve,
or one could plot
- a surface slightly inside,
- a surface slightly outside,
- an edge surface,
and combine the three plots to produce the desired result.
Both approaches are illustrated below.
Define useful constants:
sage: one = RDF.one()
sage: eps = one/64
sage: b = one + 2*eps
sage: h = one/2
sage: rh = RDF(3).sqrt()/2
sage: tau = 2*RDF.pi()
Plot the surface and the boundary curve:
sage: ro = one
sage: fo = lambda x, y, z: x*x + y*y + z*z - ro*ro
sage: xo = lambda t: rh*cos(tau*t)
sage: yo = lambda t: rh*sin(tau*t)
sage: zo = lambda t: h
sage: sopt = {'color': 'gold', 'plot_points': 77}
sopt: copt = {'color': 'crimson'}
sage: so = implicit_plot3d(fo, (-b, b), (-b, b), (-b, h), **sopt)
sage: co = parametric_plot([xo, yo, zo], (0, 1), **copt)
sage: go = so + co
sage: go.show(frame=False)
Launched html viewer for Graphics3d Object
Plot inner, outer and edge surfaces:
sage: rm = ro - eps
sage: rp = ro + eps
sage: fm = lambda x, y, z: x*x + y*y + z*z - rm*rm
sage: fp = lambda x, y, z: x*x + y*y + z*z - rp*rp
sage: rhm = (rm*rm - h*h).sqrt()
sage: rhp = (rp*rp - h*h).sqrt()
sage: xe = lambda u, v: ((1 - u)*rhm + u * rhp)*cos(tau*v)
sage: ye = lambda u, v: ((1 - u)*rhm + u * rhp)*sin(tau*v)
sage: ze = lambda u, v: h
sage: sm = implicit_plot3d(fm, (-b, b), (-b, b), (-b, h), **sopt)
sage: sp = implicit_plot3d(fp, (-b, b), (-b, b), (-b, h), **sopt)
sage: se = parametric_plot3d([xe, ye, ze], (0, 1), (0, 1), **sopt)
sage: st = sp + sm + se
sage: st.show(frame=False)
Launched html viewer for Graphics3d Object
Mon, 03 Aug 2020 07:35:39 +0200https://ask.sagemath.org/question/52775/thicker-plot-in-implicit_plot3d/?answer=52820#post-id-52820