4

Assume that we have two coordinates (a) and (b). I want to draw a line which is a parallel translation of the line which connects (a) and (b).

I would like to have something like \drawparallel{a}{b}{dist} which will draw a line parallel to the one connecting (a) and (b) at (signed!) distance dist.

I tried many things both based on \newcommand and on \tikzset but could not make it work.

Edit: To make it clearer, I want the the four points (two of the original line segment, and two of its translated copy) will form a rectangle.

Dror
  • 22,613
  • What's parallel? Is \draw ([xshit=dist]a)--([xhsift=dist]b); enough? – Ignasi May 31 '13 at 10:52
  • @Ignasi: Actually no. With your solution the four points (two of the original curve and two of the translated one) form (in general) a parallelogram. I want them to form a rectangle. – Dror May 31 '13 at 11:35
  • 2
    You can use this one but without the connecting lines http://tex.stackexchange.com/questions/55068/is-there-a-tikz-equivalent-to-the-pstricks-ncbar-command – percusse May 31 '13 at 11:57

1 Answers1

4

Indeed, as pointed out by @percusse, Jake's answer solved my problem. In particular, I added the following

\tikzset{
      ncbar/.style={
        to path=%
        ($(\tikztostart)!#1!90:(\tikztotarget)$)
        -- ($(\tikztotarget)!($(\tikztostart)!#1!90:(\tikztotarget)$)!90:(\tikztostart)$)
      },
      ncbar/.default=0.5cm,
    }

Then,

\draw (a) -- (b);
\draw (a) to[ncbar=1] (b);

yielded the right result.

enter image description here

Dror
  • 22,613