我需要你的OS开发帮助。我有C#应用程序,我转换为Objective-C。 iOS返回不同的结果:
iOS中的结果:
GetHeading y:-0.000048
GetHeading x:-0.000087
iOS源代码:
double rlatitude1 = [self toRadians:startLocation.latitude];
double rlongitude1 = [self toRadians:startLocation.longitude];
double rlatitude2 = [self toRadians:endLocation.latitude];
double rlongitude2 = [self toRadians:endLocation.longitude];
double y = sin(rlongitude2- rlongitude1) * cos(rlatitude2);
NSLog([NSString stringWithFormat:@"GetHeading y: %f",y]);
double x = cos(rlatitude1) * sin(rlatitude2) - sin(rlatitude1) * cos(rlatitude2) * cos(rlongitude2 - rlongitude1);
NSLog([NSString stringWithFormat:@"GetHeading x: %f",x]);
iOS toRadiansCode:
+(double) toRadians:(double) degree
{
double retVal = (degree * 0.0174532925);
NSLog([NSString stringWithFormat:@"toRadians: %f",retVal]);
return retVal;
}