2
3
4
5
6
7
9#ifndef GIMBAL_NUMERIC_H
10#define GIMBAL_NUMERIC_H
12#include "../core/gimbal_decls.h"
13#include "../preprocessor/gimbal_macro_utils.h"
18# define M_PI (3.14159265358979323846264338327950288
)
22# define M_E (2.71828182845904523536
)
30
31
32
33
59GBL_EXPORT
void gblCartesianToPolarf (
float x,
float y,
float* pRad,
float* pAng) GBL_NOEXCEPT;
60GBL_EXPORT
void gblPolarToCartesianf (
float rad,
float ang,
float* pX,
float* pY) GBL_NOEXCEPT;
61GBL_EXPORT
float gblLerpf (
float v1,
float v2,
float frac) GBL_NOEXCEPT;
63GBL_EXPORT
float gblDynamicWeightedMovingAverage(
float current,
float prev,
float maxDist,
float minWeight,
float maxWeight) GBL_NOEXCEPT;
64GBL_EXPORT
float gblRangePctf(
float min,
float max,
float value) GBL_NOEXCEPT;
65GBL_EXPORT GblBool gblPow2Checkz(size_t value) GBL_NOEXCEPT;
66GBL_EXPORT GblBool gblWithinCheckf(
float value,
float min,
float max) GBL_NOEXCEPT;
67GBL_EXPORT GblBool gblWithinInclusiveCheckf(
float value,
float min,
float max) GBL_NOEXCEPT;
78#define gblAlignedAllocSize(...)
79 gblAlignedAllocSizeDefault_
(__VA_ARGS__)
80#define gblAlignedAllocSizeDefault_(...)
81 gblAlignedAllocSizeDefault__
(__VA_ARGS__, 0
)
82#define gblAlignedAllocSizeDefault__(size, align, ...)
83 (gblAlignedAllocSize
)(size, align)
85#define GBL_POW2_NEXT_TRAITS_ (
88 (uint8_t, gblPow2Next_u8),
89 (uint16_t, gblPow2Next_u16),
90 (uint32_t, gblPow2Next_u32),
91 (uint64_t, gblPow2Next_u64)
95#define gblFloatEquals(...)
96 gblFloatEqualsDefault_
(__VA_ARGS__, DBL_EPSILON
)
97#define gblFloatEqualsDefault_(a, b, e, ...)
98 (gblFloatEquals
)(a, b, e)
#define GBL_META_GENERIC_MACRO_GENERATE(traits, X)
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)
GblBool gblFloatEquals(double a, double b, double e)