1

I want to draw a 3D surface outline using the 3D functionality of tikz or pgfplots. For example the code below creates a cylinder "can" surface but it is only valid for incline viewing angles \h between 0 and 90. If it goes above or below these values you can see that the rim of the caps are visible when they shouldnt be.

I am wondering if there is an easier way to define a general 3D surface in tikz but only show the outlines of the surface and fill the interior with white. Hence only the edges of the surface should be visible and any edges behind the surface should be obscured by the white.

\documentclass{standalone}

\usepackage{tikz}
\usepackage{tikz-3dplot}

\begin{document}
    % set the viewing angle
    \def\a{45}
    \def\h{55}
    \tdplotsetmaincoords{\h}{\a}
    \begin{tikzpicture}
    [scale=7,
    tdplot_main_coords,
    axis/.style={->,black,very thin},
    curve/.style={black,thin}]
    % radius and axes
    \def\radius{.1}
    \def\axissize{.3}
    \def\th{0.25}



    \tdplotsinandcos{\sintheta}{\costheta}{0}
    \tdplotdrawarc[curve,thick]{(0,0,\th)}{\radius*\costheta}{\a-360}{\a}{}{}
    \tdplotdrawarc[curve,thick]{(0,0,0)}{\radius*\costheta}{\a}{\a-180}{}{}
    \tdplotsinandcos{\sintheta}{\costheta}{\a}
    \draw[thick] (\radius*\costheta,\radius*\sintheta,0) {} -- (\radius*\costheta,\radius*\sintheta,\th);

    \tdplotsinandcos{\sintheta}{\costheta}{\a+180}
    \draw[thick] (\radius*\costheta,\radius*\sintheta,0) -- (\radius*\costheta,\radius*\sintheta,\th);


    \end{tikzpicture}

\end{document}
  • You would have to draw the edges back-to-front in order, Which is a lot more difficult than handling the 3 or 4 special cases separately. – John Kormylo Nov 21 '17 at 15:49

Your Answer

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

Browse other questions tagged or ask your own question.