Transformation of ECEF Coordinates to Geodetic Coordinates
Last updated:
The transformation from ECEF (Earth Centered Earth Fixed) coordinates to geodetic coordinates is a well-known problem in geodesy.
The rough transformation could be done by using arctan function, assuming that the Earth is a sphere.
However, for the realistic transformation, the Earth should be approximated by a spheroid, and the transformation in this case is not trivial.
ECEF Coordinate System and Geodetic Coordinate System
Let us first think about a point rsite on the Earth surface.
The Earth is approximated by a spheroid, which is axi-symmetric around the Earth rotation axis and slightly squashed in the north-south direction.
Thus, a point on the Earth surface can be described by Eq. (1).
Comparing Eq. (1) and Eq. (2), the following relationship can be found betwen φrd and φgc.
tanφgc=R⊕b⊕tanφrd
The next step is to find the relationship between φrd and φgd.
The tangential directions at the point rsite can be specified by differentiating rsite with respect to φrd and λ.
From the above equations, the normal direction at the point rsite can be obtained by
n=b⊕cosφrdcosλb⊕cosφrdsinλR⊕sinφrd
Based on the normal direction, the relationship between reduced latitude φrd and geodetic latitude φgd can be obtained.
tanφgd=b⊕R⊕tanφrd
From Eq. (3) and Eq. (7), the geocentric latitude φgc can be described by using the geodetic latitude φgd.
tanφgc=R⊕2b⊕2tanφgd
In this way, the transformation from geocentric parameters to geodetic parameters can be performed on the surface of the Earth.
However, as we are interested in the transformation of the on-orbit satellite position (x,y,z) to the geodetic parameters, some additional steps are required.
Now, the goal is to describe (x,y,z) with the geodetic parameters and then reversly solve the relation.
As the relationship between geodetic coordinates and ECEF coordinates is clarified, we proceed to the actual transformation.
The reference spheroid is WGS84, the shape of which is specified by the semi-major axis R⊕ and the flattening f⊕.
Regarding the geodetic latitude and altitude, it seems difficult to find the explicit analytic solution.
Thus, we try to find the solution by using a numerical method.
If we know the geodetic latitude φgd, the altitude hellp can be calculated by
For the initial value, we can use the geocentric latitude.
As an example, the following python script shows the transformation from ECEF coordinates to geodetic coordinates.
# WGS84 parametersflattening = 1/298.257223563semimajor = 6378.137eccentricity = np.sqrt(2*flattening - flattening**2)def geodetic_latitude(x, y, z): """ calculate the geodetic latitude # Args: x(ndarray): x coordinate in ECEF, km y(ndarray): y coordinate in ECEF, km z(ndarray): z coordinate in ECEF, km # Returns: latitude(ndarray): geodetic latitude, rad """ params = (x, y, z) latitude = np.arctan(z/ np.sqrt(x**2 + y**2)) return optimize.fsolve(latitude_equation, latitude, args=params)def latitude_equation(x: np.ndarray, *args) -> np.ndarray: """ equation to be solved # Args: *args(tuple): (x, y, z) # Returns: latitude(ndarray): latitude """ return args[2] - np.sqrt(args[0]**2 + args[1]**2) * np.tan(x) + eccentricity**2 * semimajor * np.sin(x) / np.sqrt(1 - eccentricity**2 * np.sin(x)**2)
Now, we understand the basics of the conversion from ECEF coordinates to geodetic parameters.
However, this numerical method requires a considerable amount of computation as the amount of data increases.
Therefore, we would like to use a more efficient method to calculate the geodetic parameters.
Vermeille’s Method
One of the more efficient methods is the method proposed by Vermeille [2].
In this method, the solution can be obtained analytically, by using quite technical parameter transformations.
Using these variables, we can formulate the 4th order polynomial equation (quartic equation) for k.
In general, quartic equations can be solved analytically, such as by using Ferrari’s method.
Vermeille’s method does not apply Ferrari’s method directly, but uses some similar transformations to find the factorized form.
k4+2e⊕2k3−(p+q−e⊕4)k2−2e⊕2qk−e⊕4q=0
Now, we introduce a new variable u. For any u, the following equation holds.
In Eq. (33), the inside of [⋯] is a quadratic polynomial with respect to k.
If we require that discriminant of this part equals zero, the condition of Eq. (34) is obtained.
If this condition is satisfied, the quadratic polynomial can be factorized into the form of (⋯)2, and then the entire equation can be factorized as well.
Then, the cubic equation with respect to u/r can be obtained.
r3u3−3r2u2−2s=0
We substitute Eq. (38), to obtain the equation with respect to t.
In the range of t>0, 1+t+1/t takes the minimum value of 3 at t=1.
When t=1, the left-hand side of Eq. (37) becomes −2s<0.
Therefore, there should be one solution in the range of 0<t<1, and another solution in the range of t>1.
ru=1+t+t1t6−2(1+s)t3+1=0
Focusing on real values, the following two solutions can be found.
As expected, one solution is in the range of 0<t<1, and the other is in the range of t>1.
t3t=1+s±s(2+s)=31+s±s(2+s)
Regardless of which solution is chosen, the value of u/r will be the same.
So we can choose whichever solution we like. For now, let us choose the solution with plus sign.
The second term in Eq. (33) is expressed in the square form.
The first bracket in Eq. (44) has no solution for k>0, because v−u, v, and q are all positive.
So we are interested in the second bracket.
Since u+v is positive, there is only one solution for k>0.
k=u+v+w2−w,wherew=e⊕22vu+v−q
As k has been determined, we can calculate the geodetic latitude φgd and the altitude hellp.
The original paper [2] lists the minimum equations required for the conversion.
By writing a simple script based on these equations, we can convert from ECEF coordinates to geodetic parameters.
# WGS84 parametersflattening = 1/298.257223563semimajor = 6378.137eccentricity = np.sqrt(2*flattening - flattening**2)def geodetic_vermeille(x, y, z): """ calculate the geodetic latitude and altitude based on H. Vermeille, "Direct transformation from geocentric to geodetic coordinates", 2002, Journal of Geodesy, 76:451-454 # Args: x(ndarray): x coordinate in ECEF, km y(ndarray): y coordinate in ECEF, km z(ndarray): z coordinate in ECEF, km # Returns: lat(ndarray): geodetic latitude, rad lon(ndarray): geodetic longitude, rad h(ndarray): geodetic altitude, km """ p = (x**2 + y**2)/semimajor**2 q = (1 - eccentricity**2) * z**2 / semimajor**2 r = (p + q - eccentricity**4)/6 s = eccentricity**4 * p * q / (4 * r**3) t = (1 + s + np.sqrt(s * (2 + s)))**(1/3) u = r * (1 + t + 1/t) v = np.sqrt(u**2 + eccentricity**4 * q) w = eccentricity**2 * (u + v - q)/(2 * v) k = np.sqrt(u + v + w**2) - w D = k * np.sqrt(x**2 + y**2)/(k + eccentricity**2) lat = 2 * np.arctan(z/(D+np.sqrt(D**2 + z**2))) lon = np.arctan2(y, x) h = (k + eccentricity**2 - 1)/k * np.sqrt(D**2 + z**2) return lat, lon, h
Reference
David A. Vallado, Fundamentals of Astrodynamics and Applications Fourth Edition, 2013, Microsoft Press
H. Vermeille, “Direct transformation from geocentric to geodetic coordinates”, 2002, Journal of Geodesy, 76:451-454, doi: 10.1007/s00190-002-0273-6.
MRG32k3a is one of the common algorithms for random number generation for parallel computing. In this article, we will implement the MRG32k3a algorithm on GPUs using WebGL2, with skip-ahead functionality.
Xorshift is one of the simplest and high-speed random number generator (RNG) algorithms. In this article, we explore the concept of Xorshift, and implement Rust code for searching valid Xorshift parameters for 32-bit binary.