How to avoid this degree to radian error?

Vijay picture Vijay · Nov 22, 2012 · Viewed 8.2k times · Source

While developing pie chart using core plot I added animation for that for given code

    CABasicAnimation *rotation = [CABasicAnimation animationWithKeyPath:@"transform"];
   CATransform3D transform = CATransform3DMakeRotation(DegreesToRadians(360), 0, 0, 1);
   rotation.toValue = [NSValue valueWithCATransform3D:transform];  
    rotation.duration = 10.0f;
    [pieChart addAnimation:rotation forKey:@"rotation"];    

This code gives following error Semantic Issue:

Implicit declaration of function 'DegreesToRadians' is invalid in C99

What can I do for avoid this?

And also run time it gives following error:

Apple_o  Linker id error  "_DegreesToRadians", referenced from:

Thanks and Regards

Vijayakumar

iOS Developer at Rhytha

https://rhytha.com/

Answer

Midhun MP picture Midhun MP · Nov 22, 2012

Just define a macro like:

#define DEGREES_RADIANS(angle) ((angle) / 180.0 * M_PI)

And change your method like:

CATransform3D transform = CATransform3DMakeRotation(DEGREES_RADIANS(360), 0, 0, 1);