Why are isometries all and only $f:\mathbb{R}^n \rightarrow \mathbb{R}^n $ :$f(x)=Nx+p$,where $N$ ortogonal A passage in my notes reads:

Isometries in metric spaces coincide with the usual ones when considering mappings $f:\mathbb{R}^n \rightarrow \mathbb{R}^m $  with the respective Euclidean metrics.
In particular, every isometry $f$ of $\mathbb{R}^n$ with itself is of the form $f(\vec{x})=N\vec{x} + \vec{p}$,where $N \in O(n)$ is an $n \times n$ orthogonal matrix and $\vec{p} \in\mathbb{R}^n.$

Can someone elaborate on this? Why do all isometries of $\mathbb{R}^n$ take  this form?
 A: I think this argument works but please correct me if wrong, or if I made any assumptions.
Consider the function $g(x) = f(x) - f(0)$. If we show that $g$ is a linear isometry, then we are done. The isometry is trivial. $$||g(x) - g(y)|| = ||f(x) - f(0) - f(y) + f(0)|| = ||f(x) - f(y)|| = ||x-y||$$
The tricky part is showing linearity. Okay so, we immediately have $g(0) = f(0) - f(0) = 0$ so that's great. Let's also note that $g$ preserves norms of vectors. Indeed $||g(x)|| = ||f(x) - f(0)|| = ||x-0|| = ||x||$.
How do we show $g(x+y) = g(x) + g(y)$? Let's try something slightly different. Let us show that $g(x-y) = g(x) - g(y)$. We can almost say it's the same as showing $g(x+y) = g(x) + g(y)$ but remember we haven't shown that $g$ respects scalar multiplication yet! Now consider a triangle in $\mathbb{R}^n$ with two sides $x$ and $y$ (starting at the origin). Then $x-y$ represents the third side of the triangle. So $x, y, x-y$ as points, get mapped to $g(x), g(y), g(x-y)$. Crucially, this is also a triangle "based" at the origin (since the line segment from $0$ to $x$ gets mapped to the line segment between $0$ and $g(x)$). Note that since $g$ is an isometry, the triangle formed by these three points is congruent to the one formed by $x, y, x-y$. But saying this is exactly saying that $g(x-y) = g(x) - g(y)$.
Great, we're almost there. If we want to show that $g(ax) = ag(x)$, we again use a similar argument as before. Consider points $x$ and $ax$. The relevant "triangle" (actually a line here) is formed by $x, ax$ and $(a-1)x$. This gets mapped to a line and so we have $g(ax)$ and $g(x)$ are collinear (with the orientations preserved i.e. if $a > 0$ then they point in the same direction, and if $a < 0$ then they point in opposite directions). But moreover we also know that $||g(ax)|| = ||ax|| = |a| ||x||$ so in fact it preserves the scaling factor. These two facts combined give us $g(ax) = ag(x)$.
So we have shown that $g$ is a linear isometry so it's of the form $Nx$ for some $N \in O(n)$. So $f(x) - f(0) = Nx \implies f(x) = Nx + f(0) = Nx + p$.
The gist is isometries take the triangle formed by two vectors to another triangle formed by two vectors, and they are congruent. This congruency implies linearity of the "shifted" function. Even more generally, isometries always preserves lengths and angles (so they preserve the dot product). In fact you can generalize this by saying that the group of isometries on any normed vector space $V$ (whose metric is induced by the norm) is equal to $V \rtimes O(V)$.
