The Hilbert projection theorem asserts that if $C$ is a closed convex subset of a Hilbert space $H$ and $x \in H$, there exists a unique $y \in C$ minimizing the distance to $x$. This theorem applied to $C$ which is a linear subspace can be used to derive a large portion of the elementary Hilbert space theory, e.g. all closed subspaces are complemented or Riesz representation theorem.
Could someone provide applications of the theorem in which a general $C$ is needed? (They do not have to be limited to abstract Hilbert space theory; examples involving concrete optimization problems from natural sciences etc. are welcome).