Variational Characterization of the Metric Projection