Ask Your Question

Revision history [back]

So 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