Is it possible to get just the angle of rotation from a CGAffineTransform that also has translation and scaling values? If yes, how?
Thanks in advance!
atan2(rotationTransform.b, rotationTransform.d)
The acos(b) solution suggested by someone is only valid in the range +/-0.5pi. This solution seems robust under combinations of rotation, translation and scaling although almost certainly not shear. My earlier answer (atan2(rotationTransform.b, rotationTransform.a
) was not robust to scaling.
This duplicate was the basis for my original answer.
Take the asin() or acos() of the affine member b or c.
struct CGAffineTransform {
CGFloat a;
CGFloat b;
CGFloat c;
CGFloat d;
CGFloat tx;
CGFloat ty;
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With