In the past, I used the XAffineTransform class from the GeoTools toolkit to extract rotation from an affine matrix. It works even when using zoom and shift.
This is a Java library, but you should easily convert it to (Objective-) C. You can see the source for XAffineTransform here . (The method is called getRotation.) And you can read the API here .
This is the basis of the method:
final double scaleX = getScaleX0(tr); final double scaleY = getScaleY0(tr) * flip; return Math.atan2(tr.getShearY()/scaleY - tr.getShearX()/scaleX, tr.getScaleY()/scaleY + tr.getScaleX()/scaleX);
You also need to implement the getScale / getShear methods. Not difficult. (For the most part, you can simply copy Java code as is.)
Felixyz
source share