TikZ: Perpendicular bisector of a line

Yes, with the calc library. See section 13.5.4 The Syntax of Distance Modifiers in the manual.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (3,1.2);

\draw (A) -- (B) coordinate[midway] (M);
\draw [blue,thick] ($(M)!0.5cm!270:(A)$) -- ($(M)!0.5cm!90:(A)$);
\end{tikzpicture}
\end{document}

enter image description here


Another possibility is the turn option. See section "13.4.2 Rotational Relative Coordinates" in the manual.

\documentclass[margin=5pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
  \path
    (0,0)coordinate(A)
    -- coordinate(M)
    (3,1.2)coordinate(B)
  ;
  \path
    (A)
    -- (M)
    -- ([turn]90:.5)coordinate(l1)
    -- ([turn]180:1)coordinate(l2)
  ;
  \draw (A) -- (B);
  \draw[orange] (l1) -- (l2);
\end{tikzpicture}
\end{document}

enter image description here

Tags:

Tikz Pgf