Calculation of the distance between 2 coordinates of GPS in meters


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2006
    Location
    Brasil, Sao Paulo, Campinas
    Posts
    54

    Default Calculation of the distance between 2 coordinates of GPS in meters

    Hello,

    I have a project using a GPS module in my car e now I want to improve it adding a new option... I want to know if I am near of some known poitns as radars of speeds of the roads then I thought about calculating in the distance between known LA/LON of the current LAT/LON and to test if this value is greater that one determined ray, for example 30 meters.
    As I want I covered an area relatively small I I thought about transforming degree, minute and seconds of the coordinates format of my gps ('$GPRMC,151805.812,A,2241.6835,S,04700.3015,W,0.0 0,,131206,,*1F ) in degrees and then to find the difference using the theorem of pitagoras: square shaped root of x^2+y^2, where x is lat1-lat2 and y is long1-long2. I have all datas in arrays (Lat var byte[9]: Lon var byte[10]).
    To convert I think it: GRAUs = GRAUS+(MIN/60)+((.mmmm*60)/3600). Finally I multiply the value in degrees of the difference of the 2 coordinates for the value of 111120 meters (ray of the planet in the Equator), to only have an approach value. I also can search the accurate value of a degree in my region!
    Somebody can help with some algorithm to only decide this problem using word and byte variables?

    Thanks

    Pimentel
    Last edited by Pimentel; - 26th June 2009 at 22:59.

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Hello Pimentel,

    You can use atan2 to find the angle heading from one lat/lon to another lat/lon coordinate. PicBasic doesn't include that math function, but you can use an assembly include file to perform a cordic equation for atan2. If you do a search on cordic in this forum, you will find one include for PIC16 devices, and one for PIC18 devices. There is also a trick to convert longitude to an adjusted value based on the cosine of current lat. I will explain a little more about this later.

    Here is a link explaining how to use the PIC16 trig include file with lat/lon. In it you will find a link for the cordic trig include file thread.

    http://www.picbasic.co.uk/forum/show...1216#post71216

    -Walter
    http://www.scalerobotics.com

Similar Threads

  1. GPS decoding problems
    By vladimir059@hot in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 25th February 2012, 10:57
  2. GPS $GPRMC to PIC16F684. Need help with SERIN2
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 27th November 2009, 09:47
  3. Optimizing DIV
    By skimask in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 22nd September 2008, 04:58
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. GPS waypoint distance in Km
    By Art in forum Code Examples
    Replies: 1
    Last Post: - 28th August 2005, 01:59

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

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