![TikZ를 사용하여 곡선을 360도 올바르게 회전](https://rvso.com/image/286363/TikZ%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20%EA%B3%A1%EC%84%A0%EC%9D%84%20360%EB%8F%84%20%EC%98%AC%EB%B0%94%EB%A5%B4%EA%B2%8C%20%ED%9A%8C%EC%A0%84.png)
적분으로 볼륨에 대해 쓰고 있는데 이걸 그려야 했어요.
어떻게 하면 제대로 그릴 수 있나요?
내 코드는 다음과 같습니다.
\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}