TikZ:如何繪製螺旋線並填滿曲線下方的區域

TikZ:如何繪製螺旋線並填滿曲線下方的區域

我正在嘗試畫一個螺旋狀並填滿曲線下方的區域。由於該圖的目的只是“給出一個想法”,因此我寧願保持簡單並避免使用我不熟悉的PGFplotsand 。GNUplot

參考下面的MWE,我畫了曲線和陰影,但後者對於 的負值x(即水平方向)似乎不正確。因此我問如何做正確的事。

此外,我想從螺旋面的軸(即zTikZ 座標系中的軸)開始繪製線到螺旋面本身的相應點。我註解掉的那段程式碼應該可以達到這個目的,但它不能像現在這樣運作。

有人能幫我嗎?

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
  \draw [name path=E-wave] [red,thick,->] plot [domain=0:13,samples=100] ({sin(\x r)},{cos(\x r)},\x);
  \fill [red,fill opacity=0.2] (0,0,0) -- plot [domain=0:13,samples=100] ({sin(\x r)},{cos(\x r)},\x) -- (0,0,13) -- cycle;
  %\foreach [evaluate={\xpos=1.1*sin(\zpos*180/pi);\ypos=1.1*cos(\zpos*180/pi);}] \zpos in {0,0.25*pi,...,4*pi} {
  %  \path [name path=mgntd] (0,0,\zpos) --  (\xpos,\ypos,\zpos);
  %  \draw [name intersections={of=E-wave and mgntd,by={isect\zpos}}] (0,0,\zpos) -- (isect\zpos);
  %}
  \draw [->] (0,0,0) -- (0,0,14.5);
\end{tikzpicture}
\end{document}

在此輸入影像描述

答案1

主要問題是步驟太小,無法被intersections庫識別(有些想法寫在評論部分)。我們還需要修正一個係數1.1以使箭頭回到曲線上。所呈現的佈局與此類似,https://i.stack.imgur.com/mcmob.png

%! *latex mal-helicoid.tex
\documentclass[a4paper]{article}
\pagestyle{empty}
\usepackage{tikz}
\usetikzlibrary{intersections}
\pagecolor{white}

\begin{document}
\tikzset{malstyle/.style={->,>=stealth, line width=0.2pt},
  malarrow/.style={->, >=stealth}}

\begin{tikzpicture}
% The curve drawing and filling...
\draw [name path=Ewave] [red, thick, ->, fill, fill opacity=0.2] (0,0,0) -- plot [domain=0:12.5664, samples=100] ({sin(\x r)}, {cos(\x r)}, \x) -- (0,0,12.5664) --cycle;
%\fill [red, fill opacity=0.2] (0,0,0) -- plot [domain=0:12.5664, samples=100] ({sin(\x r)},{cos(\x r)},\x) -- (0,0,12.5664) -- cycle;

% Adding all kind of arrows...
\foreach [ evaluate={\xpos=sin(\zpos*180/pi); \ypos=cos(\zpos*180/pi);} ]
   \zpos in {0, 0.2618, ..., 12.5664} 
  {% Beginning of \foreach...
  \draw[malstyle, black] (0,0,\zpos) -- (\xpos, \ypos, \zpos);
  \draw[malstyle, black!40] (0,0,0) --  (\xpos, \ypos, 0);
  \draw[malstyle, green] (0,0,\zpos) --  (\xpos, 0, \zpos);
  \draw[malstyle, blue] (0,0,\zpos) --  (0, \ypos, \zpos);
  }% End of \foreach...

% Drawing the axis... (positive and negative values)
% positive
\draw [malarrow] (0,0,0) -- (0,0,14.5) node[xshift=5, yshift=15] {$z$};
\draw [malarrow] (0,0,0) -- (0,2,0) node[xshift=-5, yshift=-10] {$y$};
\draw [malarrow] (0,0,0) -- (2,0,0) node[xshift=-10, yshift=-5] {$x$};
% negative
\draw[dashed] (0,0,0)--(-2,0,0)  (0,0,0)--(0,-2,0)  (0,0,0)--(0,0,-4);
\end{tikzpicture}

\end{document}

Mwe,我的第五次嘗試,希望也是最後一次嘗試:-)

答案2

如果你想保持簡單,請使用二維表示(擺線)。運行該範例xelatex

\documentclass[pstricks]{standalone}
\usepackage{pst-plot,pst-math}

\def\rA{1} \def\rB{2} \def\Fr{1.25 }

\begin{document}
\begin{pspicture}(-2,-2)(13,12)
\rput{45}(0,0){%
  \psparametricplot[algebraic,plotpoints=1000,fillstyle=solid,
    fillcolor=red!40!white!80,linecolor=red]%
     {0.25 ACOS \Fr div}{0.25 ACOS \Fr div Pi 4.13 mul add}%
     {\rA*t-\rB*sin(t*\Fr) | -\rA+\rB*cos(t*\Fr)+0.5}
  \psparametricplot[algebraic,plotpoints=1000,linecolor=red,
    arrows=<-,arrowscale=2.5]%
     {0.5}{14.5}{\rA*t-\rB*sin(t*\Fr) | -\rA+\rB*cos(t*\Fr)+0.5}
  \psline(-1.5,0)(16.5,0)}
\end{pspicture}
\end{document}

在此輸入影像描述

相關內容