[Tex/LaTex] Draw height in Tikz triangle

tikz-pgf

I am trying to draw the height line in Tikz. It should go from B and right down to the lower part of the triangle. But that isn't happening with the following MWE:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning, calc}

\begin{document}

\begin{tikzpicture}[scale=1.25]%,cap=round,>=latex]
   \coordinate [label=left:$A$] (A) at (-2cm,-1.cm);
   \coordinate [label=right:$C$] (C) at (2.2cm,-1.0cm);
   \coordinate [label=above:$B$] (B) at (1cm,1.0cm);
   \draw (A) -- node[sloped,above] {c} (B) -- node[sloped,above,] {a} (C) -- node[below] {b} (A);
   \draw[dashed] (B) -- (b) ;
\end{tikzpicture}

\end{document}

enter image description here

Best Answer

When line A--C is horizontal, like in this case, command

\draw[dashed] (B) -- (B|-A); 

will also draw triangle height without loading calc library.

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{positioning, calc}

\begin{document}

\begin{tikzpicture}[scale=1.25]%,cap=round,>=latex]
\coordinate [label=left:$A$] (A) at (-2cm,-1.cm);
\coordinate [label=right:$C$] (C) at (2.2cm,-1.0cm);
\coordinate [label=above:$B$] (B) at (1cm,1.0cm);
\draw (A) -- node[sloped,above] {c} (B) -- node[sloped,above,] {a} (C) -- node[below] {b} (A);
\draw[dashed] (B) -- (A-|B) ;

\end{tikzpicture}

\end{document}

enter image description here