space navigation

Hi, i am trying to make a game where you have to collect thing while you are floating in space.
the idea is to a jetpack that thrust you in the opposite direction to where you tapped. just like satellite does to correct their trajectory. see the image attached. I have drawn only three options but the idea is that no matter where you tap the object moves in the opposite direction, not only up and down , left and right. but 360 degrees around the object.
 
 at the moment i am doing this, which is not far off, but I want every direction not just 4? plus this one has a problem that can be two things at the same time
 

if x \< groupAstronaut.x then &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; moveX=moveX+10 &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; else &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;moveX=moveX-10 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if y\< groupAstronaut.y then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;moveY=moveY+10 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;moveY=moveY-10 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;end groupAstronaut:setLinearVelocity(moveX, moveY) &nbsp;

also i want the object to rotate in that direction so I need somehow calculate the angle between the object and the tap and make the object rotate to that angle.

 
 
Anybody has any ideas?

Thanks.

i found a solution to my problem, probably not the most elegant.

function getImageRotation(x1,y1,x2,y2) &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;local deltaY = y2 - y1 &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;local deltaX = x2 - x1 &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;local angleInDegrees = (math.atan2( deltaY, deltaX)) &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;return &nbsp;math.floor(angleInDegrees\*57.2957795) +90 -- +90 is only to accomodate to my graphics that by default are pointing down. &nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;

the function above gives you the angle between your graphic and the touch point.

hope this helps somebody.

i found a solution to my problem, probably not the most elegant.

function getImageRotation(x1,y1,x2,y2) &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;local deltaY = y2 - y1 &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;local deltaX = x2 - x1 &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;local angleInDegrees = (math.atan2( deltaY, deltaX)) &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;return &nbsp;math.floor(angleInDegrees\*57.2957795) +90 -- +90 is only to accomodate to my graphics that by default are pointing down. &nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;

the function above gives you the angle between your graphic and the touch point.

hope this helps somebody.