2

My plot as shown below is not reflecting the upper cap surface exactly as I have defined it (I simply negated the z-ordinate of the parametric equations)

Is this some kind of numerical bug?

enter image description here

\documentclass{article}
\usepackage[a4paper,top=3cm,bottom=3cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usepgfplotslibrary{patchplots}
\usepgfplotslibrary{colormaps}

\usetikzlibrary{arrows.meta}
\usetikzlibrary{shadings}
\usepackage{xcolor}
\usepackage{tikz-3dplot}

\begin{document}
\begin{tikzpicture}[scale=2]
\pgfmathsetmacro{\myangle}{90}
\begin{axis}[axis equal image, axis lines=none, ticks=none, view/h=120, view/v=20]
%cylindrical faces
    %\addplot3[surf, shader=interp, point meta={cos(\myangle)*x+sin(\myangle)*y}, colormap={grayslate}{rgb255=(200,200,200)rgb255=(0,0,0)}, opacity=0.75, z buffer = sort, samples = 35, 
    %variable = \u, variable y = \v, domain = 0:360, y domain = -2:2, ] ({1+cos(u)}, {sin(u)}, {(1 + floor(-v/(abs(-v)+1)) - floor(v/(abs(v)+1)))*max(-sqrt(4 - 2*x),v)/2 + (1 + floor(v/(abs(v)+1)) - floor(-v/(abs(-v)+1)))*min(sqrt(4 - 2*x),v)/2});
%spherical faces
    \addplot3[surf, shader=interp, colormap={custom}{rgb255=(100,100,100)rgb255=(250,250,250)}, z buffer = sort, samples = 35,
    variable = \u, variable y = \v, domain = 0:1, y domain = 0:180] ({u(1+cos(2*v))}, {u*sin(2*v)}, {2*sqrt(1- u*u*cos(v)^2)});
    \addplot3[surf, shader=interp, colormap={custom}{rgb255=(100,100,100)rgb255=(250,250,250)}, z buffer = sort, samples = 35,
    variable = \u, variable y = \v, domain = 0:1, y domain = 0:180] ({u(1+cos(2*v))}, {u*sin(2*v)}, {-2*sqrt(1- u*u*cos(v)^2)});
%window
    \addplot3+[domain=0:720, samples=50, samples y=0, no marks, smooth, solid, black, thin]({1+cos(x)},{sin(x)},{2*sin(x/2)});
\end{axis}\end{tikzpicture}
\end{document}
1

Are you sure you aren't just looking on the inside of the upper cap, and if you rotated your viewport you'd be able to see the feature?

  • this is not a cone – Jack Tiger Lam Sep 30 at 6:42
  • Sorry, I meant the upper cap. Do you think you could just be looking at the inside of the upper cap from below, with it not being shaded like you expect? – Keeley Hoek Sep 30 at 6:43
  • 1
    the upper cap is definitely smooth; but I have opted to use a different parametrisation of my surface, so I don't think this question is necessary any longer. but i will keep it up and take your answer for completeness. – Jack Tiger Lam Sep 30 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.