# Thread: How to calculate direction of a point A in respect to a given point B?

1. Hello,

I am working on an app where I have two points with their latitude and longitude values, say Point A and Point B. I know the distance between them as well. But I want to calculate in which direction the point B is in respect of point A.

After checking it on google, I came to know that what I am looking for is perhaps called Bearing. To calculate, Bearing itself, the Haversine formula can be used as mentioned at following sites:
http://www.movable-type.co.uk/scripts/latlong.html
http://www.ig.utexas.edu/outreach/go...h/latlong.html

Considering I have calculated bearing points (intial/final), my question is:
1) How to calculate direction (in East/West terms)?

If Bearing is not the right term which I should look for, then how should I find the direction?

Thanks a lot.

2. You need what the pages call "initial bearing".

3. Originally Posted by wizard_hu_
You need what the pages call "initial bearing".
But that's what I wanted to ask. How to determine direction from the bearing value which is given in terms of degrees, minutes & seconds?

For example, I tried to check my location (India) from Germany (near to) at the site http://www.movable-type.co.uk. The following figure shows me the direction. Now the initial bearing value is 75 degress which falls in 0-90 degees range, so should I consider it in North direction?
direction.jpg

I mean, it does not look right to me and not the accurate result as well.

4. You can determine the direction as how they have done here: http://www.packtpub.com/article/wind...ation-services

Though they calculate course, but i think meaning is somewhat same(so course from Germany to India implies heading East which is correct)

5. Originally Posted by vineet.jain
You can determine the direction as how they have done here: http://www.packtpub.com/article/wind...ation-services

Though they calculate course, but i think meaning is somewhat same(so course from Germany to India implies heading East which is correct)
As per their code, my example would result in West direction though it should be WS (west - south). It's not the accurate result but I guess it will work for me for the time being.

6. I do not know. Based on Wikipedia I approximated India with Point 1: 28, 77 (New Delhi, integer parts only), and Germany with Point 2: 52, 13 (Berlin, integer degrees again).
And the result is 5842 km, initial bearing 315 degrees. Seems to be correct to me.
(I am talking about http://www.movable-type.co.uk/scripts/latlong.html, by the way)

7. Ok Wizard. Will check it once again and revert back here.

Thanks to both of you.

8. I would go like this: atan2(latB-latA,lonB-lonA)
this would have a little error as LAT and LON doesn't measure the same in meters... I calculated for an application that 1"LAT/1"LON=102/73

so probably the right formula would be like this:
atan2(73*(latB-latA),102*(lonB-lonA))

also you have to keep in mind that the earth is round and from LON 1" to LON 350" is just 11" away and not 349"

9. I would do that too on a deserted island. However since the correct expression is available on the referred pages using spherical geometry, I would stay with that. And yes, after the spherical corrections, the last step indeed uses atan2 (http://www.movable-type.co.uk/script...g.html#bearing)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.