I am developing an iPhone application that will display both the North and Qibla directions. I am displaying the North direction with the aid of CLLocationManager and updating it with CLHeading as newHeading. magneticHeading, And using the following code, I am indicating the Qibla direction.
double A = MECCA_LONGITUDE - lon;
double b = 90.0 - lat;
double c = 90.0 - MECCA_LATITUDE;
NSLog(@"tan -1( sin(%f) / ( sin(%f) * cot(%f) - cos(%f) * cos(%f)))", A, b, c, b, A);
double qibAngle = atan(sin(A) /( sin(b) * (1 / tan(c)) - cos(b) * cos(A) ));
NSLog(@"qib Angle- %f",qibAngle);
qibla.transform = CGAffineTransformMakeRotation(qibAngle * M_PI /180);
I'm getting the angle here, but when I rotate the device, the angle does not change. Could someone please help me? I know that I need to do something with the title, but I'm not sure what.