Optimal terminal dimensionality reduction in Euclidean space