A Second-Order Theory of Entry Mechanics Into a Planetary Atmosphere