Paparazzi UAS  v5.14.0_stable-0-g3f680d1
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
pprz_geodetic.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2014 The Paparazzi Team
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
34 #ifndef PPRZ_GEODETIC_H
35 #define PPRZ_GEODETIC_H
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 #define ENU_OF_TO_NED(_po, _pi) { \
42  (_po).x = (_pi).y; \
43  (_po).y = (_pi).x; \
44  (_po).z = -(_pi).z; \
45  }
46 
47 #define LLA_ASSIGN(_pos,_lat,_lon,_alt){ \
48  (_pos).lat = (_lat); \
49  (_pos).lon = (_lon); \
50  (_pos).alt = (_alt); \
51  }
52 
53 #define LLA_COPY(_pos1,_pos2){ \
54  (_pos1).lat = (_pos2).lat; \
55  (_pos1).lon = (_pos2).lon; \
56  (_pos1).alt = (_pos2).alt; \
57  }
58 
59 #define LTP_DEF_COPY(_def1,_def2){ \
60  LLA_COPY((_def1).lla, (_def2).lla); \
61  VECT3_COPY((_def1).ecef, (_def2).ecef); \
62  RMAT_COPY((_def1).ltp_of_ecef, (_def2).ltp_of_ecef); \
63  (_def1).hmsl = (_def2).hmsl; \
64  }
65 
66 #define UTM_COPY(_u1, _u2) { \
67  (_u1).north = (_u2).north; \
68  (_u1).east = (_u2).east; \
69  (_u1).alt = (_u2).alt; \
70  (_u1).zone = (_u2).zone; \
71  }
72 
73 #define ENU_OF_UTM_DIFF(_pos, _utm1, _utm2) { \
74  (_pos).x = (_utm1).east - (_utm2).east; \
75  (_pos).y = (_utm1).north - (_utm2).north; \
76  (_pos).z = (_utm1).alt - (_utm2).alt; \
77  }
78 
79 #define NED_OF_UTM_DIFF(_pos, _utm1, _utm2) { \
80  (_pos).x = (_utm1).north - (_utm2).north; \
81  (_pos).y = (_utm1).east - (_utm2).east; \
82  (_pos).z = -(_utm1).alt + (_utm2).alt; \
83  }
84 
85 #define UTM_OF_ENU_ADD(_utm, _pos, _utm0) { \
86  (_utm).east = (_utm0).east + (_pos).x; \
87  (_utm).north = (_utm0).north + (_pos).y; \
88  (_utm).alt = (_utm0).alt + (_pos).z; \
89  }
90 
91 #define UTM_OF_NED_ADD(_utm, _pos, _utm0) { \
92  (_utm).east = (_utm0).east + (_pos).y; \
93  (_utm).north = (_utm0).north + (_pos).x; \
94  (_utm).alt = (_utm0).alt - (_pos).z; \
95  }
96 
97 #ifdef __cplusplus
98 } /* extern "C" */
99 #endif
100 
101 #endif /* PPRZ_GEODETIC_H */
102