Why does My Rotation only go Anti Clockwise when I want to go Clockwise?

core-animation, ios, objective-c

Solution

The angle is the same. To go full circle you need 2 * Pi, so half a circle is Pi. If you take -Pi it would end at the same point.

EDIT: If you need to make it turn clockwise you can go slightly off -Pi. Instead of -M_PI use -3.141593 for example.

Problem

``` [CATransaction begin]; [CATransaction setAnimationDuration:5]; CGAffineTransform currentTransform = squareLayer.affineTransform; CGFloat angle = M_PI; squareLayer.affineTransform = CGAffineTransformRotate(currentTransform, angle); [CATransaction commit]; ``` and ``` [CATransaction begin]; [CATransaction setAnimationDuration:5]; CGAffineTransform currentTransform = squareLayer.affineTransform; CGFloat angle = (M_PI * -1); squareLayer.affineTransform = CGAffineTransformRotate(currentTransform, angle); [CATransaction commit]; ``` I would have thought the -1 would have reversed the direction but apparently not?

Original source

Related problems