I'm trying to develop a simple 2D space game with no friction using corona-sdk. In the game, I have several planets which all applies forces to the player according to Newton's law of universal gravitation. Once the player is close enough to a planet, I need to put him in orbit. I do so, by creating a pivot joint between the planet and the player. From the player's liner velocity, I compute the joint's motor speed in order to achieve an as much as possible smooth cyclic rotation around the planet.
The solution, which might not be optimal (in future versions I would like to avoid completely the joint), so far is working but I'm not able to determine correctly the joint's rotation direction. The rotation of the player around the planet should be CW or CCW depending on the player's angle of approach. How do I compute that ?