Back to index

nux  3.0.0
Namespaces | Defines | Functions
MathUtility.h File Reference
#include <cstdio>
#include <cstdlib>
#include <cstdarg>
#include <cmath>
#include <cstring>
#include <ctime>
#include "Constants.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  nux
 The Writer singleton is responsible for controlling where the logging message go.

Defines

#define DEGTORAD(d)   (d) * nux::constants::pi / 180.0f
#define RADTODEG(d)   (d) * 180.0f / nux::constants::pi
#define HAK32_SWAP(a, b)   (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b)))

Functions

template<typename T >
nux::Square (const T A)
template<typename T >
nux::Clamp (const T X, const T min_value, const T max_value)
template<typename T >
nux::ClampUp (const T X, const T min_value)
template<typename T >
nux::ClampDown (const T X, const T max_value)
template<typename T >
nux::Align (const T Ptr, int Alignment)
template<typename T >
const T nux::Rol (const T &a, const unsigned int n=1)
template<typename T >
const T nux::Ror (const T &a, const unsigned int n=1)
template<typename T >
const T nux::Abs (const T &a)
 Return the absolute value of a.
template<typename T >
const T & nux::Min (const T &a, const T &b)
 Return the minimum between a and b.
template<typename T >
const T & nux::Min (const T &a, const T &b, const T &c)
 Return the minimum between a, b and c.
template<typename T >
const T & nux::Min (const T &a, const T &b, const T &c, const T &d)
 Return the minimum between a, b, c and d.
template<typename T >
const T & nux::Max (const T &a, const T &b)
 Return the maximum between a and b.
template<typename T >
const T & nux::Max (const T &a, const T &b, const T &c)
 Return the maximum between a, b and c.
template<typename T >
const T & nux::Max (const T &a, const T &b, const T &c, const T &d)
 Return the maximum between a,b,c and d.
template<typename T >
nux::Max3 (const T A, const T B, const T C)
template<typename T >
nux::Min3 (const T A, const T B, const T C)
template<typename T >
nux::Sign (const T &x)
 Return the sign of x.
template<typename T >
nux::Modulo (const T &x, const T &m)
int nux::ModuloInt (const int x, const int m)
template<typename T >
nux::MinMod (const T &a, const T &b)
double nux::Random ()
 Return a random variable between [0,1[ (uniform distribution).
double nux::CRandom ()
 Return a random variable between [-1,1[ (uniform distribution).
double nux::RandomGaussian ()
 Return a random variable using a gaussian distribution and a variance of 1.
unsigned int nux::RandomUInt ()
unsigned int nux::RandomUInt (unsigned int max_random)
size_t nux::DiffPointer (void *Ptr0, void *Ptr1)
template<typename T >
nux::SubstractPointer (void *Ptr, size_t Value)
template<typename T >
nux::AddPointer (void *Ptr, size_t Value)
template<typename T >
nux::RoundUp (T Value, int Alignment)
 Round up to the nearest multiple of Alignment that is greater or equal to Value.
template<typename T >
nux::RoundDown (T Value, int Alignment)
 Round down to the nearest multiple of Alignment that is smaller or equal to Value.
template<typename T >
bool nux::IsAligned (T Value, int Alignment)
 Return true is Value is aligned on Alignment.
unsigned short nux::ReverseByteOrdering (unsigned short value)
 Revert Byte order 0x0011 -> 0x1100.
unsigned int nux::ReverseByteOrdering (unsigned int value)
 Revert Byte order 0x00112233 -> 0x33221100.
unsigned long long nux::ReverseByteOrdering (unsigned long long value)
 Revert Byte order 0x0011223344556677 -> 0x7766554433221100.
bool nux::IsPowerOf2 (unsigned int n)
unsigned int nux::NextPowerOfTwo (unsigned int x)
unsigned int nux::GetLowerPowerOfTwoExponent (unsigned int x)
unsigned int nux::PowerOfTwo (int i)
unsigned int nux::Hak32_ClearLSBBit (unsigned int N)
unsigned int nux::Hak32_CountNumBits (unsigned int N)
unsigned int nux::Hak32_BitParity (unsigned int N)
bool nux::Hak32_CPULittleEndian ()
unsigned int nux::Hak32_Log2 (unsigned int N)
unsigned int nux::Hak32_Log10 (unsigned int N)
unsigned int nux::Hack32_TrailingZeroRight (unsigned int N)

Define Documentation

#define DEGTORAD (   d)    (d) * nux::constants::pi / 180.0f

Definition at line 35 of file MathUtility.h.

#define HAK32_SWAP (   a,
 
)    (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b)))

Definition at line 361 of file MathUtility.h.

#define RADTODEG (   d)    (d) * 180.0f / nux::constants::pi

Definition at line 36 of file MathUtility.h.