TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

After I learned earlier today how to draw nice randomized trees (Draw randomized tree in TikZ) , I discovered that I'm not quite satisfied with how the results look like - because the structure I want to draw is not really a tree, but actually a shower of high energy particles. Here's the best I can do:




    \foreach \i in {1,...,\nTracks} {
      \pgfmathparse{\phiMin+(\phiMax-\phiMin)*(\i-1)/\nTracks + rnd * ((\phiMax-\phiMin)/\nTracks-\phiSep) + \phiSep/2}
      \typeout{#2 \i : \phiVal - \radVal}
      \coordinate (\coordname) at (\phiVal:\radVal);
      \draw[black] (#2) --  (\coordname);
        \ifthenelse{\lengthtest{\pgfmathresult pt<\branchingProbability pt}}{


  \coordinate (test);

If you run the output, you see from the \typeouts that all the nodes are created and everything seems to work - apart from the fact that only the first iteration seems to be drawn. I think this has something to do with the polar coordinates, but I can't quite figure out what's wrong with it.


Follwing a comment from Qrrbibel, here is an image of a shower that looks like what I was hoping for:

Atmospheric Collision

As you can see, it has a tree-like structure, but the nodes from different branches are not leveled and the lines are decreasing in length and varying in angle as the tree expands, giving the whole thing a somewhat more realistic look as compared to purely schematic trees.

share|improve this question
Can you add an example or a link to “a shower of high energy particles”. How does that look like? Why are you using xkeyval? TikZ already uses the pgfkeys package and that integrates nicely. By the way, in your code, you use \pgfmathparse twice successively, the result from the first one is lost and never accessed. – Qrrbrbirlbel Oct 13 '13 at 15:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.