3

Sorry guys, I literally can't work out how to do this...

Consider the following figure:

enter image description here

This is drawn by:

  \begin{tikzpicture}
    \begin{scope}[rotate=+60]
      \foreach \x in {-0.3, -0.2, -0.1, 0.0, +0.1, +0.1, +0.2, +0.3}
        \draw[xshift=\x cm] (0, +2) -- (0, 0);
    \end{scope}
    \begin{scope}[rotate=-60]
      \foreach \x in {-0.3, -0.2, -0.1, 0.0, +0.1, +0.1, +0.2, +0.3}
        \draw[xshift=\x cm] (0, +2) -- (0, 0);
    \end{scope}
    \begin{scope}[rotate=180]
      \foreach \x in {-0.3, -0.2, -0.1, 0.0, +0.1, +0.1, +0.2, +0.3}
        \draw[xshift=\x cm] (0, +2) -- (0, 0);
    \end{scope}
    \fill[white]      (-1, -1) -- (+1, -1) -- (0, +1) -- cycle;
    \draw[very thick] (-1, -1) -- (+1, -1) -- (0, +1) -- cycle;
    \draw (0, -0.3) node {+};
  \end{tikzpicture}

Now how do I add arrow heads to it? (I want each line to have an arrow head where it meets the triangle.)

As you can see, I already had to to some awful hack with drawing a white triangle over the top of those lines, since TikZ doesn't seem to allow arbitrary clipping. But clipping wouldn't be necessary if I could just make the lines stop at the edge of the triangle --- and that would also make adding arrow heads trivial.

After about an hour of trial and error, I eventually managed to make the syntax for connecting nodes actually work. But then all the lines converge to the center of the triangle, rather than remaining parallel like I want.

\begin{tikzpicture}
  \node[name=add, regular polygon, regular polygon sides=3, draw, very thick] at (0, 0) {+};
  \begin{scope}[rotate=60]
      \foreach \x in {-0.3, -0.2, -0.1, 0.0, +0.1, +0.1, +0.2, +0.3}
        \draw[xshift=\x cm, ->] (0, +2) to (add);
    \end{scope}
\end{tikzpicture}

enter image description here

Any hints?

  • 1
    Please try with \draw[<-] (add.60)--+(60:2cm);. Writting tikz code from an ipad is not so easy. – Ignasi Jan 26 '15 at 21:27
  • @Ignasi Very true. And in the past it was even worse – JLDiaz Jan 27 '15 at 15:11
4

You can use the anchors to position your arrows, and, as @Ignasi suggests, specify coordinates in terms angles.

MWE

\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\begin{document}
\begin{tikzpicture}
  \node(add)[regular polygon,regular polygon sides=3,draw,very thick,minimum size=2cm]{+};
  \foreach\ang[count=\i] in {60,180,300}{
  \begin{scope}[rotate=\ang]
  \foreach \x in {0,.1,.2,.3}{
    \draw[<-]([xshift=\x cm]add.side \i)--+(90:2cm);
    \draw[<-]([xshift=-\x cm]add.side \i)--+(90:2cm);
  }
  \end{scope}
  }
\end{tikzpicture}
\end{document}

Output

enter image description here

  • Well... I pasted it in, and it works. I still haven't the vaguest idea why it works, but hey... – MathematicalOrchid Jan 27 '15 at 22:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.