重複の可能性:
iPhone コンパス GPS 方向
こんにちは、iPhone の GPS とコンパスを使用して、ある種のポインターを特定の場所に向けるアプリケーションを開発しようとしています (コンパスが常に北を指すように)。場所は固定されており、ユーザーがどこにいても、その特定の場所を指すポインターが常に必要です。私はこの場所の緯度/経度座標を持っていますが、コンパスと GPS を使用してその場所を指す方法がわかりません... http://www.youtube.com/watch?v=iC0Xn8hY80wこのリンク 1 のように: 20' 私はすでにいくつかの手続き見出しを知っています = atan2( sin(lon2-lon1)*cos(lat2), cos(lat1)*sin(lat2) - sin(lat1)*cos(lat2)*cos(lon2-lon1) ) 次に 180/π を掛けてから、-(CLLocationDirection)directionToLocationCLLocati on *)location {
CLLocationCoordinate2D coord1 = self.coordinate; CLLocationCoordinate2D coord2 = location.coordinate;
CLLocationDegrees deltaLong = coord2.longitude - coord1.longitude; CLLocationDegrees yComponent = sin(deltaLong) * cos(coord2.latitude); CLLocationDegrees xComponent = (cos(coord1.latitude) * sin(coord2.latitude)) - (sin(coord1.latitude) * cos(coord2.latitude) * cos(deltaLong));
CLLocationDegrees ラジアン = atan2(yComponent, xComponent); CLLocationDegrees 度 = RAD_TO_DEG(ラジアン) + 360;
fmod(度、360)を返します。矢印を設定し、矢印を回転させたい。しかし、結果は正しくありません。また、現在の見出しは使用しません。矢印を回転させるには、現在の見出しを結果と組み合わせて使用する必要があると思います。
誰でも私にいくつかの解決策を教えてください。