Ballistic capture in the solar system