Use spacedim in compute_transformation instead of incorrect dim