Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid this degree to radian error?

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/

like image 484
Vijay Avatar asked Nov 22 '12 06:11

Vijay


People also ask

How do we convert degrees to radians?

How to Convert Degrees to Radians? The value of 180° is equal to π radians. To convert any given angle from the measure of degrees to radians, the value has to be multiplied by π/180.

Why might it be useful to convert degrees to radians?

You should use radians when you are looking at objects moving in circular paths or parts of circular path. In particular, rotational motion equations are almost always expressed using radians. The initial parameters of a problem might be in degrees, but you should convert these angles to radians before using them.


1 Answers

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);
like image 104
Midhun MP Avatar answered Sep 28 '22 00:09

Midhun MP