Here is a function that uses the same format as the CoreGraphics CGAffineTransform API format.
This works exactly the way other RotateAt () APIs should work.
The operation is the equivalent of the following specification: translate (pt.x, pt.y); rotate (angle); translate (-pt.x, -pt.y);
CGAffineTransform CGAffineTransformMakeRotationAt(CGFloat angle, CGPoint pt){
const CGFloat fx = pt.x, fy = pt.y, fcos = cos(angle), fsin = sin(angle);
return CGAffineTransformMake(fcos, fsin, -fsin, fcos, fx - fx * fcos + fy * fsin, fy - fx * fsin - fy * fcos);
}
As with CGAffineTransformMakeRotation(), the angle is in radians, not degrees.
source
share