/** calculates the trajectory coordinates of the circle according to the coordinate point of the center, RADIUS, and the coordinate point where the current gesture is located * @param radius Circle radius * @param The coordinate point of the centercircle Center * @param currentpoint the current The coordinate point where the gesture is located * @return Cgpoint returns the coordinates of the circle*/+(Cgpoint) Circlepoint: (cgfloat) Radius withcentercircle: (cgpoint) centercircle withcurrentpoint: (CGPoint) Currentpoint;+(Cgpoint) Circlepoint: (cgfloat) Radius withcentercircle: (cgpoint) centercircle withcurrentpoint: (CGPoint) currentpoint{Cgpoint CPoint; CGFloat x=Currentpoint.x; CGFloat y=Currentpoint.y; CGFloat CX; //x-coordinate trajectory of a circleCGFloat CY;//y-coordinate trajectory of a circleCGFloat DaX;//The square of the distance from the center to the rotation button//CGFloat Day;CGFloat AX;//the distance from the center to the rotation button//cgfloat AY;CGFloat cosx;//cos value of the angle between the horizontal direction of the center and the rotation button//Square of the distance between the center and the touch Point (Pythagorean theorem)DaX = (x-centercircle.x) * (x-centercircle.x) + (y-centercircle.y) * (Y-centercircle.y); AX= sqrt (DaX);//Open Radicals//the distance between the center and the touch pointCosx = Fabs (x-centercircle.x)/ax;//Absolute ValueCX = Cosx*radius;//x =r * COSX; The value of the X of the center to the touch point in the horizontal coordinateCY = sqrt (radius*radius-cx*CX); if(x<centercircle.x)//If X's point is less than the center of the circle on the left side{CX= centercircle.x-CX; } Else{CX= centercircle.x +CX; } if(y<centercircle.y) {CY= Centercircle.y-CY; } Else{CY= Centercircle.y +CY; } cpoint.x=CX; Cpoint.y=CY; returnCPoint;}
IOS calculates the trajectory coordinates of a circle based on its coordinate point, radius, and coordinate point where the current gesture is located.