locked
Geography between two points RRS feed

  • Question

  • How to count geographic cooridnate in the middle between two points? Probably, I can't use following equations:
    (g2.Lat - p1.Lat) / 2 + g1.Lat
    (g2.Long - p1.Long) / 2 + g1.Long
    where g1 and g2 are start and end of line.
    I have a linestring and I would like to animate pushpin's move on it.

     

    Saturday, July 12, 2008 5:30 PM

Answers

  • Your question is a little unclear - when you say you want to 'count' the co-ordinate in the middle between two points, do you mean that you want to find the co-ordinates of the point in the middle of the line that follows the great circle - the shortest distance between two points on a sphere?

    This is a little tricky, but it's certainly possible. For animating a pushpin, you can probably assume a spherical model of the Earth, rather than a more complex spheroidal or ellipsoidal model. In which case, you can follow the instructions here:
    http://www.astro.uu.nl/~strous/AA/en/reken/grootcirkel.html#2
    Sunday, July 13, 2008 7:20 PM
    Answerer
  • Hi Folks,

    If I understand the question correctly, you're looking for a way to generate new points along the edge between two given points.  Since we define edges as great circles in the sphere of directions, you can do this by taking a linear combination of the vectors that define each endpoint.

    To be a little more explicit...

    First, find the vectors that describe each end endpoint.  This really means converting lat/long to Cartesian coordinates, and will require a little trig.  This is left as an exercise for the reader (with aid from Wikipedia).

    Given these vectors P and Q, and a number 0<= x <=1, you can generate a new vector R that lies between them:

    R = xP + (1-x)Q    (remember: this is a vector equation)

    You can then convert the vector R back into latitude/longitude values.  By varying x, you can generate any arbitrary point on the edge.

    Cheers,
    -Isaac
    Monday, July 14, 2008 3:47 PM

All replies

  • No, yes and yes.

     

    No: mathematically there's an infinite number of points on a path between any two given points. Zeno's Paradox is example of this.

     

    Yes: Since we are dealing with Floating Point numbers, you couldn't actually compute points that are less than one angular epsilon in distance from each other.

     

    Yes: What you need to know is a relative velocity for the animation. If you know the distance between the points, a constant heading and the number of animation steps you want to take then this is mathematically possible. Its much easier for a straight-line path. You'll have to do some trig, of course.

     

    kt

    Saturday, July 12, 2008 8:33 PM
    Answerer
  • Your question is a little unclear - when you say you want to 'count' the co-ordinate in the middle between two points, do you mean that you want to find the co-ordinates of the point in the middle of the line that follows the great circle - the shortest distance between two points on a sphere?

    This is a little tricky, but it's certainly possible. For animating a pushpin, you can probably assume a spherical model of the Earth, rather than a more complex spheroidal or ellipsoidal model. In which case, you can follow the instructions here:
    http://www.astro.uu.nl/~strous/AA/en/reken/grootcirkel.html#2
    Sunday, July 13, 2008 7:20 PM
    Answerer
  • Is your pushpin going to be animated across a flat, 2d map? If so, you're going to have to project the results before you can use them anyway - it may be better to work with projected co-ordinates to start with, using the geometry datatype - then you CAN work out the midpoint of the line using your original calculations:
    (g2.X - g1.X) / 2 + g1.X
    (g2.Y - g1.Y) / 2 + g1.Y

    Just a suggestion...
    Sunday, July 13, 2008 9:51 PM
    Answerer
  • Hi Folks,

    If I understand the question correctly, you're looking for a way to generate new points along the edge between two given points.  Since we define edges as great circles in the sphere of directions, you can do this by taking a linear combination of the vectors that define each endpoint.

    To be a little more explicit...

    First, find the vectors that describe each end endpoint.  This really means converting lat/long to Cartesian coordinates, and will require a little trig.  This is left as an exercise for the reader (with aid from Wikipedia).

    Given these vectors P and Q, and a number 0<= x <=1, you can generate a new vector R that lies between them:

    R = xP + (1-x)Q    (remember: this is a vector equation)

    You can then convert the vector R back into latitude/longitude values.  By varying x, you can generate any arbitrary point on the edge.

    Cheers,
    -Isaac
    Monday, July 14, 2008 3:47 PM