# How to draw a circular and a spiral line between two vectors

I'd like to do the next graph:

(Sorry for my terrible draw!) I pretend the red line to be a dashed black spiral line, and I'd like the blue line to be a dashed black circular line.

What I've got so far:

\begin{tikzpicture}
\draw [<->] (0,4) node[left]{$\mbox{Im} (z)$} -- (0,0) -- (4,0) node[below]{$\mbox{Re} (z)$};
\draw [<->] (1,3)node[right]{$\alpha z$} -- (0,0) -- (2,1)node[right]{$z$};
\end{tikzpicture}


Anyone could help me?

The radius, the start and end angles for the arc command can be calculated, see the following example.

(Update:) For the red "spiral" line I have used the plot function with a polar coordinate. The length of the polar coordinate linearly increases with the angle going from point (z) to (a):

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{topaths}

\begin{document}
\begin{tikzpicture}
\draw [<->]
(0,4) node[left]{$\mbox{Im} (z)$}
-- (0,0)
-- (4,0) node[below]{$\mbox{Re} (z)$};
\draw [<->]
(1,3) coordinate (a) node[above] {$\alpha z$}
-- (0,0)
-- (2,1) coordinate (z) node[right] {$z$};

\draw[blue]
let \p{z} = (z),
\n{angle_z} = {atan(\y{z}/\x{z})},
\p{a} = (a),
\n{angle_a} = {atan(\y{a}/\x{a})},
in
(z) arc[start angle=\n{angle_z},
end angle=\n{angle_a},
;

\draw[red, densely dashed]
let \p{z} = (z),
\p{a} = (a),
\n{zAngle} = {atan2(\y{z}, \x{z})},
\n{aAngle} = {atan2(\y{a}, \x{a})},
\n{diffAngle} = {\n{aAngle} - \n{zAngle}},
\n{zLength} = {sqrt(\x{z}*\x{z} + \y{z}*\y{z})},
\n{aLength} = {sqrt(\x{a}*\x{a} + \y{a}*\y{a})},
\n{diffLength} = {\n{aLength} - \n{zLength}}
in
plot[
smooth,
variable=\t,
domain=\n{aAngle}:\n{zAngle},
samples=8,
]
(\t:{\n{zLength} + \n{diffLength} * (\t - \n{zAngle}) / \n{diffAngle}})
;
\end{tikzpicture}
\end{document}


Remark:

The order of arguments for function atan2 has changed in TikZ 3.0: atan2(<y>, <x>). In case of older TikZ versions, <y> and <x> has to be exchanged.

A combination of rotation and scaling does the job neatly in Metapost.

prologues := 3;
outputtemplate := "%j%c.eps";

beginfig(1);

path re, im;
re = origin -- right scaled 4cm;
im = re rotated 90;
drawarrow im; label.lft(btex $\mathop{\rm Im}(z)$ etex, point 1 of im);
drawarrow re; label.bot(btex $\mathop{\rm Re}(z)$ etex, point 1 of re);

z1 = (2.828cm,1.414cm);
alpha = 0.3;
theta = 45;

s = 20;
draw z1 for i=1 upto s: -- z1 rotated (theta*i/s)                      endfor withcolor .67 blue;
draw z1 for i=1 upto s: -- z1 rotated (theta*i/s) scaled (1+alpha*i/s) endfor dashed evenly withcolor .73 red;

drawarrow origin -- z1;
drawarrow origin -- z1 scaled (1+alpha) rotated theta;

label.rt (btex $z$ etex, z1);
label.top(btex $\alpha z$ etex, z1 scaled (1+alpha) rotated theta);

endfig;
end.

• I would suggest the use of the zscaled operator in this case. May 21, 2015 at 12:09
• @FranckPastor yes it's a natural for zscaled but I was trying to show the basic approach. It would be interesting to see a version for comparison. May 21, 2015 at 17:29

Another try with MetaPost, inspired by Thruston's solution, but using the zscaled operator of MetaPost which is in fact the complex multiplication. Also, I have incorporated it in a LuaLaTeX program, as I use to do.

\documentclass[border=2mm]{standalone}
\usepackage{luamplib, amsmath}
\begin{document}
\begin{mplibcode}
beginfig(1);
r = 1.3; theta = 45;
z = (2.828cm,1.414cm);
pair alpha, alphaz, re, im;
re = (4cm, 0); im = (0, 4cm);
alpha = r*dir theta;
alphaz = z zscaled alpha;
for m = re, im, z, alphaz: drawarrow origin -- m; endfor
s = 20;
draw z
for i = 1 upto s: .. z zscaled ((i/s)[1,r]*dir(i/s*theta))
endfor withcolor .73red dashed evenly;
draw z
for i = 1 upto s: .. z rotated (i/s*theta)
endfor withcolor .67blue;
label.bot(btex $\text{Re}(z)$ etex, re);
label.lft(btex $\text{Im}(z)$ etex, im);
label.rt(btex $z$ etex, z);
label.top(btex $\alpha z$ etex, alphaz);
endfig;
\end{mplibcode}
\end{document}


Here is a short code for an Archimedean spiral between two points (the equation was calculated) with pstricks:

\documentclass[pdf, x11names]{standalone}
\begin{pspicture} $\psset{ticks=none, labels=none, arrowinset=0.2,arrows =c->, labelsep=3pt} \psaxes{c->}(0,0)(4.6,4.6)[\re (z),-90][\im (z),180] \pnodes(0,0){O}(2.8;30){Z}(4.6;60){T} \uput[r](T){\alpha z}\uput[r](Z){z} \ncline{O}{T} \ncline{O}{Z} \psset{linewidth =0.6pt} \psarc[linecolor=LightSteelBlue3,dimen=inner](O){2.8}{31}{60} \psplot[linecolor=Tomato3, polarplot, algebraic, plotpoints=200]{\Pi6}{\Pi3}{10.8*x/Pi + 1}%$\end{pspicture}