Optimal results for autonomous attitude control using the potential function method