Another algorithm
actually i solved it in a different way.
i create 2 radius lengths:
1. movingRadius
2. rotatingRadius
now what i do is i check the distance between touch position (x,y) and center position (x/y) of the object.
if it is < movingRadius then object starts to move else if its < rotatingradius obj starts to rotate else (to far away from object = do nothing)
like this its more user friendly to move an object. instead of having the touch to be inside the physicbody now it can be outside but still filter unwanted touches.
the movingradius and rotatingradius has also a minimum value so if i use small objects you still get a good touch handling.
so i set the radius according to the object width or height (the bigger of both) like:
(lets take the rotating radius for example)
rotatingradius = max(max(obj.width/2,obj1.height/2),vpW*0.1)
so the rotating radius is the size of the bigger value between (obj.width/2 and obj.height/2) BUT NOT smaller then vpW*0.1 (10% of the screen width)
this is how i do it in my new iSpriteKit game.