Formula for CGPointApplyAffineTransform function in iOS
I am trying to affine rotate matrix in Android based on iOS Code
iOS has two functions CGAffineTransformMakeRotation and CGPointApplyAffineTransform used for calculation
Step 1: CGAffineTransformMakeRotation(); Input: 2.2860321998596191 Result: a = -0.65579550461444569, b = 0.75493857771840255, c = -0.75493857771840255, d = -0.65579550461444569, tx = 0, ty = 0 Formula: double A = Math.cos(RadiansRotated); double B = -Math.sin(RadiansRotated); double C = Math.sin(RadiansRotated); double D = Math.cos(RadiansRotated);
I am able to calculate a,b,c,d for step 1 using above formula
Step 2: CGPointApplyAffineTransform() Input : x = 612.55191924649432, y = -391.95960729287646 And Matrix return from Step 1 Result: x = -105.80336653205421, y = 719.48442314773808
Does anyone know the formula used in ApplyAffineTransform?
I need help for Step 2
I have tried with Android's Matrix class - Not Working
I have also tried with Java's AffineTransform - Not working
The math behind the CGAffineTransform functions is described in “The Math Behind the Matrices” in the Quartz 2D Programming Guide.
The formulae for transforming a point using an affine transform are given as:
x' = ax + cy + tx y' = bx + dy + ty
Incidentally, in your step 1, you have reversed the signs of b and c, which has the effect of reversing the direction of rotation.