How to avoid this degree to radian error?
Asked Answered
K

3

10

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/

Kidderminster answered 22/11, 2012 at 6:43 Comment(0)
I
22

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);
Intrigant answered 22/11, 2012 at 6:54 Comment(1)
@VijayakumarNL: with pleasure :)Intrigant
B
0
#define RADIANS_TO_DEGREES(radians) ((radians) * (180.0 / M_PI))

write this code at top of your .m file where you want to convert

let me know whether is it working or not

Brey answered 22/11, 2012 at 6:52 Comment(0)
I
0

For simple angles, just use radians:

Transform3D transform = CATransform3DMakeRotation(2 * M_PI, 0, 0, 1);

A quick list of typical angles:

Degrees | Code
--------+---------
360     | 2 * M_PI
180     | M_PI
90      | M_PI_2
45      | M_PI_4
Insinuating answered 18/6, 2014 at 6:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.