坐标系转换,并判断点是否在圆内

2016-01-15  本文已影响111人  MindTheGap

CGFloat x1,y1;

x1=0;y1=0;

int l = self.frame.size.width;//直径

int r = l/2;

if (point.x<r && point.y<r){

x1 = point.x - r;

y1 = r - point.y;}

if (point.x>r && point.y<r){

x1 = point.x - r;

y1 = r - point.y; }

if (point.x<r && point.y>r) {

x1 = point.x-r;

y1 = r - point.y;}

if (point.x>r&& point.y>r) {

x1 = point.x - r;

y1 = r - point.y;}

if (x1*x1+y1*y1<r*r){

 return YES;

}else{

return NO;

}

 

上一篇下一篇

猜你喜欢

热点阅读