![]() |
TGX 1.0.5
A tiny 2D/3D graphics library optimized for 32 bits microcontrollers.
|
Utility/miscellaneous functions used throughout the library. More...
Go to the source code of this file.
Macros | |
#define | M_PI 3.14159265358979323846 |
define Pi in case math.h is not yet included. | |
Functions | |
TGX_INLINE uint16_t | tgx::BigEndian16 (uint16_t v) |
little endian / big endian conversion | |
template<typename T > | |
TGX_INLINE void | tgx::swap (T &a, T &b) |
Baby let me swap you one more time... | |
template<typename T > | |
TGX_INLINE T | tgx::min (const T &a, const T &b) |
Don't know why but faster than fminf() for floats. | |
template<typename T > | |
TGX_INLINE T | tgx::max (const T &a, const T &b) |
Don't know why but much faster than fmaxf() for floats. | |
template<typename T > | |
TGX_INLINE T | tgx::clamp (const T &v, const T &vmin, const T &vmax) |
Template clamp version. | |
TGX_INLINE float | tgx::roundfp (const float f) |
Rounding for floats. | |
TGX_INLINE double | tgx::roundfp (const double f) |
Rounding for doubles. | |
TGX_INLINE uint32_t | tgx::float_as_uint32 (float f) |
Reinterpret the bits of a float as a uint32_t. | |
TGX_INLINE float | tgx::uint32_as_float (uint32_t u) |
Reinterpret the bits of a uint32_t as a float. | |
TGX_INLINE int32_t | tgx::safeMultB (int32_t A, int32_t B) |
Return a value smaller or equal to B such that the multiplication by A is safe (no overflow with int32). | |
TGX_INLINE float | tgx::fast_inv (float x) |
Fast (approximate) computation of 1/x. More... | |
TGX_INLINE double | tgx::fast_inv (double x) |
Fast (approximate) computation of 1/x. More... | |
TGX_INLINE float | tgx::precise_sqrt (float x) |
Compute the square root of a float (exact computation). | |
TGX_INLINE double | tgx::precise_sqrt (double x) |
Compute the square root of a double (exact computation). | |
TGX_INLINE float | tgx::fast_sqrt (float x) |
Compute a fast approximation of the square root of a float. More... | |
TGX_INLINE double | tgx::fast_sqrt (double x) |
Compute a fast approximation of the square root of a double. | |
TGX_INLINE float | tgx::precise_invsqrt (float x) |
Compute the inverse square root of a float (exact computation). More... | |
TGX_INLINE double | tgx::precise_invsqrt (double x) |
Compute the inverse square root of a double (exact computation). | |
TGX_INLINE float | tgx::fast_invsqrt (float x) |
Compute a fast approximation of the inverse square root of a float. More... | |
TGX_INLINE double | tgx::fast_invsqrt (double x) |
Compute a fast approximation of the inverse square root of a float. | |
TGX_INLINE int32_t | tgx::lfloorf (float x) |
Compute (int32_t)floorf(x). More... | |
Utility/miscellaneous functions used throughout the library.
|
inline |
Fast (approximate) computation of 1/x.
Version for float.
Credit Ken Cooke (@joestash)
|
inline |
Fast (approximate) computation of 1/x.
Version for double.
|
inline |
Compute a fast approximation of the square root of a float.
Credit Ken Cooke (@joestash)
|
inline |
Compute the inverse square root of a float (exact computation).
Credit Ken Cooke (@joestash)
|
inline |
Compute a fast approximation of the inverse square root of a float.
Credit Ken Cooke (@joestash)
|
inline |
Compute (int32_t)floorf(x).
Credit Ken Cooke (@joestash)