I have the problem, that I want to draw a vector that is decomposed into two orthogonal parts. A short example:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[dot/.style={circle,inner sep=2pt,fill,label={#1},name=#1,color=red},
extended line/.style={shorten >=-#1,shorten <=-#1},
extended line/.default=1cm,scale=2]
\begin{scope}[rotate=30]
\node [dot=A] at (1,4) {};
\node [dot=B] at (2,2) {};
\node [dot=P] at (4,4) {};
\draw [->] (A) -- (B);
\draw [->] (A) -- (P -| B);
\draw [->] (A) -- ($(B) - (P-|B) + (A)$);
\end{scope}
\end{tikzpicture}
\end{document}
Here I have the vector AB. I want one of the component vecors to be in the direction of AP. The other should be orthogonal (as seen).
In the example I solved it using -| but this works only if the desired vectors are parallel to the actual axes. I need it for arbitrary points A, B and P.
Can you give me a hint, how to draw it?

