Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 06-19-2009, 01:01 AM   #12 (permalink)
Launch
New Member
 
Join Date: Jun 2009
Posts: 5
Default

I may be wrong but you should be able to use the law of cosines. I drew up a crappy diagram in MS paint...
Yfrog - anglebetween.jpg

Use the north pole, find the distance between the north pole and point A, the north pole and point B, and between A and B. You are trying to find the angle marked by the X, or angle A. I'll call the sides opposite of A, a, and B, b, and the north pole is point C, so the side opposite that is c.

a^2 = b^2 + c^2 - 2bc Cos(A)

so A (the angle X in the diagram) is = arccos ((a^2-b^2-c^2)(-2bc))

And A will give you the bearing from the North, and keep in mind arccos doesn't give you negative angles (only 0 degrees to 180) so you will have to determine (easily) if the person is going west or east. So if you get 90 degrees from this, or pi/2 radians, see if point B is to the east of A or west of A, and if its east of A then the person is going directly east, and vice versa.

Last edited by Launch; 06-19-2009 at 01:04 AM.
Launch is offline   Reply With Quote
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 24,342
Threads: 39,136
Posts: 171,587
Top Poster: smasher (2,577)
Welcome to our newest member, gabrieljose
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:07 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.