A generalization of the distance formula It is well-known that the distance of a point (3D vector) $q$ from the plane $n \cdot ( r - r_0 ) = 0$ is given by
$d=\dfrac{ | n \cdot (q - r_0) | }{ \sqrt{ n \cdot n } } $​
In this problem, I seek a generalization of the formula to
$\mathbb{R}^n$, and to multiple hyperplanes.
So consider a point $q \in \mathbb{R}^n$, I want to find the point $x \in \mathbb{R}^n$ which satisfies $A x = b$, where $A$ is an $m \times n$ known matrix whose rows are the normals to $m$ hyperplanes, where $m \lt n $, and $b \in \mathbb{R}^{m} $ is a known vector of $ m $ constants.  Hence, $x$ lies on the intersection of $m$ hyperplanes, each described by:
$$ A_i x = b_i \hspace{48pt} , i = 1, ..., m $$
where $A_i$ is the $i$-th row of matrix $A$ and $b_i$ is the $i$-th element of vector $b$.
The problem is to determine the minimum distance between such an $x$ and point $q$ which is given.
The distance is assumed to be the Euclidean distance, given by,
$ d(x, q) = \sqrt{ (x - q)^T (x - q) }$

I guess you want to minimize $d(x,q)$ for a given $q$ where $x$ is a solution to $Ax=b$? Let $x_0$ be a solution to $Ax=b$. Then we get:
$$ x = x_0 + R$$
with $R$ in the kernel of $A$. Let’s assume that $x_0$ is orthogonal to the kernel (else we can repace $x_0$ by the projection onto the space created by the rows of $A$).
Then
$$ ||x-q||^2 = ||x_0+R - q ||^2 $$
If we set $q_p$ the projection of $q$ onto the rows of $A$ and $q_o=q-q_p$ so that $q_o$ is in the kernel of $A$ and $q_p$ is orthogonal to the kernel of $A$. Then we thus get
$$ ||x-q||^2 = ||x_0-q_p||^2 + ||R-q_o||^2$$
This is of course minimal if and only if $R=q_0$. Then the minimal distance is
$$ ||x_0-q_p|| $$
Now let’s assume that the rows $l_j$ in $A$ are all orthonormal (if they aren’t we can make them). Then $q_p$ is given by $\sum_j \langle q, l_j\rangle l_j$ and $x_0$ gets replaced by $\sum_j \langle x_0, l_j\rangle l_j$. This gives then the formula
$$ \sum_j | \langle x_0-q,l_j\rangle|$$
for the minimum distance.
In your original problem $A=n^T$ and $b=nr_0$. Assume $$||n||=1$$
Then $q_p = \langle q, n\rangle n$. Also $r=r_0$ is a solution to $Ax=b$. Then $x_0=\langle r_0,n\rangle n$. So we get: The minimal distance is
$$ || x_0-q_o || = || \langle r_0,n\rangle n - \langle q,n\rangle n || = | \langle r_0-q, n\rangle |$$
which is your initial formula.
