46#define Q24_8_DECI_MASK ((1 << FRAC_BITS) - 1)
47#define Q24_8_WHOLE_MASK (~Q24_8_DECI_MASK)
49#define Q16_16_FRAC_BITS 16
50#define Q16_16_DECI_MASK ((1 << Q16_16_FRAC_BITS) - 1)
51#define Q16_16_WHOLE_MASK (~Q16_16_DECI_MASK)
53#define Q8_24_FRAC_BITS 24
54#define Q8_24_DECI_MASK ((1 << Q8_24_FRAC_BITS) - 1)
55#define Q8_24_WHOLE_MASK (~Q8_24_DECI_MASK)
82#define FP_MATH_DEFINES
91 #define TO_FX(in) ((in) * (1 << FRAC_BITS))
98 #define FROM_FX(in) ((in) >> FRAC_BITS)
106 #define ADD_FX(a, b) ((a) + (b))
114 #define SUB_FX(a, b) ((a) - (b))
122 #define MUL_FX(a, b) (((a) * (b)) >> FRAC_BITS)
130 #define DIV_FX(a, b) (((a) << FRAC_BITS) / (b))
137 #define FLOOR_FX(a) ((a) & (~((1 << FRAC_BITS) - 1)))
145 #define TO_FX_FRAC(num, denom) DIV_FX(num, denom)
uint32_t uq24_8
unsigned 24 bits integer, 8 bits fraction
Definition fp_math.h:41
#define FRAC_BITS
8 fractional bits for q24_8
Definition fp_math.h:45
#define ADD_FX(a, b)
Add two q24_8 numbers together.
Definition fp_math.h:106
q24_8 y
The Y component of the vector.
Definition fp_math.h:61
uint32_t uq8_24
unsigned 8 bits integer, 24 bits fraction
Definition fp_math.h:43
uint16_t uq8_8
unsigned 8 bits integer, 8 bits fraction
Definition fp_math.h:40
vec_q24_8 fpvDivSc(vec_q24_8 vec, q24_8 scalar)
Divide a vector by a scalar.
Definition fp_math.c:240
vec_q24_8 fpvNorm(vec_q24_8 vec)
Normalize and return a vector.
Definition fp_math.c:155
#define FROM_FX(in)
Convert a q24_8 to an integer.
Definition fp_math.h:98
q24_8 fpvSqMag(vec_q24_8 a)
Compute the squared magnitude of a vector.
Definition fp_math.c:180
vec_q24_8 fpvSub(vec_q24_8 a, vec_q24_8 b)
Subtract two vectors.
Definition fp_math.c:208
#define DIV_FX(a, b)
Divide a q24_8 by another.
Definition fp_math.h:130
q24_8 x
The X component of the vector.
Definition fp_math.h:60
#define MUL_FX(a, b)
Multiply two q24_8.
Definition fp_math.h:122
int32_t q16_16
16 bits integer, 16 bits fraction
Definition fp_math.h:37
#define FLOOR_FX(a)
Find the floor of a q24_8.
Definition fp_math.h:137
void fastNormVec(q24_8 *xp, q24_8 *yp)
Quickly normalize a q24_8 vector, in-place.
Definition fp_math.c:67
vec_q24_8 fpvAdd(vec_q24_8 a, vec_q24_8 b)
Add two vectors.
Definition fp_math.c:192
int16_t q8_8
8 bits integer, 8 bits fraction
Definition fp_math.h:35
#define SUB_FX(a, b)
Subtract a q24_8 from another.
Definition fp_math.h:114
q24_8 fpvDot(vec_q24_8 a, vec_q24_8 b)
Compute the dot product of two vectors.
Definition fp_math.c:169
float fixToFloat(q24_8 fx)
Convert a q24_8 to floating point.
Definition fp_math.c:255
int32_t q24_8
24 bits integer, 8 bits fraction
Definition fp_math.h:36
int32_t q8_24
8 bits integer, 24 bits fraction
Definition fp_math.h:38
vec_q24_8 fpvMulSc(vec_q24_8 vec, q24_8 scalar)
Multiply a vector by a scalar.
Definition fp_math.c:224
#define TO_FX(in)
Convert an integer to a q24_8.
Definition fp_math.h:91
uint32_t uq16_16
unsigned 16 bits integer, 16 bits fraction
Definition fp_math.h:42
A 2D vector with q24_8 numbers.
Definition fp_math.h:59