3

I'm writing about the volume by an integral, and I had to draw this.

enter image description here

How do I draw it properly?

Here is my codes:

\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\usepackage[lmargin=3cm,rmargin=2cm,tmargin=2cm,bmargin=1.7cm]{geometry}

\begin{document}

\begin{tikzpicture}[scale=0.6]
\draw[->] (-1,0) -- (25,0) node[right] {$x$};
\draw (0,0) -- (4,0) -- (4,1.93) -- cycle;
\draw[dashed] (0,0) -- (4,0) -- (4,-1.93) -- cycle;
\draw[dashed,sloped] (4,-1.93) .. controls (3.3,0) .. (4,1.93) ;
\draw[dashed,sloped] (4,-1.93) .. controls (4.7,0) .. (4,1.93) ;

\draw[sloped] (5,0) .. controls (6.19,1.86) and (7.74,1.12) .. (8.2,1.83) ;
\draw[sloped,dashed] (5,0) .. controls (6.19,-1.86) and (7.74,-1.12) .. (8.2,-1.83) ;
\draw[dashed,sloped] (8.2,-1.83) .. controls (8.7,0) .. (8.2,1.83) ;
\draw[dashed,sloped] (8.2,-1.83) .. controls (7.7,0) .. (8.2,1.83) ;

\draw[sloped] (9,0) .. controls (11.04,1.96) .. (14.59,0) ;
\draw[sloped,dashed] (9,0) .. controls (11.04,-1.96) .. (14.59,0) ;
\draw[dashed,sloped] (11.04,-1.5) .. controls (10.5,0) .. (11.04,1.5) ;
\draw[dashed,sloped] (11.04,-1.5) .. controls (11.5,0) .. (11.04,1.5) ;

\draw (15.79,0) -- (17.5,1.93) -- (22,0) -- cycle;
\draw[dashed] (15.79,0) -- (17.5,-1.93) -- (22,0) -- cycle;
\draw[dashed,sloped] (17.5,-1.93) .. controls (16.8,0) .. (17.5,1.93) ;
\draw[dashed,sloped] (17.5,-1.93) .. controls (18.1,0) .. (17.5,1.93) ;
\end{tikzpicture}

\end{document}
kalakay
  • 2,469

2 Answers2

5

Just for typing exercise with PSTricks.

Animated version

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-func}

\def\f{(sin(x)+1.2)}
\pstVerb{/I2P {AlgParser cvx exec} def}

\begin{document}
\foreach \n in {10,...,25}{%
\begin{pspicture}(-0.5,-3)(7,3)
    \psVolume[fillstyle=solid,fillcolor=orange!50,linecolor=blue](0,\psPiTwo){\n}{\f I2P}
    \psaxes{->}(0,0)(0,-2.75)(6.75,2.75)[$x$,0][$y$,90]
\end{pspicture}}
\end{document}

enter image description here

  • Why does this doesn't paint “correctly” all of the small cylinders? I mean, in the (approximated) interval [1.5,4.5] —where the derivative is negative— all the cylinders are missing one line (they should look exacty like the last cylinder —with that edge visible—). I know nothing about pstricks so may be you are telling it not to do so. – Manuel Mar 17 '14 at 15:02
  • @Manuel: Please illustrate your question with some screenshots so I can easily grasp what you meant. – kiss my armpit Mar 17 '14 at 15:11
  • It's just the 3D of the cylinders, that in the interval I pointed evey cylinder is missing one edge (the one shown in the last cylinder to the right). In the rest of cylinders (out of that interval) that edge doesn't matter because the cylinder next to it is bigger and hides it. – Manuel Mar 17 '14 at 15:17
  • @Manuel: I think it is a bug. :-) – kiss my armpit Mar 17 '14 at 15:21
  • Ok. I was trying to explain better, but I see you understood me ;) – Manuel Mar 17 '14 at 15:21
3

I'd recommend using an ellipse:

enter image description here

References:

Code:

\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\usepackage[lmargin=3cm,rmargin=2cm,tmargin=2cm,bmargin=1.7cm]{geometry}

% https://tex.stackexchange.com/questions/36534/symbol-for-rotate-around-axis/ \newcommand{\AxisRotator}[1][rotate=0]{% \tikz [x=0.25cm,y=0.60cm,line width=.2ex,-stealth,#1] \draw (0,0) arc (-150:150:1 and 1);% }

\begin{document}

\begin{tikzpicture}[scale=0.6]

\draw[->] (-1,0) -- (25,0) node[right] {$x$}; \draw (-2,0) -- (0.25,0) node [midway] {\AxisRotator[rotate=-180]};

\draw (0,0) -- (4,0) -- (4,1.93) -- cycle; \draw[dashed] (0,0) -- (4,0) -- (4,-1.93) -- cycle; %\draw[dashed,sloped] (4,-1.93) .. controls (3.3,0) .. (4,1.93) ; %\draw[dashed,sloped] (4,-1.93) .. controls (4.7,0) .. (4,1.93) ; \draw [blue, thick] (4,0) ellipse [x radius=0.5cm, y radius=1.92cm];

\draw[sloped] (5,0) .. controls (6.19,1.86) and (7.74,1.12) .. (8.2,1.83) ; \draw[sloped,dashed] (5,0) .. controls (6.19,-1.86) and (7.74,-1.12) .. (8.2,-1.83) ; %\draw[dashed,sloped] (8.2,-1.83) .. controls (8.7,0) .. (8.2,1.83) ; %\draw[dashed,sloped] (8.2,-1.83) .. controls (7.7,0) .. (8.2,1.83) ; \draw [blue, thick] (8.2,0) ellipse [x radius=0.5cm, y radius=1.80cm];

\draw[sloped] (9,0) .. controls (11.04,1.96) .. (14.59,0) ; \draw[sloped,dashed] (9,0) .. controls (11.04,-1.96) .. (14.59,0) ; %\draw[dashed,sloped] (11.04,-1.5) .. controls (10.5,0) .. (11.04,1.5) ; %\draw[dashed,sloped] (11.04,-1.5) .. controls (11.5,0) .. (11.04,1.5) ; \draw [blue, thick] (11.04,0) ellipse [x radius=0.5cm, y radius=1.47cm];

\draw (15.79,0) -- (17.5,1.93) -- (22,0) -- cycle; \draw[dashed] (15.79,0) -- (17.5,-1.93) -- (22,0) -- cycle; %\draw[dashed,sloped] (17.5,-1.93) .. controls (16.8,0) .. (17.5,1.93) ; %\draw[dashed,sloped] (17.5,-1.93) .. controls (18.1,0) .. (17.5,1.93) ; \draw [blue, thick] (17.5,0) ellipse [x radius=0.5cm, y radius=1.88cm]; \end{tikzpicture}

\end{document}

Peter Grill
  • 223,288