[Tex/LaTex] Tikz: draw a vector pointing from one point to another

tikz-pgf

I have two points:

\coordinate (A) at (1,2);
\coordinate (B) at (13.2,-23.4);

I would like to draw a vector pointing from point A to point B. The vector starts from point A, its length is other specified, and its end is not at point B. See the figure below. Is there an automatic way to draw the arrow such that I need not to calculate the coordinate of the end of the arrow every time?

enter image description here

Best Answer

Additional to shorten, you could be interested in the calc library.

Code

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,arrows}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (-1,5);
\coordinate (B) at (1,2);
\tikzset{-|}
\draw [|-|,help lines] (A) -- (B);
\draw[black,very thick] (A) -- ($(B)!1cm!(A)$); % 1 cm before B
\draw[blue, thick] (A) -- ($(A)!.65!(B)$);      % 65 % on the path from A to B
\draw[green] (A) -- ($(B)!.45!(A)$);            % 45 % on the path from B to A (55% from A to B)
\end{tikzpicture}
\end{document}

Output

Output

Related Question