Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 59x 59x 59x 59x 59x | /** Earth-centred, Earth-fixed Cartesian coordinates on WGS84. */
import { DEG, type LatLon, WGS84, e2 } from '../../geo/ellipsoid'
export function toEcef(
{ lat, lon }: LatLon,
height = 0,
): { x: number; y: number; z: number } {
const phi = lat * DEG
const lam = lon * DEG
const sinPhi = Math.sin(phi)
const N = WGS84.a / Math.sqrt(1 - e2 * sinPhi * sinPhi)
return {
x: (N + height) * Math.cos(phi) * Math.cos(lam),
y: (N + height) * Math.cos(phi) * Math.sin(lam),
z: (N * (1 - e2) + height) * sinPhi,
}
}
|