2
3
4
5
6
7
8
9
11#ifndef GIMBAL_NUMERIC_H
12#define GIMBAL_NUMERIC_H
14#include "../core/gimbal_decls.h"
15#include "../preprocessor/gimbal_macro_utils.h"
19#define GBL_F_PI 3.1415926f
26
27
28
29
42GBL_EXPORT size_t gblAlignedAllocSize (size_t size,
51GBL_EXPORT double gblAbsoluteError (
double approximate,
53GBL_EXPORT double gblRelativeError (
double approximate,
61GBL_EXPORT
void gblCartesianToPolarf (
float x,
float y,
float* pRad,
float* pAng) GBL_NOEXCEPT;
62GBL_EXPORT
void gblPolarToCartesianf (
float rad,
float ang,
float* pX,
float* pY) GBL_NOEXCEPT;
63GBL_EXPORT
float gblLerpf (
float v1,
float v2,
float frac) GBL_NOEXCEPT;
65GBL_EXPORT
float gblDynamicWeightedMovingAverage(
float current,
float prev,
float maxDist,
float minWeight,
float maxWeight) GBL_NOEXCEPT;
66GBL_EXPORT
float gblRangePctf(
float min,
float max,
float value) GBL_NOEXCEPT;
67GBL_EXPORT GblBool gblPow2Checkz(size_t value) GBL_NOEXCEPT;
68GBL_EXPORT GblBool gblWithinCheckf(
float value,
float min,
float max) GBL_NOEXCEPT;
69GBL_EXPORT GblBool gblWithinInclusiveCheckf(
float value,
float min,
float max) GBL_NOEXCEPT;
80#define gblAlignedAllocSize(...)
81 gblAlignedAllocSizeDefault_
(__VA_ARGS__)
82#define gblAlignedAllocSizeDefault_(...)
83 gblAlignedAllocSizeDefault__
(__VA_ARGS__, 0
)
84#define gblAlignedAllocSizeDefault__(size, align, ...)
85 (gblAlignedAllocSize
)(size, align)
87#define GBL_POW2_NEXT_TRAITS_ (
90 (uint8_t, gblPow2Next_u8),
91 (uint16_t, gblPow2Next_u16),
92 (uint32_t, gblPow2Next_u32),
93 (uint64_t, gblPow2Next_u64)
97#define gblFloatEquals(...)
98 gblFloatEqualsDefault_
(__VA_ARGS__, DBL_EPSILON
)
99#define gblFloatEqualsDefault_(a, b, e, ...)
100 (gblFloatEquals
)(a, b, e)
#define GBL_META_GENERIC_MACRO_GENERATE(traits, X)
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)