Given the points A, B and P below, I would like to draw a line parallel to AB and passes through P (or just points towards P if P is not between A and B on the x-axis as in this example). In other words, it is to shift AB up/down so that the shifted line is collinear with P.
Desired output (the point R shown just for illustration):
Below is what I currently have. In essence it is to project P vertically onto AB (call the projection R), then use tikz.calc to get the starting and ending points of the red line. I wonder if there is a simpler approach, where ideally I can do away with setting the dummy points Q and R? A similar problem is here but P has to be vertically above/below A or B in that question.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[dot/.style={circle,inner sep=1pt,fill,label={#1},name=#1}]
% define the points A, B, P
\draw[dashed] (0,0) node[dot=A]{}
-- (3,2) node[dot=B]{}
(-1,0.5) node[dot=P]{};
% find vertical projection of P on AB as R
\path (P) +(0,-0.1) coordinate(Q); %0.1 is an arbitary value
\node[dot=R] at (intersection of A--B and P--Q){}; %make R a coordinate in actual use
\draw[red] ($(A)+(P)-(R)$) -- ($(B)+(P)-(R)$);
\end{tikzpicture}
\end{document}





