The method is elaborated in IOGP Guidance Note 373-07-2, Oct 2018, Pg 100-104.
Let's assume the followings:
- G_phi, G_lam, G_eh be your Ground Station's lat, long, and ellipsoid height.
- P_phi, P_lam, P_eh be your Plane's lat, long, and ellipsoid height.
Next, let's compute the followings (from the Ground Station and Plane geodetic coordinates):
- Let gX, gY, gZ be the ECEF coordinates of your Ground Station.
- Let pX, pY, pZ be the ECEF coordinates of your Plane.
Your Ground Station's ENU coordinate is E=0, N=0, U=0. So there is nothing to compute.
Your Plane's ENU coordinates, relative to your Ground Station, is therefore (using the scalar form of the formula):-
- E = (-1)(pX - gX)(sin G_lam) + (pY - gY)(cos G_lam)
- N = (-1)(pX - gX)(sin G_phi * cos G_lam) - (pY - gY)(sin G_phi * sin G_lam) + (pZ - gZ)(cos G_phi)
- U = (pX - gX)(cos G_phi * cos G_lam) + (pY - gY)(cos G_phi * sin G_lam) + (pZ - gZ)(sin G_phi)
(All geodetic coordinates are in radians.)
Reply to Comment
@rdb is dealing with altitudes (referring to some geoid)...
Questioner stated "GPS lat, lon, and altitude". Usually, this means ellipsoidal height. Moreover - Questioner used a plane as an example, hence unlikely the height is orthometric. =)
but turning polar to rectangular like a sphere, so it is not easy to write a correct answer.
Questioner was describing his approach which was unsuccessful. However, his/her description is not to be confused as his/her requirement to arrive at the correct answer.
Section 2.2.2 details the formulas discussed in your answer, to convert geocentric coordinates to topocentric ones, but first geographic coordinates must be converted into geocentric (section 2.2.1).
This is correct. My answer jumped directly into the ECEF coordinates (i.e., gX/gY/gZ and pX/pY/pZ), making the assumption that the Questioner knows how to convert phi/lambda/eh to ECEF XYZ. Moreover, Method 2.2.2 is chosen because it is easier to explain (and much less to type).
Best Answer
You can get the [x y z] vector of each as follows:
Then subtract the vectors from each other. Make sure your lat and lon are expressed in radians.
Note that I have assumed a spherical model of the earth, which will yield very good answers in proportional terms — less than 0.3% worst case, based on a scratch-of-the-head "calculation", and much, much less for points that are within a few degrees of each other. If you need an answer that's good down to the meter regardless of the distance, you will need to use an ellipsoidal model, such as WGS 84 (thanks to @whuber for pointing this out). In that case, you can replace 6371000 with the equatorial radius, 6378137, and multiply z by (1 – 1/298.257223563).