# Line passing through a point and perpendicular to another one

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}[dot/.style={circle,inner sep=1pt,fill,label={#1},name=#1},
extended line/.style={shorten >=-#1,shorten <=-#1},
extended line/.default=1cm]

\node [dot=A] at (0,0) {};
\node [dot=B] at (3,1) {};
\node [dot=P] at (1.9,-1.6) {};

\draw [extended line=0.5cm] (A) -- (B);
\draw [extended line] ($(A)!(P)!(B)$) -- (P);

\fill [red] ($(A)!(P)!(B)$) circle [radius=2pt];

\end{tikzpicture}
\end{document}

You can use the calc library for this, which allows to do coordinate calculations. The expression ($(A)!(P)!(B)$) yields the projection of (P) on the line from (A) to (B), for example.

You can extend the lines by using the shorten > and shorten < commands with negative values. I’m using them here in a style called extended line that takes an optional argument to set the length by which to extend the line.