Celestial mechanics via quaternions