Saga3D API Documentation  1.0-RC4
irrMath.h File Reference
#include "SagaConfig.h"
#include <cmath>
#include <cfloat>
#include <cstdlib>
#include <climits>
#include <cstdint>
#include <glm/vec3.hpp>
#include <glm/gtx/norm.hpp>

Go to the source code of this file.

Classes

union  saga::core::FloatIntUnion32
 
union  saga::core::inttofloat
 

Namespaces

 saga
 
 saga::core
 typedef for Function Pointer
 

Macros

#define F32_AS_S32(f)   (*((std::int32_t *) &(f)))
 
#define F32_AS_U32(f)   (*((std::uint32_t *) &(f)))
 
#define F32_AS_U32_POINTER(f)   (((std::uint32_t *) &(f)))
 
#define F32_VALUE_0   0x00000000
 
#define F32_VALUE_1   0x3f800000
 
#define F32_SIGN_BIT   0x80000000U
 
#define F32_EXPON_MANTISSA   0x7FFFFFFFU
 
#define AIR(x)   (IR(x)&0x7fffffff)
 Absolute integer representation of a floating-point value. More...
 
#define IEEE_1_0   0x3f800000
 integer representation of 1.0 More...
 
#define IEEE_255_0   0x437f0000
 integer representation of 255.0 More...
 
#define F32_LOWER_0(n)   ((n) < 0.0f)
 
#define F32_LOWER_EQUAL_0(n)   ((n) <= 0.0f)
 
#define F32_GREATER_0(n)   ((n) > 0.0f)
 
#define F32_GREATER_EQUAL_0(n)   ((n) >= 0.0f)
 
#define F32_EQUAL_1(n)   ((n) == 1.0f)
 
#define F32_EQUAL_0(n)   ((n) == 0.0f)
 
#define F32_A_GREATER_B(a, b)   ((a) > (b))
 
#define REALINLINE   inline
 

Functions

bool saga::core::isBetweenPoints (const glm::vec3 &point, const glm::vec3 &begin, const glm::vec3 &end)
 
glm::vec3 saga::core::getHorizontalAngle (const glm::vec3 &vec)
 
glm::vec3 saga::core::rotationToDirection (const glm::vec3 &vec, const glm::vec3 &forwards={0, 0, 1})
 
float saga::core::radToDeg (float radians)
 Utility function to convert a radian value to degrees. More...
 
double saga::core::radToDeg (double radians)
 Utility function to convert a radian value to degrees. More...
 
float saga::core::degToRad (float degrees)
 Utility function to convert a degrees value to radians. More...
 
double saga::core::degToRad (double degrees)
 Utility function to convert a degrees value to radians. More...
 
template<class T >
const T & saga::core::min_ (const T &a, const T &b)
 returns minimum of two values. Own implementation to get rid of the STL (VS6 problems) More...
 
template<class T >
const T & saga::core::min_ (const T &a, const T &b, const T &c)
 returns minimum of three values. Own implementation to get rid of the STL (VS6 problems) More...
 
template<class T >
const T & saga::core::max_ (const T &a, const T &b)
 returns maximum of two values. Own implementation to get rid of the STL (VS6 problems) More...
 
template<class T >
const T & saga::core::max_ (const T &a, const T &b, const T &c)
 returns maximum of three values. Own implementation to get rid of the STL (VS6 problems) More...
 
template<class T >
saga::core::abs_ (const T &a)
 returns abs of two values. Own implementation to get rid of STL (VS6 problems) More...
 
template<class T >
saga::core::lerp (const T &a, const T &b, const float t)
 
template<class T >
const T saga::core::clamp (const T &value, const T &low, const T &high)
 clamps a value between low and high More...
 
template<class T1 , class T2 >
void saga::core::swap (T1 &a, T2 &b)
 swaps the content of the passed parameters More...
 
template<class T >
saga::core::roundingError ()
 
template<>
float saga::core::roundingError ()
 
template<class T >
saga::core::relativeErrorFactor ()
 
template<>
float saga::core::relativeErrorFactor ()
 
template<class T >
bool saga::core::equals (const T a, const T b, const T tolerance=roundingError< T >())
 returns if a equals b, taking possible rounding errors into account More...
 
template<class T >
bool saga::core::equalsRelative (const T a, const T b, const T factor=relativeErrorFactor< T >())
 
bool saga::core::equalsByUlp (float a, float b, int maxUlpDiff)
 We compare the difference in ULP's (spacing between floating-point numbers, aka ULP=1 means there exists no float between). More...
 
bool saga::core::iszero (const double a, const double tolerance=ROUNDING_ERROR_double)
 returns if a equals zero, taking rounding errors into account More...
 
bool saga::core::iszero (const float a, const float tolerance=ROUNDING_ERROR_float)
 returns if a equals zero, taking rounding errors into account More...
 
bool saga::core::isnotzero (const float a, const float tolerance=ROUNDING_ERROR_float)
 returns if a equals not zero, taking rounding errors into account More...
 
bool saga::core::iszero (const std::int32_t a, const std::int32_t tolerance=0)
 returns if a equals zero, taking rounding errors into account More...
 
bool saga::core::iszero (const std::uint32_t a, const std::uint32_t tolerance=0)
 returns if a equals zero, taking rounding errors into account More...
 
std::int32_t saga::core::s32_min (std::int32_t a, std::int32_t b)
 
std::int32_t saga::core::s32_max (std::int32_t a, std::int32_t b)
 
std::int32_t saga::core::s32_clamp (std::int32_t value, std::int32_t low, std::int32_t high)
 
std::uint32_t saga::core::IR (float x)
 
float saga::core::FR (std::uint32_t x)
 Floating-point representation of an integer value. More...
 
float saga::core::FR (std::int32_t x)
 
REALINLINE std::uint32_t saga::core::if_c_a_else_b (const std::int32_t condition, const std::uint32_t a, const std::uint32_t b)
 conditional set based on mask and arithmetic shift More...
 
REALINLINE std::uint16_t saga::core::if_c_a_else_b (const std::int16_t condition, const std::uint16_t a, const std::uint16_t b)
 conditional set based on mask and arithmetic shift More...
 
REALINLINE std::uint32_t saga::core::if_c_a_else_0 (const std::int32_t condition, const std::uint32_t a)
 conditional set based on mask and arithmetic shift More...
 
REALINLINE void saga::core::setbit_cond (std::uint32_t &state, std::int32_t condition, std::uint32_t mask)
 
float saga::core::round_ (float x)
 
REALINLINE void saga::core::clearFPUException ()
 
REALINLINE float saga::core::squareroot (const float f)
 
REALINLINE double saga::core::squareroot (const double f)
 
REALINLINE std::int32_t saga::core::squareroot (const std::int32_t f)
 
REALINLINE double saga::core::reciprocal_squareroot (const double x)
 
REALINLINE float saga::core::reciprocal_squareroot (const float f)
 
REALINLINE std::int32_t saga::core::reciprocal_squareroot (const std::int32_t x)
 
REALINLINE float saga::core::reciprocal (const float f)
 
REALINLINE double saga::core::reciprocal (const double f)
 
REALINLINE float saga::core::reciprocal_approxim (const float f)
 
REALINLINE std::int32_t saga::core::floor32 (float x)
 
REALINLINE std::int32_t saga::core::ceil32 (float x)
 
REALINLINE std::int32_t saga::core::round32 (float x)
 
float saga::core::float_max3 (const float a, const float b, const float c)
 
float saga::core::float_min3 (const float a, const float b, const float c)
 
float saga::core::fract (float x)
 

Variables

const std::int32_t saga::core::ROUNDING_ERROR_S32 = 0
 Rounding error constant often used when comparing float values. More...
 
const float saga::core::ROUNDING_ERROR_float = 0.000001f
 
const double saga::core::ROUNDING_ERROR_double = 0.00000001
 
const float saga::core::PI = 3.14159265359f
 Constant for PI. More...
 
const float saga::core::RECIPROCAL_PI = 1.0f/PI
 Constant for reciprocal of PI. More...
 
const float saga::core::HALF_PI = PI/2.0f
 Constant for half of PI. More...
 
const double saga::core::PI64 = 3.1415926535897932384626433832795028841971693993751
 Constant for 64bit PI. More...
 
const double saga::core::RECIPROCAL_PI64 = 1.0/PI64
 Constant for 64bit reciprocal of PI. More...
 
const float saga::core::DEGTORAD = PI / 180.0f
 32bit Constant for converting from degrees to radians More...
 
const float saga::core::RADTODEG = 180.0f / PI
 32bit constant for converting from radians to degrees (formally known as GRAD_PI) More...
 
const double saga::core::DEGTORAD64 = PI64 / 180.0
 64bit constant for converting from degrees to radians (formally known as GRAD_PI2) More...
 
const double saga::core::RADTODEG64 = 180.0 / PI64
 64bit constant for converting from radians to degrees More...
 

Macro Definition Documentation

◆ AIR

#define AIR (   x)    (IR(x)&0x7fffffff)

Absolute integer representation of a floating-point value.

Definition at line 433 of file irrMath.h.

◆ F32_A_GREATER_B

#define F32_A_GREATER_B (   a,
 
)    ((a) > (b))

Definition at line 467 of file irrMath.h.

◆ F32_AS_S32

#define F32_AS_S32 (   f)    (*((std::int32_t *) &(f)))

Definition at line 415 of file irrMath.h.

◆ F32_AS_U32

#define F32_AS_U32 (   f)    (*((std::uint32_t *) &(f)))

Definition at line 416 of file irrMath.h.

◆ F32_AS_U32_POINTER

#define F32_AS_U32_POINTER (   f)    (((std::uint32_t *) &(f)))

Definition at line 417 of file irrMath.h.

◆ F32_EQUAL_0

#define F32_EQUAL_0 (   n)    ((n) == 0.0f)

Definition at line 466 of file irrMath.h.

◆ F32_EQUAL_1

#define F32_EQUAL_1 (   n)    ((n) == 1.0f)

Definition at line 465 of file irrMath.h.

◆ F32_EXPON_MANTISSA

#define F32_EXPON_MANTISSA   0x7FFFFFFFU

Definition at line 422 of file irrMath.h.

◆ F32_GREATER_0

#define F32_GREATER_0 (   n)    ((n) > 0.0f)

Definition at line 463 of file irrMath.h.

◆ F32_GREATER_EQUAL_0

#define F32_GREATER_EQUAL_0 (   n)    ((n) >= 0.0f)

Definition at line 464 of file irrMath.h.

◆ F32_LOWER_0

#define F32_LOWER_0 (   n)    ((n) < 0.0f)

Definition at line 461 of file irrMath.h.

◆ F32_LOWER_EQUAL_0

#define F32_LOWER_EQUAL_0 (   n)    ((n) <= 0.0f)

Definition at line 462 of file irrMath.h.

◆ F32_SIGN_BIT

#define F32_SIGN_BIT   0x80000000U

Definition at line 421 of file irrMath.h.

◆ F32_VALUE_0

#define F32_VALUE_0   0x00000000

Definition at line 419 of file irrMath.h.

◆ F32_VALUE_1

#define F32_VALUE_1   0x3f800000

Definition at line 420 of file irrMath.h.

◆ IEEE_1_0

#define IEEE_1_0   0x3f800000

integer representation of 1.0

Definition at line 444 of file irrMath.h.

◆ IEEE_255_0

#define IEEE_255_0   0x437f0000

integer representation of 255.0

Definition at line 446 of file irrMath.h.

◆ REALINLINE

#define REALINLINE   inline

Definition at line 475 of file irrMath.h.