dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
misc_math.h File Reference
#include <math.h>
#include "stdint.h"
#include "stdbool.h"

Go to the source code of this file.

Macros

#define MAX(a, b)   ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
 
#define MIN(a, b)   ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
 
#define sign(x)   ((x) < 0 ? -1 : 1)
 This is but one definition of sign(.) More...
 
#define s_qN   13
 
#define s_qP   15
 
#define s_qA   12
 
#define TOL_EPS   0.0001f
 
#define PSEUDOINV_CONVERGE_LIMIT   75
 
#define matrix_mul_check(a, b, out, arows, acolsbrows, bcols)
 
#define matrix_mul_scalar_check(a, scalar, out, rows, cols)
 
#define matrix_add_check(a, b, out, rows, cols)
 
#define matrix_sub_check(a, b, out, rows, cols)
 
#define matrix_transpose_check(a, b, out, rows, cols)
 
#define cast_uint32_t   (uint32_t)
 
#define powapprox   powf
 
#define expapprox   expf
 

Functions

float bound_sym (float val, float range)
 Bound input value within range (plus or minus) More...
 
float bound_min_max (float val, float min, float max)
 Bound input value between min and max. More...
 
float circular_modulus_deg (float err)
 Circular modulus. More...
 
float circular_modulus_rad (float err)
 
float expo3 (float x, int32_t g)
 Approximation an exponential scale curve. More...
 
float expoM (float x, int32_t g, float exponent)
 
float interpolate_value (const float fraction, const float beginVal, const float endVal)
 
float vectorn_magnitude (const float *v, int n)
 
float vector3_distances (const float *actual, const float *desired, float *out, bool normalize)
 
void vector2_clip (float *vels, float limit)
 
void vector2_rotate (const float *original, float *out, float angle)
 
float cubic_deadband (float in, float w, float b, float m, float r)
 
void cubic_deadband_setup (float w, float b, float *m, float *r)
 
float linear_interpolate (float const input, float const *curve, uint8_t num_points, const float input_min, const float input_max)
 
void randomize_addseed (uint32_t seed)
 
uint32_t randomize_int (uint32_t interval)
 
void apply_channel_deadband (float *value, float deadband)
 Apply deadband to Roll/Pitch/Yaw channels. More...
 
static bool IS_NOT_FINITE (float x)
 
static int16_t sin_approx (int32_t x)
 Fast approximation of sine; 3rd order taylor expansion. Based on http://www.coranac.com/2009/07/sines/. More...
 
static void matrix_mul (const float *a, const float *b, float *out, int arows, int acolsbrows, int bcols)
 Multiplies out = a b. More...
 
static void matrix_mul_scalar (const float *a, float scalar, float *out, int rows, int cols)
 Multiplies a matrix by a scalar Can safely be done in-place. (e.g. is slow and not vectorized/unrolled) More...
 
static void matrix_add (const float *a, const float *b, float *out, int rows, int cols)
 Adds two matrices Can safely be done in-place. (e.g. is slow and not vectorized/unrolled) More...
 
static void matrix_sub (const float *a, const float *b, float *out, int rows, int cols)
 Subtracts two matrices Can safely be done in-place. (e.g. is slow and not vectorized/unrolled) More...
 
static void matrix_transpose (const float *a, float *out, int arows, int acols)
 Transposes a matrix. More...
 
static bool matrix_pseudoinv_convergecheck (const float *a, const float *b, const float *prod, int rows, int cols)
 
static bool matrix_pseudoinv_step (const float *a, float *ainv, int arows, int acols)
 
static float matrix_getmaxabs (const float *a, int arows, int acols)
 Finds the largest value in a matrix. More...
 
static bool matrix_pseudoinv (const float *a, float *out, int arows, int acols)
 Finds a pseudo-inverse of a matrix. More...
 
static float fastlog2 (float x)
 
static float fastpow2 (float p)
 
static float fastpow (float x, float p)
 
static float fastexp (float p)
 

Macro Definition Documentation

#define s_qA   12
#define s_qN   13
#define s_qP   15