Real-Time Energy-Optimal Path Planning for Electric Vehicles