Do you want to be able to specify four or more nodes, some of which might not influence the hull?
–
JakeSep 1 '11 at 13:31

No, you can assume the hull is known, and that the nodes are given in a clockwise direction.
–
Simon ByrneSep 1 '11 at 13:36

I tried to compile both examples from above, always pdflatex reported for instance: Package pgf Error: No shape named is known \draw[red]\convexpath{a,b,c,d}{1cm} What trick am I missing? It can't be so difficult ... I am using Debian, is it a version problem?
–
user25147Jan 28 '13 at 19:15

@curiosity: Which version of PGF are you using (check your .log file)
–
JakeJan 29 '13 at 8:52

3 Answers
3

Here's one way of doing it: I used [<new pgf key>/.code={...}, <new pgf key>] to smuggle some code into the TikZ path that can be executed without interrupting the path construction. The code creates new invisible nodes at the position of all the specified nodes and names them sequentially (hullnode[1...n]), and then creates two additional nodes hullnode0 at hullnode[n] and hullnode[n+1] at hullnode1. This makes it possible to just loop over hullnode[1...n] and draw the arcs.

The command takes two arguments: A comma separated list of node names (without parentheses), and a buffer length. If anyone succeeds in making the buffer size argument optional, please tell me how!

Unfortunately, the result is no longer the same as of pgf 3.0.0.
–
RaimFeb 1 '14 at 23:22

2

@Raim I just came across exactly the same problem: it seems that the atan2 function has changed, so you need to switch the arguments: e.g. atan2(\x1,\y1) becomes atan2(\y1,\x1)
–
Simon ByrneMar 21 '14 at 11:35

@SimonByrne good catch. I already wasn't understanding why my old presentations would no longer compile correctly. Perhaps this can also be changed in the code provided above by @Jake?
–
jackalNov 18 '14 at 14:28

That's great! You should probably accept this answer instead of mine (I think you might need to wait a bit before that's possible) so it will be more obvious to others looking for a way to do this.
–
JakeSep 15 '11 at 12:05

When defining \previousnode and \nextnode, you should write int(\currentnode +/- 1). Otherwise, hullcoord\nextnode will expand to e.g. hullcoord0.0 causing small bad visible flickers in the result. Btw, I would also prefer if this was the accepted and thus topmost answer.
–
gTcVOct 23 '14 at 11:08

Here's an alternative solution. Not as fancy as the other two answers, but simpler to use I think, plus you can more easily customize the borders. Also, it doesn't matter whether the order is clockwise or counter-clockwise.

If instead you only want the line, you can use the same approach as for the double line style. We simply draw the same path again, but a little bit smaller and in the background color (white in this case).