Transfer point to ios corner

my code is disabled here - it should rotate a point around the source, and then translate back

    angle = angle * M_PI / 180;
point1.x = (point1.x) * cos(angle) - (point1.y) * sin(angle);
point1.y = (point1.x) * sin(angle) + (point1.y) * cos(angle);

and after that, to translate the point where it should β€œmove”, the condition will be indicated on the basis of which quadrant the point after β€œrotation” - for example, if it is at 1, x + = 2 * x and y + = 2 * y. The problem here is in rotation: for example, for an angle of 130 degrees, for the point (100 100), here are the coordinates of the new point x: CGFloat-3.09086e-06, y: CGFloat100. What am I doing wrong?

+4
source share
1 answer

point1.y, point1.x. , :

angle = angle * M_PI / 180;
CGPoint result = CGPointZero;
result.x = (point1.x) * cos(angle) - (point1.y) * sin(angle);
result.y = (point1.x) * sin(angle) + (point1.y) * cos(angle);

result .

+4

All Articles