I've done a degrees to radians conversion before running the expression, and a radians to degrees conversion afterwards, and I'm getting no more errors. I'm not getting the correct answer, but it's progress.
It's not a Google Maps app right now, rather just a quick proof-of-concept thing. (Proof that I can do it!) It may morph into one in the future...:) Thanks, JS James Keeline wrote: >>Jamey Saunders wrote: >> >> >>>I have a bit of a problem with a pretty complicated mathematical >>>expression. Basically, I'm trying to determine the initial heading >>>between two points on the globe using latitude and longitude of the >>>two points. I already know the distance between the two ($miles). >>> >>>Here's the expression: >>> >>> >$Hdg=2*M_PI-acos((sin($lat2)-sin($lat1)*cos($miles))/(sin($miles)*cos($lat1))); > > >>>When I echo $Hdg, I see: >>> >>>-1.#IND >>> >>>If the expression was working, I should see something like 134.9 for >>>the following latitude/longitude combinations: >>> >>>$lat1 = 33.9780761 >>>$lon1 = -83.9623772 >>>$lat2 = 32.1950556 >>>$lon2 = -81.8695556 >>>$miles = 172.7381359 >>> >>>I can't find any references to what #IND means, so if anyone out there >>>has any ideas, I'd be grateful. >>> >>>-JS >>> >>> > > >--- Brian Cummiskey <[EMAIL PROTECTED]> wrote: > > >>Only thing i can thinkg of off the top of my head is that you are trying >>to plug in degrees and minuets, but the sin,cos, and other trig >>functions in php take on a parameter in radians-- not degrees. >> >> > > >Degrees vs. radians can certainly be a factor. Make sure you are giving the >functions a value in radians. > >Also, you have this item: > > 2*M_PI > >Have you defined a constant called M_PI or do you expect it to be a variable? > >Here are some links which may be helpful for determing the bearing (or heading) >between two latitude and longitude points: > > http://www.movable-type.co.uk/scripts/LatLong.html > > http://mathforum.org/library/drmath/view/55417.html > >This sounds like a Google Map application :) > >James >_____ > > >James D. Keeline >http://www.Keeline.com http://www.Keeline.com/articles >http://Stratemeyer.org http://www.Keeline.com/TSCollection > >http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc. >Fall Semester Begins Sep 7 -- New Classes Start Every Few Weeks. > > > >Community email addresses: > Post message: [email protected] > Subscribe: [EMAIL PROTECTED] > Unsubscribe: [EMAIL PROTECTED] > List owner: [EMAIL PROTECTED] > >Shortcut URL to this page: > http://groups.yahoo.com/group/php-list >Yahoo! Groups Links > > > > > > > > > ------------------------ Yahoo! Groups Sponsor --------------------~--> Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life. http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/HKFolB/TM --------------------------------------------------------------------~-> Community email addresses: Post message: [email protected] Subscribe: [EMAIL PROTECTED] Unsubscribe: [EMAIL PROTECTED] List owner: [EMAIL PROTECTED] Shortcut URL to this page: http://groups.yahoo.com/group/php-list Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/php-list/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
