Paparazzi UAS  v5.8.2_stable-0-g6260b7c
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 
74 #define ENU_OF_UTM_DIFF(_pos, _utm1, _utm2) { \
75  (_pos).x = (_utm1).east - (_utm2).east; \
76  (_pos).y = (_utm1).north - (_utm2).north; \
77  (_pos).z = (_utm1).alt - (_utm2).alt; \
78  }
79 
80 #define NED_OF_UTM_DIFF(_pos, _utm1, _utm2) { \
81  (_pos).x = (_utm1).north - (_utm2).north; \
82  (_pos).y = (_utm1).east - (_utm2).east; \
83  (_pos).z = -(_utm1).alt + (_utm2).alt; \
84  }
85 
86 #define UTM_OF_ENU_ADD(_utm, _pos, _utm0) { \
87  (_utm).east = (_utm0).east + (_pos).x; \
88  (_utm).north = (_utm0).north + (_pos).y; \
89  (_utm).alt = (_utm0).alt + (_pos).z; \
90  }
91 
92 #define UTM_OF_NED_ADD(_utm, _pos, _utm0) { \
93  (_utm).east = (_utm0).east + (_pos).y; \
94  (_utm).north = (_utm0).north + (_pos).x; \
95  (_utm).alt = (_utm0).alt - (_pos).z; \
96  }
97 
98 #ifdef __cplusplus
99 } /* extern "C" */
100 #endif
101 
102 #endif /* PPRZ_GEODETIC_H */
103