Legendre transformation and analytical mechanics: A geometric approach