我正在用积分来写体积,我必须画出这个。
我该如何正确绘制它?
这是我的代码:
\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}
答案1
我建议使用ellipse
:
参考:
代码:
\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}
答案2
仅用于使用 PSTricks 进行打字练习。
动画版
\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}