title: How to determine closest CGPoint with an angle and another CGPoint
body: <p>I calculate angle between two CGPoints :</p>
  
  <pre><code>//calculate radian and degree
              CGPoint diff = ccpSub(center, location);//return ccp(v1.x - v2.x, v1.y - v2.y);
              float rads = atan2f( diff.y, diff.x);
              float degs = -CC_RADIANS_TO_DEGREES(rads);
              NSLog(@"Rad %.2f Degs %.2f",rads,degs);
  </code></pre>
  
  <p>Now In another function where I have a pre known CGPoint and  the degree of above function, I want to calculate closest point that satisfies the degree.</p>
  
  <p>I was thinking about maybe below code would help me but in below code start point and rotation point is known, in my situation I only know start point.</p>
  
  <pre><code>-(void) rotateAroundPoint:(CGPoint)rotationPoint angle:(CGFloat)angle {
      CGFloat x = cos(CC_DEGREES_TO_RADIANS(-angle)) * (self.position.x-rotationPoint.x) - sin(CC_DEGREES_TO_RADIANS(-angle)) * (self.position.y-rotationPoint.y) + rotationPoint.x;
      CGFloat y = sin(CC_DEGREES_TO_RADIANS(-angle)) * (self.position.x-rotationPoint.x) + cos(CC_DEGREES_TO_RADIANS(-angle)) * (self.position.y-rotationPoint.y) + rotationPoint.y;
  </code></pre>
  
  <p><strong>Lets say I have a point 800,600 and I have a degree of 70, how can I calculate closest point with that point and that degree?</strong> </p>
  
  <p>EDIT:::</p>
  
  <p>Normally in my game sprites are moved with a button therefore all rotation,movement,speed etc are handled when button pressed <code>[sprite moveToPreGivenPostion:CGPoint]</code></p>
  
  <p>But now a compass is added and when user choose an angle on the compass I need to move the sprite in the direction of degree on compass, since <code>[sprite moveToPreGivenPostion:CGPoint]</code> already handles rotation and other stuff I just want to determine that what CGPoint should I send to <code>moveToPreGivenPostion</code> function. </p>