Post · 1 min read· p. 67

geodetic2ecef

ahrs.common.frames.geodetic2ecef(lat: float, lon: float, h: float, a: float = 6378137.0, b: float = 6356752.3142) → ndarray : Transform geodetic coordinates to Rectangular (Cartesian) Coordinates in the Earth-Centered Earth-Fixed frame.

code
The cartesian coordinates of a point (xyz)\begin{pmatrix}x & y & z\end{pmatrix}
can be calculated from the geodetic coordinates
(ϕλh)\begin{pmatrix}\phi & \lambda & h\end{pmatrix} using the
following equations [[Wik15](/u/fab8b0a9fec670cf#id85)] [[ZHP11](/u/fab8b0a9fec670cf#id16)]
[[NKG13](/u/fab8b0a9fec670cf#id55)]:

x=(N+h)cos⁡ϕcos⁡λy=(N+h)cos⁡ϕsin⁡λz=((1−e2)N+h)sin⁡ϕ\begin{split}\begin{array}{rcl} x & = & (N + h) \cos\phi \cos\lambda \\ y & = & (N + h) \cos\phi \sin\lambda \\ z & = & \big(\left(1 - e^2\right)N + h\big) \sin\phi \end{array}\end{split}
where ϕ\phi is the latitude, λ\lambda is the longitude, hh is the height, and NN is the radius of curvature in the prime vertical at the given latitude ϕ\phi:
r=a1−e2sin⁡2ϕr = \frac{a}{\sqrt{1 - e^2 \sin^2\phi}}
The first eccentricity of the ellipsoid **squared**, e2e^2, is defined using the equatorial radius of the ellipsoid aa, and the polar radius of the ellipsoid bb:
e2=a2−b2a2e^2 = \frac{a^2-b^2}{a^2}
These values default to Earth’s ellipsoid. Parameters: : - **lat** (*float*) – Latitude, in degrees. - **lon** (*float*) – Longitude, in degrees. - **h** (*float*) – Height above ellipsoidal surface, in meters. - **a** (*float, default: 6378137.0*) – Ellipsoid’s equatorial radius (semi-major axis), in meters. Defaults to Earth’s. - **b** (*float, default: 6356752.3142*) – Ellipsoid’s polar radius (semi-minor axis), in meters. Defaults to Earth’s. Returns: : **X** – ECEF cartesian coordinates. Return type: : numpy.ndarray