23 #define sq(x) ((x)*(x))
27 #define FAST_TRIGONOMETRY // order 9 approximation
31 #define M_PIf 3.14159265358979323846f
33 #define RAD (M_PIf / 180.0f)
35 #define MIN(a, b) ((a) < (b) ? (a) : (b))
36 #define MAX(a, b) ((a) > (b) ? (a) : (b))
37 #define ABS(x) ((x) > 0 ? (x) : -(x))
72 int constrain(
int amt,
int low,
int high);
73 float constrainf(
float amt,
float low,
float high);
81 int scaleRange(
int x,
int srcMin,
int srcMax,
int destMin,
int destMax);
82 float scaleRangef(
float x,
float in_min,
float in_max,
float out_min,
float out_max);
94 #if defined(FAST_MATH) || defined(VERY_FAST_MATH)
99 #define tan_approx(x) (sin_approx(x) / cos_approx(x))
101 #define sin_approx(x) sinf(x)
102 #define cos_approx(x) cosf(x)
103 #define atan2_approx(y,x) atan2f(y,x)
104 #define acos_approx(x) acosf(x)
105 #define tan_approx(x) tanf(x)
108 #define DEGREES_TO_DECIDEGREES(angle) (angle * 10)
109 #define DECIDEGREES_TO_DEGREES(angle) (angle / 10)
110 #define DECIDEGREES_TO_RADIANS(angle) ((angle / 10.0f) * 0.0174532925f)
111 #define DEGREES_TO_RADIANS(angle) ((angle) * 0.0174532925f)
113 void arraySubInt32(int32_t *dest, int32_t *array1, int32_t *array2,
int count);
float roll
Definition: maths.h:60
float Z
Definition: maths.h:49
void normalizeV(struct fp_vector *src, struct fp_vector *dest)
Definition: maths.c:182
float matrix_3x3_t[3][3]
Definition: maths.h:115
#define cos_approx(x)
Definition: maths.h:102
float scaleRangef(float x, float in_min, float in_max, float out_min, float out_max)
Definition: maths.c:177
int32_t quickMedianFilter5(int32_t *v)
Definition: maths.c:259
void devPush(stdev_t *dev, float x)
Definition: maths.c:140
fp_angles_def angles
Definition: maths.h:67
float m_newM
Definition: maths.h:41
t_fp_vector_def V
Definition: maths.h:54
int32_t quickMedianFilter3(int32_t *v)
Definition: maths.c:250
float m_oldM
Definition: maths.h:41
void matrix_set_identity(matrix_3x3_t mat)
Definition: maths.c:194
int constrain(int amt, int low, int high)
Definition: maths.c:115
float m_newS
Definition: maths.h:41
int scaleRange(int x, int srcMin, int srcMax, int destMin, int destMax)
Definition: maths.c:169
#define sin_approx(x)
Definition: maths.h:101
int m_n
Definition: maths.h:42
void arraySubInt32(int32_t *dest, int32_t *array1, int32_t *array2, int count)
Definition: maths.c:298
float constrainf(float amt, float low, float high)
Definition: maths.c:125
float X
Definition: maths.h:47
float Y
Definition: maths.h:48
float devStandardDeviation(stdev_t *dev)
Definition: maths.c:159
float yaw
Definition: maths.h:62
int32_t quickMedianFilter9(int32_t *v)
Definition: maths.c:283
void devClear(stdev_t *dev)
Definition: maths.c:135
struct fp_vector t_fp_vector_def
struct fp_angles fp_angles_def
float pitch
Definition: maths.h:61
int32_t quickMedianFilter7(int32_t *v)
Definition: maths.c:270
#define atan2_approx(y, x)
Definition: maths.h:103
void buildRotationMatrix(fp_angles_t *delta, float matrix[3][3])
Definition: maths.c:201
float devVariance(stdev_t *dev)
Definition: maths.c:154
void rotateV(struct fp_vector *v, fp_angles_t *delta)
Definition: maths.c:230
float m_oldS
Definition: maths.h:41
int32_t applyDeadband(int32_t value, int32_t deadband)
Definition: maths.c:103
float degreesToRadians(int16_t degrees)
Definition: maths.c:164
int16_t raw[2]
Definition: accelerometer.h:51
#define acos_approx(x)
Definition: maths.h:104