A geometrical approach for the resolution of an optimal control problem