NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
maths.c File Reference
#include <stdint.h>
#include <math.h>
#include <string.h>
#include "axis.h"
#include "maths.h"
Include dependency graph for maths.c:

Macros

#define sinPolyCoef3   -1.666665710e-1f
 
#define sinPolyCoef5   8.333017292e-3f
 
#define sinPolyCoef7   -1.980661520e-4f
 
#define sinPolyCoef9   2.600054768e-6f
 
#define atanPolyCoef1   3.14551665884836e-07f
 
#define atanPolyCoef2   0.99997356613987f
 
#define atanPolyCoef3   0.14744007058297684f
 
#define atanPolyCoef4   0.3099814292351353f
 
#define atanPolyCoef5   0.05030176425872175f
 
#define atanPolyCoef6   0.1471039133652469f
 
#define atanPolyCoef7   0.6444640676891548f
 
#define QMF_SORT(a, b)   { if ((a)>(b)) QMF_SWAP((a),(b)); }
 
#define QMF_SWAP(a, b)   { int32_t temp=(a);(a)=(b);(b)=temp; }
 
#define QMF_COPY(p, v, n)   { int32_t i; for (i=0; i<n; i++) p[i]=v[i]; }
 

Functions

float sin_approx (float x)
 
float cos_approx (float x)
 
float atan2_approx (float y, float x)
 
float acos_approx (float x)
 
int32_t applyDeadband (int32_t value, int32_t deadband)
 
int constrain (int amt, int low, int high)
 
float constrainf (float amt, float low, float high)
 
void devClear (stdev_t *dev)
 
void devPush (stdev_t *dev, float x)
 
float devVariance (stdev_t *dev)
 
float devStandardDeviation (stdev_t *dev)
 
float degreesToRadians (int16_t degrees)
 
int scaleRange (int x, int srcMin, int srcMax, int destMin, int destMax)
 
float scaleRangef (float x, float in_min, float in_max, float out_min, float out_max)
 
void normalizeV (struct fp_vector *src, struct fp_vector *dest)
 
void matrix_set_identity (matrix_3x3_t mat)
 
void buildRotationMatrix (fp_angles_t *delta, float matrix[3][3])
 
void rotateV (struct fp_vector *v, fp_angles_t *delta)
 
int32_t quickMedianFilter3 (int32_t *v)
 
int32_t quickMedianFilter5 (int32_t *v)
 
int32_t quickMedianFilter7 (int32_t *v)
 
int32_t quickMedianFilter9 (int32_t *v)
 
void arraySubInt32 (int32_t *dest, int32_t *array1, int32_t *array2, int count)
 

Macro Definition Documentation

#define atanPolyCoef1   3.14551665884836e-07f
#define atanPolyCoef2   0.99997356613987f
#define atanPolyCoef3   0.14744007058297684f
#define atanPolyCoef4   0.3099814292351353f
#define atanPolyCoef5   0.05030176425872175f
#define atanPolyCoef6   0.1471039133652469f
#define atanPolyCoef7   0.6444640676891548f
#define QMF_COPY (   p,
  v,
 
)    { int32_t i; for (i=0; i<n; i++) p[i]=v[i]; }
#define QMF_SORT (   a,
 
)    { if ((a)>(b)) QMF_SWAP((a),(b)); }
#define QMF_SWAP (   a,
 
)    { int32_t temp=(a);(a)=(b);(b)=temp; }
#define sinPolyCoef3   -1.666665710e-1f
#define sinPolyCoef5   8.333017292e-3f
#define sinPolyCoef7   -1.980661520e-4f
#define sinPolyCoef9   2.600054768e-6f

Function Documentation

float acos_approx ( float  x)
int32_t applyDeadband ( int32_t  value,
int32_t  deadband 
)
void arraySubInt32 ( int32_t *  dest,
int32_t *  array1,
int32_t *  array2,
int  count 
)
float atan2_approx ( float  y,
float  x 
)
void buildRotationMatrix ( fp_angles_t delta,
float  matrix[3][3] 
)

Here is the call graph for this function:

int constrain ( int  amt,
int  low,
int  high 
)
float constrainf ( float  amt,
float  low,
float  high 
)
float cos_approx ( float  x)

Here is the call graph for this function:

float degreesToRadians ( int16_t  degrees)
void devClear ( stdev_t dev)
void devPush ( stdev_t dev,
float  x 
)
float devStandardDeviation ( stdev_t dev)

Here is the call graph for this function:

float devVariance ( stdev_t dev)
void matrix_set_identity ( matrix_3x3_t  mat)
void normalizeV ( struct fp_vector src,
struct fp_vector dest 
)
int32_t quickMedianFilter3 ( int32_t *  v)
int32_t quickMedianFilter5 ( int32_t *  v)
int32_t quickMedianFilter7 ( int32_t *  v)
int32_t quickMedianFilter9 ( int32_t *  v)
void rotateV ( struct fp_vector v,
fp_angles_t delta 
)

Here is the call graph for this function:

int scaleRange ( int  x,
int  srcMin,
int  srcMax,
int  destMin,
int  destMax 
)
float scaleRangef ( float  x,
float  in_min,
float  in_max,
float  out_min,
float  out_max 
)
float sin_approx ( float  x)