Question

I am working on a application showing my heading and bearing to the location I want to go. I want to display a arrow direction to the direction user should have his heading to rich the desire location. There is nothing to get worry about this. What I want to do is I have degrees.. 0-360.

When I pass these degrees to the angle in bellow method this react strange. The Image get totate more than once. I tried to get radians from the degrees and than tried but no success.

All I want is I have float value range between 0-360 and I wanted to rotate my image only once a 369 degree rotation.

I have passed radians too. For converting degrees to radians I used:

float radian = degrees * M_PI / 180

But this is also having same issue. All I want is image show work like a compass for all 360 degrees.

How to get angle for this method:

CATransform3DRotate (CATransform3D t, CGFloat angle, CGFloat x, CGFloat y, CGFloat z)'

Thank you in advance

Was it helpful?

Solution

You should pass radians there. For example, this will rotate image on 180 degrees:

switcher.transform = CGAffineTransformMakeRotation(M_PI);

if you have problems with converting degrees to radians, you can use following macroses:

#define DegreesToRadians(degrees) (degrees * M_PI / 180)
#define RadiansToDegrees(radians) (radians * 180 / M_PI)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top