| TGX 1.0.4 A tiny 2D/3D graphics library optimized for 32 bits microcontrollers.

Loading...
Searching...
No Matches
Macros | Functions
Misc.h File Reference

Utility/miscellaneous functions used throughout the library. More...

`#include <stdint.h>`
`#include <math.h>`
`#include <string.h>`
`#include "Arduino.h"`

Go to the source code of this file.

## Macros
#define | TGX_SINGLE_PRECISION_COMPUTATIONS 1
| Set this to 1 to use float as the default floating point type and set it to 0 to use double precision instead.
#define | TGX_DEFAULT_NO_BLENDING -1.0f
| Default blending operation for drawing primitive: overwrite instead of blending.
#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 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.
TGX_INLINE double | tgx::fast_inv (double x)
| Fast (approximate) computation of 1/x.
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.
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).
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.
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).

## Detailed Description

Utility/miscellaneous functions used throughout the library.

## Function Documentation

## ◆ fast_inv() [1/2]

TGX_INLINE float tgx::fast_inv | ( | float | x | ) |
| inline

Fast (approximate) computation of 1/x.

Version for float.

## ◆ fast_inv() [2/2]

TGX_INLINE double tgx::fast_inv | ( | double | x | ) |
| inline

Fast (approximate) computation of 1/x.

Version for double.