我在2点A(100,100)和B(100,200)之间画了一条线,我想围绕A点旋转x度。显然,代码仅适用于45度。我尝试了90度,看起来有点不对劲。我希望有人能够指出什么是错的。
float newX = 100.0f;
float newY = 100.0f;
float newX1 = 100.0f;
float newY1 = 200.0f;
float degree = 90.0;
float x, y;
x = newX1;
y = newY1;
x -= newX;
y -= newY;
newX1 = (x * cos(degree)) - (y * sin(degree));
newY1 = (x * sin(degree)) + (y * cos(degree));
newX1 += newX;
newY1 += newY;
CGContextBeginPath(ctx);
CGContextMoveToPoint(ctx, newX, newY);
CGContextAddLineToPoint(ctx, newX1, newY1);
CGContextStrokePath(ctx);