2011-01-22 5 views
1

나는이 같은 목적 C 함수 toRadians를 사용하여 라디안 이중 변환하려고 :아이폰 toRadians의 toDegrees 컴파일러 문제

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

을하지만 toRadians 및 toDegrees

을의 컴파일러 경고 및 오류 또는 암시 적 선언을 점점 계속

나는 #import <math.h>을 포함 시켰지만 어떤 이유로 그 문제를 해결하지 못했습니다.

모든 도움을 주시면 대단히 감사하겠습니다.

답변

5

재단 수업에는 toRadians가 없습니다. 당신은 그냥 그렇지 않으면 당신은

#include <math.h>

0

해야합니다 그것을 수동으로

degrees * M_PI/180.0

재단의 수입은 그래서 당신은 M_PI있을 것이다 math.h이 코딩을 시도 변환 할 수 있습니다 : - 정도 (라디안)

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);