0
我有一個來自Core Location的座標,並且想要計算給定軸承和距離的座標,以km爲單位。根據度數和距離獲取新座標+1
我覺得這是這裏的公式。 http://www.movable-type.co.uk/scripts/latlong.html
公式:
LAT2 = ASIN(SIN(LAT1)* COS(d/R)+ COS(LAT1)* SIN(d/R)* COS(θ))
lon2 = lon1 + ATAN2(SIN(θ)* SIN(d/R)* COS(LAT1), COS(d/R)-sin(LAT1)* SIN(LAT2))
d/R是 的角距(以弧度爲單位), 其中d是行進距離, R是地球半徑
我有以下代碼。
CLLocationCoordinate2D linecoordstart;
linecoordstart = [[existingpoints objectAtIndex:i] coordinate];
NSString *bearing = [[existingpoints objectAtIndex:i] heading];
NSString *distance = [[existingpoints objectAtIndex:i] distance];
CLLocationCoordinate2D sourceCoordinate;
sourceCoordinate = [[existingpoints objectAtIndex:i] coordinate];
NSLog(@"%f,%f",sourceCoordinate.latitude,sourceCoordinate.longitude);
float lat2;
int d = 5;
int R = 6371;
lat2 = asin(sin(sourceCoordinate.latitude)cos(d/R) + cos(sourceCoordinate.latitude)sin(d/R)cos(180));
NSLog(@"%f",lat2);
我想能夠通過它是一個軸承,它是目前的NSString和距離。我無法弄清楚如何在我的生活中使用Math.h函數!