2

I've got a (parametrised) truncated cylinder using the code below:

\documentclass[crop,tikz]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis line style = {draw=none},ticks = none]
            \def\h{.2}
            \def\r{1}
            \def\R{2}

            %\def\ang{2}
            %\begin{scope}[rotate around x=pi/2,rotate around z=\ang]
                %\draw[->] (0:0) arc (0:10:1);
            %\end{scope}

            \addplot3 [surf,color=black,faceted color=black,opacity=.1,domain=0:2*pi,y domain=0:1,samples=50,samples y=15] ({((\r-\R)*y+\R)*cos(deg(x))},{((\r-\R)*y+\R)*sin(deg(x))},{y*\h});

        \end{axis}
\end{tikzpicture}
\end{document}

I'm looking to add a (parametrised) line on the bottom plane, a line on the cylinder, an arc between the two lines, and a node to label the angle the cylinder makes with the horizontal plane, depicted in red below:

enter image description here

The parameter is the angle (\ang in the code and the blue bit in the picture above) of the plane around the vertical axis in in which to draw this triangular arc thing. Of course the $\theta$ angle is also a parameter, it should be atan(\h/(\R-\r)) where in the code I have put 10, since even that hasn't yet worked for me. Attempts using the commented out code with \draw[...] ... arc ... have borne no fruit.

1

I finally managed to do it. Although if you change the arrow head (to latex, for example) it doesn't look aligned because it remains two dimensional.

\documentclass[crop,tikz]{standalone}
\usepackage{pgfplots}%,tikz-3dplot}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}[hide axis,axis equal]
    \def\h{2}
    \def\r{1}
    \def\R{2}

    \addplot3 [surf,color=black,faceted color=black,opacity=.1,data cs=polar,domain=0:360,y domain=\r:\R,samples=50,samples y=15,data cs=polar] {(1-(y-\r)/(\R-\r))*\h};

    \def\ang{-100}
    \def\f{.7}
    \def\ff{.3}
    \def\fff{.5}
    \def\ffff{.8}
    \draw[blue,thick] ({\ff*\R*cos(\ang)},{\ff*\R*sin(\ang)},0) -- ({\R*cos(\ang)},{\R*sin(\ang)},0) -- ({\f*\R*cos(\ang)},{\f*\R*sin(\ang)},{(1-(\f*\R-\r)/(\R-\r))*\h});

    \def\fr{.5*\R}
    \addplot3[thick,variable=t,samples y=0,blue,domain=0:{atan(\h/(\R-\r))}
    ,->] ({\R*cos(\ang)+(\fr*cos(t))*cos(\ang-180)},{\R*sin(\ang)+(\fr*cos(t))*sin(\ang-180)},{\fr*sin(t)}) node[xshift=.05cm,yshift=-.55cm]{$\theta$};

    \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

1
  • 1
    The formula ({(\R-\fr*cos(t))*cos(\ang)},{(\R-\fr*cos(t))*sin(\ang)},{\fr*sin(t)}) draws the same curve and is more legible. – marsupilam Aug 26 '17 at 18:57

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.