title: Rotate Arrow UIImage in a circle in objC
body: <p>I'm working on the iPad app, In which I have to rotate a arrow in a circle by touch. But I'm facing problems in it. The problem is in the angle calculation to which the image must be rotate. </p>
  
  <p>You can check it <a href="http://188.121.62.140/resturants/Rotate.jpg" rel="nofollow">here</a> . 
  I have to rotate the big red arrow image around the circle. Can anybody help me, How to get the angle of the touched point. Currently I'm using the following code, I found it at somewhere in the net. But it didn't rotate the arrow to the touched place. </p>
  
  <pre><code>- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
  {
      UITouch *oneTouch = [touches anyObject];
      CGPoint currentPoint = [oneTouch locationInView:imgCompass];    
  
      double current_angle = [self wheelAngleFromPoint:currentPoint]; 
      imgNeedle.transform = CGAffineTransformMakeRotation( current_angle );
  }
  
  - (double) wheelAngleFromPoint:(CGPoint)location
  {
      double retAngle;
  
      // subtract center of wheel 
  
      location.x -= (self.imgNeedle.bounds.size.width ) / 2.0;
      location.y = (self.imgNeedle.bounds.size.height )  / 2.0 - location.y;
  
  
      // normalize vector
      double vector_length = sqrt(location.x*location.x + location.y*location.y);
  
      location.x = location.x/vector_length;
      location.y = location.y/vector_length;
  
      retAngle = acos(location.y);
  
      float offset = 0.28;
      //if (location.x)
      //  offset = 0.28;
      retAngle += offset;
  
  
      if (location.x&lt;0)
      {
          retAngle = -retAngle;
      }
  
      return retAngle;
  }
  </code></pre>
  
  <p>Can anyone help me in correct angle calculation.</p>
  
  <p>Thanks</p>