Continuing from here, I would like to calculate a third coordinate, c3, that lies in the middle of c1 and c2. I have tried

\coordinate (c3) at (0.5*c1+0.5*c2);

but that gives me the error

Package pgf Error: No shape named 0 is known

Second, I would like to draw an arrow from c3, orthogonal to the line between c1 and c2. So I would like to take the difference c2-c1, rotate that vector by 90 degrees, normalize it, multiply it with the length the arrow is supposed to have, then add it to c3 and store it as a new coordinate called c4. Is this possible? (I want to avoid calculating the coordinates manually since I have to do this a lot of times and I want to be able to make changes to it easily)

Edit 1: Thanks to Jake and percusse, I reallized that I have to enclose the expression in $-signs and enclose the coordinates in parentheses. I have now updated the minimal example to

As can be seen, the arrows are not equally long, so replacing 2cm (which Jake used) with 0.5 (which I assumed would automatically, like all other coordinates specified without a unit, use the x and y vectors) did apparently not work. Any ideas for how to specify the length of the arrow in terms of "unit lengths"? (The coordinate (4,1) for example is 4 unit lengths in the x-direction and 1 unit length in the y-direction)

Nice! But I'm running into problems when I'm trying to replace the 2cm with a dimensionless quantity. I've updated my question to include that.
–
StrawberryFieldsForeverAug 13 '12 at 12:15

1

I can't think of a simple way to do this, since you can specify different lengths for x and y. What (physical) length would you expect the dimensionless length 1 to have? I would recommend defining a macro \def\unitlength{0.05\textwidth} before your tikzpicture, and using that macro both in the definition of x and y and in the coordinate calculations. In your example, you could use \def\unitlength{0.05\textwidth} \begin{tikzpicture}[x=\unitlength,y=\unitlength] \def\arrowlength{0.5*\unitlength}
–
JakeAug 13 '12 at 12:21

That would definitely be a solution. I recal I have even used a similar method for another problem I ran in to.
–
StrawberryFieldsForeverAug 13 '12 at 12:23

Assuming the coordinate system is not skewed, the macro \pgf@xx holds the unit x vector. So {\arrowlength*\pgf@xx} would give 0.5 times the unit x vector. But requires \makeatletter somewhere before that
–
percusseAug 13 '12 at 12:46

In addition to Jake's answer, when one wants to do a little more complicated point weighting etc. the local shift and scale options are useful (both with x and y counterparts). They map to lower level PGF commands \pgfpointadd and \pgfpointscale commands.