Metric formulae for nonconvex Hamilton-Jacobi equations and applications