How to use linear interpolation estimate current position between two Geo Coordinates?

前端 未结 2 569
日久生厌
日久生厌 2020-12-10 06:03

I have the following available:

  • last reported lat,lon w/timestamp
  • target lat,lon
  • estimated time to target
  • heading

How

2条回答
  •  离开以前
    2020-12-10 06:42

    You want to use a Slerp, or spherical linear interpolation.

    Convert your latitude and longitude to a unit 3-vector:

    p=(x,y,z)=(cos(lon)*cos(lat), sin(lon)*cos(lat), sin(lat))
    

    Then, "Slerp" gives you a constant-velocity interpolation along the surface of the unit sphere:

    theta= angle between 3-vectors p0 and p1 (e.g., cos(theta)= p0.p1)
    Slerp(p0,p1,t)= ( p0*sin((1-t)*theta) + p1*sin(t*theta) ) / sin(theta)
    

    Note that if theta is very close to 0 or 180 degrees, this formula can be numerically unstable. In the small-angle case, you can fall back to linear interpolation; in the 180 degree case, your path is genuinely ambiguous.

提交回复
热议问题