MRTKLIB 0.7.14
Modernized GNSS Positioning Library
Loading...
Searching...
No Matches
mrtk_coords.h
Go to the documentation of this file.
1/*------------------------------------------------------------------------------
2 * mrtk_coords.h : coordinate transformation functions
3 *
4 * Copyright (C) 2026 H.SHIONO (MRTKLIB Project)
5 * Copyright (C) 2023-2025 Cabinet Office, Japan
6 * Copyright (C) 2024-2025 Lighthouse Technology & Consulting Co. Ltd.
7 * Copyright (C) 2023-2025 Japan Aerospace Exploration Agency
8 * Copyright (C) 2023-2025 TOSHIBA ELECTRONIC TECHNOLOGIES CORPORATION
9 * Copyright (C) 2015- Mitsubishi Electric Corp.
10 * Copyright (C) 2014 Geospatial Information Authority of Japan
11 * Copyright (C) 2014 T.SUZUKI
12 * Copyright (C) 2007-2023 T.TAKASU
13 *
14 * SPDX-License-Identifier: BSD-2-Clause
15 *----------------------------------------------------------------------------*/
16/**
17 * @file mrtk_coords.h
18 * @brief MRTKLIB Coordinates Module — Coordinate transformations and geometry.
19 *
20 * This header provides coordinate transformation functions (ECEF, geodetic,
21 * ENU), rotation matrices, degree/DMS conversions, ECI-to-ECEF transformation,
22 * and positioning geometry functions (geometric distance, satellite azimuth/
23 * elevation, DOP computation).
24 *
25 * @note All functions in this module are pure cut-and-paste extractions
26 * from rtkcmn.c with zero algorithmic changes.
27 */
28#ifndef MRTK_COORDS_H
29#define MRTK_COORDS_H
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
36#include "mrtklib/mrtk_mat.h"
37#include "mrtklib/mrtk_time.h"
38
39/*============================================================================
40 * Degree / DMS Conversions
41 *===========================================================================*/
42
43/**
44 * @brief Convert degree to degree-minute-second.
45 * @param[in] deg Degree
46 * @param[out] dms Degree-minute-second {deg, min, sec}
47 * @param[in] ndec Number of decimals of second
48 */
49void deg2dms(double deg, double* dms, int ndec);
50
51/**
52 * @brief Convert degree-minute-second to degree.
53 * @param[in] dms Degree-minute-second {deg, min, sec}
54 * @return Degree
55 */
56double dms2deg(const double* dms);
57
58/*============================================================================
59 * ECEF / Geodetic Conversions
60 *===========================================================================*/
61
62/**
63 * @brief Transform ECEF position to geodetic position.
64 * @param[in] r ECEF position {x, y, z} (m)
65 * @param[out] pos Geodetic position {lat, lon, h} (rad, m)
66 * @note WGS84, ellipsoidal height.
67 */
68void ecef2pos(const double* r, double* pos);
69
70/**
71 * @brief Transform geodetic position to ECEF position.
72 * @param[in] pos Geodetic position {lat, lon, h} (rad, m)
73 * @param[out] r ECEF position {x, y, z} (m)
74 * @note WGS84, ellipsoidal height.
75 */
76void pos2ecef(const double* pos, double* r);
77
78/*============================================================================
79 * ENU / ECEF Transformations
80 *===========================================================================*/
81
82/**
83 * @brief Compute ECEF to local coordinate transformation matrix.
84 * @param[in] pos Geodetic position {lat, lon} (rad)
85 * @param[out] E ECEF to local coord transformation matrix (3x3)
86 * @note Matrix stored by column-major order (Fortran convention).
87 */
88void xyz2enu(const double* pos, double* E);
89
90/**
91 * @brief Transform ECEF vector to local tangential coordinate.
92 * @param[in] pos Geodetic position {lat, lon} (rad)
93 * @param[in] r Vector in ECEF coordinate {x, y, z}
94 * @param[out] e Vector in local tangential coordinate {e, n, u}
95 */
96void ecef2enu(const double* pos, const double* r, double* e);
97
98/**
99 * @brief Transform local tangential coordinate vector to ECEF.
100 * @param[in] pos Geodetic position {lat, lon} (rad)
101 * @param[in] e Vector in local tangential coordinate {e, n, u}
102 * @param[out] r Vector in ECEF coordinate {x, y, z}
103 */
104void enu2ecef(const double* pos, const double* e, double* r);
105
106/**
107 * @brief Transform ECEF covariance to local tangential coordinate.
108 * @param[in] pos Geodetic position {lat, lon} (rad)
109 * @param[in] P Covariance in ECEF coordinate
110 * @param[out] Q Covariance in local tangential coordinate
111 */
112void covenu(const double* pos, const double* P, double* Q);
113
114/**
115 * @brief Transform local ENU covariance to ECEF coordinate.
116 * @param[in] pos Geodetic position {lat, lon} (rad)
117 * @param[in] Q Covariance in local ENU coordinate
118 * @param[out] P Covariance in ECEF coordinate
119 */
120void covecef(const double* pos, const double* Q, double* P);
121
122/*============================================================================
123 * ECI / ECEF Transformation
124 *===========================================================================*/
125
126/**
127 * @brief Compute ECI to ECEF transformation matrix.
128 * @param[in] tutc Time in UTC
129 * @param[in] erpv ERP values {xp, yp, ut1_utc, lod} (rad, rad, s, s/d)
130 * @param[out] U ECI to ECEF transformation matrix (3x3)
131 * @param[in,out] gmst Greenwich mean sidereal time (rad) (NULL: no output)
132 * @note Not thread-safe (uses static cache).
133 */
134void eci2ecef(gtime_t tutc, const double* erpv, double* U, double* gmst);
135
136/*============================================================================
137 * Positioning Geometry
138 *===========================================================================*/
139
140/**
141 * @brief Compute geometric distance and receiver-to-satellite unit vector.
142 * @param[in] rs Satellite position (ECEF at transmission) (m)
143 * @param[in] rr Receiver position (ECEF at reception) (m)
144 * @param[out] e Line-of-sight vector (ECEF)
145 * @return Geometric distance (m) (<0: error/no satellite position)
146 * @note Distance includes Sagnac effect correction.
147 */
148double geodist(const double* rs, const double* rr, double* e);
149
150/**
151 * @brief Compute satellite azimuth/elevation angle.
152 * @param[in] pos Geodetic position {lat, lon, h} (rad, m)
153 * @param[in] e Receiver-to-satellite unit vector (ECEF)
154 * @param[in,out] azel Azimuth/elevation {az, el} (rad) (NULL: no output)
155 * (0.0<=azel[0]<2*pi, -pi/2<=azel[1]<=pi/2)
156 * @return Elevation angle (rad)
157 */
158double satazel(const double* pos, const double* e, double* azel);
159
160/**
161 * @brief Compute DOP (dilution of precision).
162 * @param[in] ns Number of satellites
163 * @param[in] azel Satellite azimuth/elevation angle (rad)
164 * @param[in] elmin Elevation cutoff angle (rad)
165 * @param[out] dop DOPs {GDOP, PDOP, HDOP, VDOP}
166 * @note dop[0]-[3] return 0 in case of DOP computation error.
167 */
168void dops(int ns, const double* azel, double elmin, double* dop);
169
170#ifdef __cplusplus
171}
172#endif
173
174#endif /* MRTK_COORDS_H */
double geodist(const double *rs, const double *rr, double *e)
Compute geometric distance and receiver-to-satellite unit vector.
void enu2ecef(const double *pos, const double *e, double *r)
Transform local tangential coordinate vector to ECEF.
void pos2ecef(const double *pos, double *r)
Transform geodetic position to ECEF position.
double satazel(const double *pos, const double *e, double *azel)
Compute satellite azimuth/elevation angle.
void xyz2enu(const double *pos, double *E)
Compute ECEF to local coordinate transformation matrix.
void covecef(const double *pos, const double *Q, double *P)
Transform local ENU covariance to ECEF coordinate.
void covenu(const double *pos, const double *P, double *Q)
Transform ECEF covariance to local tangential coordinate.
void eci2ecef(gtime_t tutc, const double *erpv, double *U, double *gmst)
Compute ECI to ECEF transformation matrix.
void deg2dms(double deg, double *dms, int ndec)
Convert degree to degree-minute-second.
Definition mrtk_coords.c:63
void dops(int ns, const double *azel, double elmin, double *dop)
Compute DOP (dilution of precision).
void ecef2pos(const double *r, double *pos)
Transform ECEF position to geodetic position.
double dms2deg(const double *dms)
Convert degree-minute-second to degree.
Definition mrtk_coords.c:86
void ecef2enu(const double *pos, const double *r, double *e)
Transform ECEF vector to local tangential coordinate.
MRTKLIB Foundation — Common types, standard includes, and system constants (MAXSAT,...
MRTKLIB Matrix Module — Matrix/vector operations and estimation.
MRTKLIB Time Module — GNSS time types and conversion functions.
GNSS time representation.
Definition mrtk_time.h:49