6

I am drawing a little sketch, where a line enters a circle, and three other lines come out. Above each line, there is to be a tittle sinusoidal curve (almost as if I used a construct like \node (a) edge node[auto] {Some caption} (b); which you can find on page 48, PGF manual 2.10); this illustrates what I have so far (code below):

enter image description here

My question is: How can I place a wiggly line such as there is on the left above the other 3 lines on the right? Especially the lines also going north and south east are troubling me. Furthermore: how can I get anchors around the middle node (potential) which are placed on a circle, so that my edges coming all have the same length?

So far: I achieved placing the line above the left edge by placing two empty nodes above it, and shifting one to the left on the x axis, and one to the right, and naming them:

\node[shape=coordinate] (arrow start) [left=of potential,xshift=-1cm] {}
    edge [post] node[auto,above,name=wavestart,yshift=0.3cm,xshift=-0.7cm] {}
                node[auto,above,name=waveend,yshift=0.3cm,xshift=0.7cm] {} (potential);

Afterwards I could connect those new nodes easily by just creating another edge between them and pathmorphing it:

\path (wavestart) edge[decorate,decoration={snake,amplitude=1.4mm, segment length=15pt}] (waveend);

All code:

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{patterns,positioning,decorations.pathmorphing,arrows}

\begin{document}

\begin{tikzpicture}%
    [post/.style={->,shorten >=1pt,>=stealth',semithick}]

    \node[circle, draw=black, pattern color=gray,%
     pattern=north east lines,label=below:$V(x)$,%
     minimum size=1cm] (potential) {};
    \node[shape=coordinate] [above right=of potential] (outgoing up) {};
    \node[shape=coordinate] [right=of potential] (outgoing mid) {};
    \node[shape=coordinate] [below right=of potential] (outgoing down) {};

    \path (potential)
        edge[post] (outgoing up)
        edge[post] (outgoing mid)
        edge[post] (outgoing down);

    \node[shape=coordinate] (arrow start) [left=of potential,xshift=-1cm] {}
        edge [post] node[auto,above,name=wavestart,yshift=0.3cm,xshift=-0.7cm] {}
                                node[auto,above,name=waveend,yshift=0.3cm,xshift=0.7cm] {} (potential);

    \path (wavestart) edge[decorate,decoration={snake,amplitude=1.4mm, segment length=15pt}] (waveend);



\end{tikzpicture}

\end{document}

2 Answers 2

4

You could put the wiggly line in a node and then position that like you normally would. Example code:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns,positioning,decorations.pathmorphing,arrows}
\begin{document}
\def\sinline{\tikz\draw[decorate,decoration={snake,amplitude=1.4mm, segment length=15pt}] (0,0) -- (.8,0);}
\begin{tikzpicture}%
    [post/.style={->,shorten >=1pt,>=stealth',semithick}]

    \node[circle, draw=black, pattern color=gray,%
     pattern=north east lines,label=below:$V(x)$,%
     minimum size=1cm] (potential) {};
    \node[shape=coordinate] [above right=of potential] (outgoing up) {};
    \node[shape=coordinate] [right=of potential] (outgoing mid) {};
    \node[shape=coordinate] [below right=of potential] (outgoing down) {};

    \path (potential) ++(-2,0) edge[post] node[above,sloped]{\sinline} (potential);

    \path (potential)
        edge[post] node[above,sloped]{\sinline} (outgoing up)
        edge[post] node[above,sloped]{\sinline} (outgoing mid)
        edge[post] node[above,sloped]{\sinline} (outgoing down);

\end{tikzpicture}
\end{document}

The result:

wiggly lines

5
  • Oh wow, that's a lovely solution! In fact, I wanted to do exactly that yesterday, but I couldn't figure out how. Thank you so much! Commented Jan 30, 2012 at 16:15
  • Is there a way to have tikz not inherit the post style? Right now, the node containing \sinline apparently inherits the post style from the edge. Commented Jan 30, 2012 at 21:04
  • Also: that syntax you used \path (potential) ++(-2,0) edge (potential): how could I use it in reverse? I guess \path (potential) edge ++(+2,0) would work, but what about \path (a) edge ++ (b) (+2,0) (that one fails)? Commented Jan 30, 2012 at 21:17
  • @mSSM: As far as inheriting the post style goes, I don't think there is much you can do. The easiest way is to explicitly set the values you want for those given in the post style on the node (they will override). For the reverse of the path notation, I don't really get what you mean. Your syntax is wrong on your try. You need to tell me what you wish to accomplish in order for me to be able to correct you. Commented Jan 31, 2012 at 0:21
  • Ok, let me rephrase my second question: with \path (a) ++(-2,0) edge (b) you essentially say "start at (a), move to (-2,0) from (a) and make this the new reference point, and draw a line to (b)". What I want to do is: "start at (a), draw a line to [ (b) ++(+2,0) ]", i.e. I would like to have an edge from (a) to a point somewhere past (b), using a similar syntax you employed. Commented Jan 31, 2012 at 13:24
1

For this kind of annotations of path are the pics made for.

The pic is called sine and is drawn as such, the options given to the pic[<options>] can be used inside the pic code via the pic actions key.

I've added the pic directly to the post style with an optional color parameter for the sine curve.

Code

\documentclass[tikz]{standalone}
\usetikzlibrary{patterns,arrows.meta}
\begin{document}
\begin{tikzpicture}[
  reset/.style={color=black,thin,solid,opaque,line cap=butt,line join=miter,arrows=-},
  post/.style={
    -{Stealth[round]}, shorten >=1pt, semithick,
    edge node={pic[reset,sloped,draw=#1]{sine}}},
  post/.default=black,
  sine/.pic={
    \path[yscale=.1,xscale=.08,pic actions] (-2*pi,2)
      foreach \i in {1,-1,1,-1} {
        sin ++(pi/2,+\i) cos ++(pi/2,+-\i) };
  }]

\node[circle, draw=black, pattern color=gray, pattern=north east lines,
      label=below:$V(x)$, minimum size=1cm] (potential) {};

\path (potential) ++ (left:2) edge[post] (potential)
      (potential)             edge[post=red]   ++ ( 45:2)
                              edge[post=green] ++ (  0:2)
                              edge[post=blue]  ++ (-45:2);
\end{tikzpicture}
\end{document}

Output

enter image description here

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.