开发者

iphone toRadians toDegrees compiler problem

I am trying to convert a double to radians using the Objective c function toRadians like this:

double oldLat = toRadians(oldLocation.coordinate.latitude);

but I keep getting a compiler warning and error or implicit declaration of toRadians and toDegrees

I included #import <math.h> but that didn't solve the problem for some reason.

any开发者_Go百科 help would be greatly appreciated.


There is no toRadians in the Foundation classes. You can just convert it manually

degrees * M_PI / 180.0

Foundation imports math.h so you'll have M_PI otherwise you'll have to

#include <math.h>


try this coding:- ( radian to degree)

location = [[CCDirector sharedDirector] convertToGL:location];

        // Determine offset of location to projectile
        int offX = location.x - PROJECTILE_POSITION_X;
        int offY = location.y - PROJECTILE_POSITION_Y;

                int realX = winSize.width + (PROJECTILE_WIDTH/2);
        float ratio = (float) offY / (float) offX;
        int realY = (realX * ratio) + PROJECTILE_POSITION_Y;

        int offRealX = realX - PROJECTILE_POSITION_X;
        int offRealY = realY - PROJECTILE_POSITION_Y;

        // Determine angle to face
        float angleRadians = atanf((float)offRealY / (float)offRealX);
        float angleDegrees =  (__angleRadians__)/((__angleRadians__) * 57.29577951f);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜