Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Answer to title: Yes, CGAffineTransform can rotate more than 360 degrees just fine.<br> Answer to question: Yes, but you cannot animate it because there is nothing to animate.</p> <p>Remember that <a href="http://tinyurl.com/bp2e8x" rel="nofollow noreferrer">the affine transformation is a matrix</a>, and that a rotation matrix contains the sine and cosine numbers <em>precomputed</em>. It's as if you said:</p> <pre><code>CGFloat angle = 4.0 * M_PI; NSAffineTransformStruct matrix = { .m11 = cos(angle), .m12 = sin(angle), .m21 = -sin(angle), .m22 = cos(angle), .tx = 0.0, .ty = 0.0 }; NSAffineTransform *transform = [NSAffineTransform transform]; [transform setTransformStruct:matrix]; </code></pre> <p>Now, let's review some sample values for <code>cos</code> and <code>sin</code>:</p> <ul> <li><code>cos(0π)</code> = 1</li> <li><code>sin(0π)</code> = 0</li> <li><code>cos(2π)</code> = 1</li> <li><code>sin(2π)</code> = 0</li> <li><code>cos(4π)</code> = 1</li> <li><code>sin(4π)</code> = 0</li> </ul> <p>Remember, <strong>the matrix doesn't contain the angle -- it only contains the cosine and sine</strong>. And those values don't change from one multiple of a circle to another. Therefore, there is nothing to animate.</p> <p>(Note that Calculator.app gives wrong results for cos(xπ) and sin(xπ). Try Grapher, <a href="http://isthe.com/chongo/tech/comp/calc/" rel="nofollow noreferrer">calc</a>, or <a href="http://tinyurl.com/aztfkw" rel="nofollow noreferrer">Google</a>.) </p> <p>You will need to split the animation into fractions of a circle. The half-circles Brad Larson suggested will do just fine.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload