7

I am trying to draw an helicoid and to fill the area below the curve. Since the aim of the figure is just to "give an idea", I would prefer to keep it simple and to avoid using PGFplots and GNUplot -- with which I am not familiar.

Referring to the MWE below, I drew the curve and the shading, but the latter does not seem right for negative values of x, i.e. the horizontal direction. Thus I am asking how to make it right.

Moreover, I would like to draw lines starting from the axis of the helicoid, i.e. the z axis in TikZ coordinate system, to the corresponding point on the helicoid itself. The piece of code I commented out should serve this purpose, but it does not work as it is now.

Can someone help me?

\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}

enter image description here

2 Answers 2

10
+100

The main problem was that step was too small to be recognized by the intersections library (some ideas are written in the comment section). We also needed to correct a coefficient of 1.1 to get arrowheads back on the curve. The presented layout is in a way similar to this one, https://i.sstatic.net/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, my fifth and hopefully the last attempt :-)

7
  • This is what I was trying to accomplish, thanks. Just two questions: 1) what do you mean by "The step was too small"? My step was 0.25*pi which is something like 0.789. 2) Why do the arrows do not have their arrowhead on the curve?
    – Pier Paolo
    Commented Mar 29, 2014 at 17:43
  • 1
    I think you tried to reach isect\zpos, specifically e.g. isect0.78539, that's an item which is not in the set of intersection points. I would need a little more digging on this but I think you can reach isect0, isect1, isect2 if it is in the list, ... So your 0*pi was fine in theory (there could be a problem of 0 as an integer value versus 0.0 as a real value), but not the other steps. To 2) It is still a surprise to me too, I am on it.
    – Malipivo
    Commented Mar 29, 2014 at 18:03
  • 1
    If you \let, it points to the memory address not to the actual value. You can use \pgfmathsetmacro to get the value assigned to the macro.
    – percusse
    Commented Mar 29, 2014 at 18:06
  • @percusse Thank you for letting me know. It is good to know.
    – Malipivo
    Commented Mar 29, 2014 at 18:07
  • 1
    You used a coefficient of 1.1 for the arrows (probably on purpose to get arrow heads more visible), but not for the curve and fill, this must be corrected somehow, e.g. by {1.1*sin(\x r)}, {1.1*cos(\x r)} (twice) or by deleting 1.1 in the main \foreach cycle (twice).
    – Malipivo
    Commented Mar 29, 2014 at 18:22
6

If you want to keep it simple use a 2d representation (cycloide). Run the example with 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}

enter image description here

4
  • Thanks for your answer, someday I'm surely going to learn PSTricks :). Could it be possible to draw arrows from points along the axis at coordinates (0,0,a) to points on the curve at corresponding coordinates (sin a,cos a,a) for values of a given by a=pi/3+k*p/3 and k=0,1,2... ?
    – Pier Paolo
    Commented Mar 25, 2014 at 10:20
  • Arrows are possible at the end of the curve, see my edited answer.
    – user2478
    Commented Mar 25, 2014 at 10:29
  • I was referring to something like this.
    – Pier Paolo
    Commented Mar 25, 2014 at 10:47
  • 1
    See tug.org/PSTricks/main.cgi?file=pst-plot/3D/examples#wave
    – user2478
    Commented Mar 25, 2014 at 10:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .