×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    India
    Posts
    1,173

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

    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. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,684

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

    You need what the pages call "initial bearing".

  3. #3
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    India
    Posts
    1,173

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

    Quote Originally Posted by wizard_hu_ View Post
    You need what the pages call "initial bearing".
    Thanks Wizard for your reply.
    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.
    Last edited by pooja_1650; 2013-02-11 at 11:26.

  4. #4
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,006

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

    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. #5
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    India
    Posts
    1,173

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

    Quote Originally Posted by vineet.jain View Post
    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)
    Thanks Vineet for the link.
    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. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,684

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

    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. #7
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    India
    Posts
    1,173

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

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

    Thanks to both of you.

  8. #8
    Nokia Developer Champion
    Join Date
    Feb 2011
    Location
    bucharest
    Posts
    149

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

    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. #9
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,684

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

    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)

Similar Threads

  1. Replies: 2
    Last Post: 2010-11-18, 15:28
  2. how to create Floating Point and Fixed point editor?
    By rohanwaugh in forum Symbian User Interface
    Replies: 5
    Last Post: 2008-12-18, 07:25
  3. BT point to point example cant work in 7650 and N'GAGE
    By cheemathew in forum Bluetooth Technology
    Replies: 1
    Last Post: 2004-02-24, 13:11
  4. Java/SMS/WAP - point me in the right direction!
    By jorich in forum General Development Questions
    Replies: 2
    Last Post: 2003-05-23, 08:09
  5. Java/SMS/WAP - point me in the right direction!
    By jorich in forum WAP Servers
    Replies: 1
    Last Post: 2003-05-12, 22:13

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×