开发者

Calculate path direction (azimuth) given starting and ending coordinates easily

开发者 https://www.devze.com 2023-03-09 23:51 出处:网络
I just trying know how to implement in objective c an equation that gave my position in lat, long and the position of a point in lat,long returns the relative angle to the azimuth so I will be able to

I just trying know how to implement in objective c an equation that gave my position in lat, long and the position of a point in lat,long returns the relative angle to the azimuth so I will be able to know when to paint this point knowing the azimuth. I also know more or less the equation but I don´t know how to do it in objective c: b = arccos ( cos (90 - lat2) * cos (90 - lat1) + sin (90 - lat2) * sin (90 - lat1) * cos (lon2 - lon1) ) A = 开发者_Go百科arcsin ( sin (90 - lat2) * sin (lon2 - lon1) / sin (b) )


Regarding turning that equation into Objecive-C.

'man cos' and 'man sin' say they take radians, so you'll have to convert your degree values to radians. The common method seems to be this, (90 * M_PI/180), where 90 is the degree value being converted.

The functions for arccos and arcsin are acos and asin respectively. I assume they to take radians. Their man pages don't explicitly say.

Read the man pages to learn which version of the above functions are appropriate for your case. For instance, sin has; sin(), sinl(), sinf().

0

精彩评论

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