Prove that an isometry on a subset of $\mathbb{R}^n$ is affine. Let $f:S\rightarrow \mathbb{R}^n$ be an isometry, where $S\subset \mathbb{R}^n$. Prove that there exist a matrix $A\in\mathbb{R}^{n\times n}$ such that $|\det A|=1$ and a vector $b\in \mathbb{R}^n$ such that $f(x)=Ax+b$ for all $x\in S$.
The second question I have is: What conditions must the set $S$ meet if the matrix $A$ and the vector $b$ are unique?
I suppose that the condition is: There exist $n+1$ points $s_1,\ldots,s_{n+1}\in S$ such that all of them don't lie in any hyperplane (i.e. $(n-1)$-dimensional affine subspace ). For example for $n=2$ there exist $s_1,s_2,s_3\in S$ which are vertices of a triangle. However, I don't know how to prove it.
 A: Let $s_0\in S$. Let $U$ be the linear subspace of $\Bbb R^n$ spanned by al $s-s_0$, $s\in S$.
Let $W$ be the linear subspace of $\Bbb R^n$ spanned by al $f(s)-f(s_0)$, $s\in S$.
Then we can pick a basis $u_1,\ldots, u_m$ of $U$ such that all $u_i$ are of the form $s_i-s_0$, $s_i\in S$.
If we let $w_i=f(s_i)-f(s_0)$ then the $w_i$ are also a basis of $W$.
Clearly, $|w_i|=|f(s_i)-f(s_0)|=|s_i-s_0|=|u_i|$ and
$|w_i-w_j|=|f(s_i)-f(s_j)|=|s_i-s_j|=|u_i-u_j|$.
From this we conclude equality of scalar products, $w_i\cdot w_j=u_i\cdot u_j$, and hence that the linear map $\phi\colon U\to W$ given by $v_i\mapsto w_i$ is an isometric linear isomorphism.
Lemma. $f(x)=\phi(x-s_0)+f(s_0)$ for all $x\in S$.
Proof. First of all note that $x-s_0\in U$ and $f(x)-f(s_0)\in W$.
Hence we can write
$$ x=s_0+\sum a_i u_i,\qquad f(x)=f(s_0)+\sum b_i w_i.$$
The $a_i$ can be determined by a few length measurements inside $S$:
We have  for $1\le k\le m$
$$\tag1\begin{align}|x-s_k|^2&=|x-s_0|^2+|s_k-s_0|^2+2(s_k-s_0)(x-s_0)\\
&=|x-s_0|^2+u_k^2+2\sum_{i=1}^ma_iu_iu_k\end{align}$$
As the Gram matrix for the $u_i$ is invertible, we can compute the $a_i$ from $(1)$. Moreover, the Gram matrix for the $w_i$ is the same, and of course also $|f(x)-f(s_0)|=|x-s_0|$ and $|f(x)-f(s_k)|=|x-s_k|$, which implies that the corresponding computation for the coefficients $b_i$ produces the same result. We conclude $f(x)-f(s_0)=\sum a_iw_i=\phi(\sum a_i u_i)=\phi(x-s_0)$. $\square$
Now let $U^\perp, W^\perp$ be the orthogonal complements of $U,W$.
From $\dim U=\dim W$ we have $\dim U^\perp=\dim W^\perp$, hence there esists an isometric linear isomorphism $\psi\colon U^\perp \to W^\perp$.
Let $A\colon \Bbb R^n=U\oplus U^\perp \to \Bbb R^n=W\oplus W^\perp$ be the linear map $u+u^\perp \mapsto \phi(u)+\psi(u^\perp)$. Then $A$ is an isomety, hence $|\det A|=1$. If we let $b=f(s_0)-As_0$ we obtain (using the lemma above)
$$ f(x)=Ax+b\qquad\text{for all }x\in S.$$

If $U^\perp$ (and $W^\perp$) has positive dimension (or equivalently, if $U$ is a proper subspace) then we have several choices for the isometry $\psi$ (e.g., replace $\psi$ with $-\psi$).
Hence uniqueness of $A$ and $b$ can hold only if $U=W=\Bbb R^n$.
To check this, assume $U=W=\Bbb R^n$and that also $f(x)=A'x+b'$ for all $x\in S$ with some other matrix $A'$ and vector $b'$.
Then $A'u_i=A'(s_i-s_0)=f(s_i)-f(s_0)=A(s_i-s_0)=Au_i$ for $1\le i\le m=n$.
As the $u_i$ form a basis of $\Bbb R^n$, we conclude that $A'=A$.
But then also
$b'=f(s_0)-A's_0=f(s_0)-As_0=b$.
We conclude that $A,b$ are uniquely determined if and only if $S$ is not contained in a proper affine subspace.
