views:

395

answers:

1

I have the following function that I am so close to cracking but can't find a mod function in obj-c. I hope someone can help suss this.

-(void)estimatePosition{
    float lat1 = 50.000;
    float lon1 = -1.666;
    float d = 500;
    float tc = 90;

    float lat;
    float dlon;
    float lon;

    lat =asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc));
    dlon=atan2(sin(tc)*sin(d)*cos(lat1),cos(d)-sin(lat1)*sin(lat));
    lon=mod(lon1-dlon +M_PI,2*M_PI )-M_PI;
}
+4  A: 

Since %-operator is only for integers you should use fmod() or fmodf() from <math.h>

stacker
Thank you, sorted!
Lee Armstrong