I am looking at this equation that compute the distance from a point $x$ to a line defined by a point $p$ on the line and a normal vector $\hat{n}$ to that line.
$$ d(x,(p,n))=\|(x-p)\cdot {\hat {n}}\|=\|(x-p)^{\top }{\hat {n}}\|={\sqrt {(x-p)^{\top }{\hat {n}}{\hat {n}}^{\top }(x-p)}}. $$
However, I am having trouble understanding its derivation, I was hopping that someone would provide a more detailed explanation for how to derive it.