判断某点是否在圆圈内

  1. - (BOOL) pointInside:(CGPoint)point withEvent:(UIEvent *)event   
  2. {  
  3. CGPoint pt;  
  4. float HALFSIDE = SIDELENGTH / 2.0f;  
  5. // normalize with centered origin  
  6. pt.x = (point.x - HALFSIDE) / HALFSIDE;  
  7. pt.y = (point.y - HALFSIDE) / HALFSIDE;  
  8. // x^2 + y^2 = radius  
  9. float xsquared = pt.x * pt.x;  
  10. float ysquared = pt.y * pt.y;  
  11. // If the radius < 1, the point is within the clipped circle  
  12. if ((xsquared + ysquared) < 1.0return YES;  
  13. return NO;  
  14. }  

你可能感兴趣的:(判断某点是否在圆圈内)