Merged in f5soh/librepilot/LP-607_world_mag_model_2015v2 (pull request #526)
[librepilot.git] / flight / libraries / math / vectors.h
blobe2689a5fd74db13eb28f32aef7d6da6925f53bf5
1 /**
2 ******************************************************************************
3 * @addtogroup OpenPilot Math Utilities
4 * @{
5 * @addtogroup Reuseable vector data type and functions
6 * @{
8 * @file vectors.h
9 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2015.
10 * @brief Reuseable vector data type and functions
12 * @see The GNU Public License (GPL) Version 3
14 *****************************************************************************/
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 * for more details.
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #ifndef VECTORS_H_
32 #define VECTORS_H_
34 #include <math.h>
35 #include <stdint.h>
37 #define DECLAREVECTOR3(suffix, datatype) \
38 typedef struct Vector3##suffix##_t { \
39 datatype x; \
40 datatype y; \
41 datatype z; \
42 } Vector3##suffix
44 #define DECLAREVECTOR2(suffix, datatype) \
45 typedef struct Vector2##suffix##_t { \
46 datatype x; \
47 datatype y; \
48 } Vector2##suffix
51 DECLAREVECTOR3(i16, int16_t);
52 DECLAREVECTOR3(i32, int32_t);
53 DECLAREVECTOR3(u16, uint16_t);
54 DECLAREVECTOR3(u32, uint32_t);
55 DECLAREVECTOR3(f, float);
57 DECLAREVECTOR2(i16, int16_t);
58 DECLAREVECTOR2(i32, int32_t);
59 DECLAREVECTOR2(u16, uint16_t);
60 DECLAREVECTOR2(u32, uint32_t);
61 DECLAREVECTOR2(f, float);
63 #endif /* VECTORS_H_ */