I just started researching this topic and therefore I do not know much about it. Nonetheless, I am still curious about what determines the direction an object takes after passing by a planet. I think the new direction is most likely determined by the gravity of set planet and the new direction can be calculated using vectors. But I also think that the speed of the planet can have an influence in the new direction of the object. In both cases I believe that the new direction is found by adding vectors or by using Pythagora's. Can someone correct me?