iPhone の GPS とコンパスを使用して、ある種のポインターを特定の場所に向けるアプリケーションを開発しようとしています (コンパスが常に北を指すように)。場所は固定されており、ユーザーがどこにいても、その特定の場所を指すポインターが常に必要です。私はこの場所の緯度/経度座標を持っていますが、コンパスと GPS を使用してその場所を指す方法がわかりません... http://www.youtube.com/watch?v=iC0Xn8hY80wこのリンク 1 のように: 20'
私はいくつかのコードを書いていますが、正しい方向に回転することはできません。
-(float) angleToRadians:(double) a {
return ((a/180)*M_PI);
}
-(void)updateArrow {
double alon=[longi doubleValue];//source
double alat=[lati doubleValue];//source
double blon=[pointlongi doubleValue];//destination
double blat=[pointlati doubleValue];//destination
float fLat = [self angleToRadians:alat];
float fLng = [self angleToRadians:alon];
float tLat = [self angleToRadians:blat];
float tLng = [self angleToRadians:blon];
float temp = atan2(sin(tLng-fLng)*cos(tLat),
cos(fLat)*sin(tLat)-sin(fLat)*cos(tLat)*cos(tLng-fLng));
double temp2= previousHeading;
double temp1=temp-[self angleToRadians:temp2];
/*I using this,but it can't rotate by :point even i change the coordinate
in CGPointMake */
Compass2.layer.anchorPoint=CGPointMake(0, 0.5);
[Compass2 setTransform:CGAffineTransformMakeRotation(temp1)];
/* Compass2 is a UIImageView like below picture I want to rotate it around
: point in image
^
|
|
|
:
|
*/