AGX Dynamics 2.40.1.2
Loading...
Searching...
No Matches
Math.h File Reference
#include <agx/config.h>
#include <agx/macros.h>
#include <agx/agxCore_export.h>
#include <agx/debug.h>
#include <agx/Real.h>
#include <agx/Integer.h>
#include <agx/Random.h>
#include <cmath>
#include <math.h>
#include <stdlib.h>
#include <limits>
#include <algorithm>
#include <float.h>

Go to the source code of this file.

Namespaces

namespace  agx
 The agx namespace contains the dynamics/math part of the AGX Dynamics API.
 

Macros

#define AGX_BIT_MASK(bit)   (1 << bit)
 
#define AGX_SET_BIT(val, bit)   (val |= AGX_BIT_MASK(bit))
 
#define AGX_TEST_BIT(val, bit)   (val & AGX_BIT_MASK(bit))
 
#define AGX_UNSET_BIT(val, bit)   (val &= ~AGX_BIT_MASK(bit))
 
#define INT_EQUALS_ZERO(T)
 
#define INT_IS_FINITE(T)
 
#define INT_IS_INF(T)
 
#define INT_IS_NAN(T)
 
#define NUMERIC_MAX(type)   std::numeric_limits<type>::max()
 
#define NUMERIC_MIN(type)   std::numeric_limits<type>::min()
 
#define UINT_ABSOLUTE(T)
 

Functions

template<typename T >
bool agx::_equivalent (T lhs, T rhs, T epsilon=T(AGX_EQUIVALENT_EPSILON))
 Compare two values for equality.
 
template<typename T >
bool agx::_relativelyEquivalent (T lhs, T rhs, T relativeEpsilon=T(AGX_EQUIVALENT_EPSILON))
 Compare two values for relative equality.
 
template<typename T >
agx::absolute (T v)
 return the absolute value.
 
template<typename T1 , typename T2 >
T1 * agx::align_ceil (const T1 *ptr, T2 alignment)
 
template<typename T >
agx::align_ceil (T value, T alignment)
 
template<typename T1 , typename T2 >
T1 * agx::align_ceil2 (const T1 *ptr, T2 alignment)
 
template<typename T >
agx::align_ceil2 (T value, T alignment)
 
template<typename T1 , typename T2 >
T1 * agx::align_floor (const T1 *ptr, T2 alignment)
 
template<typename T >
agx::align_floor (T value, T alignment)
 
template<typename T1 , typename T2 >
T1 * agx::align_floor2 (const T1 *ptr, T2 alignment)
 
template<typename T >
agx::align_floor2 (T value, T alignment)
 
Int32 agx::alignPowerOfTwo (Int32 value)
 
Int64 agx::alignPowerOfTwo (Int64 value)
 
UInt32 agx::alignPowerOfTwo (UInt32 value)
 
UInt64 agx::alignPowerOfTwo (UInt64 value)
 
template<typename T1 , typename T2 , typename T3 >
T1 agx::clamp (T1 v, T2 minimum, T3 maximum)
 
template<typename T >
Real agx::computeVolume (const T &a, const T &b, const T &c, const T &d)
 a, b, c, d sides of the tetrahedron
 
template<typename T >
Real agx::computeVolume (const T &f1, const T &f2, const T &f3, const T &b1, const T &b2, const T &b3)
 compute the volume of a prism.
 
constexpr Real agx::degreesToRadians (Real angle)
 
bool agx::equalsZero (double d, double eps=DBL_EPSILON)
 
bool agx::equalsZero (float f, float eps=FLT_EPSILON)
 
bool agx::equivalent (double lhs, double rhs, double epsilon=(double) AGX_EQUIVALENT_EPSILON)
 Compare two values for equality.
 
bool agx::equivalent (float lhs, float rhs, double epsilon)
 Compare two values for equality.
 
bool agx::equivalent (float lhs, float rhs, float epsilon=(float) AGX_EQUIVALENT_EPSILON)
 Compare two values for equality.
 
bool agx::geq (double a, double b, double eps=(double) AGX_EQUIVALENT_EPSILON)
 
bool agx::geq (float a, float b, float eps=(float) AGX_EQUIVALENT_EPSILON)
 
AGXCORE_EXPORT agx::UniformInt32Generatoragx::getRandGenerator ()
 
template<typename T >
agx::UInt8 agx::highestBitToIndex (T n)
 
template<typename T >
agx::inverse (const T &value)
 
int agx::irandom (int min, int max)
 
template<typename T1 , typename T2 >
bool agx::isAligned (const T1 *ptr, T2 alignment)
 
template<typename T >
bool agx::isAligned (T value, T alignment)
 
template<typename T >
bool agx::isEven (T val)
 
template<typename T >
bool agx::isFinite (T v)
 
template<typename T >
bool agx::isInf (T v)
 
template<typename T >
bool agx::isNaN (T v)
 
template<typename T >
bool agx::isPowerOfTwo (T value)
 
bool agx::leq (double a, double b, double eps=(double) AGX_EQUIVALENT_EPSILON)
 
bool agx::leq (float a, float b, float eps=(float) AGX_EQUIVALENT_EPSILON)
 
template<typename T1 , typename T2 >
T1 const agx::lerp (T1 const &a, T1 const &b, T2 t)
 Linearly interpolate from a to b using t = {0..1}.
 
Int32 agx::log2 (size_t val)
 
template<typename T1 , typename T2 >
T1 const agx::logInterpolate (T1 const &a, T1 const &b, T2 const &t)
 This function calculates a linear interpolation in a logarithmic space between two positive, non zero values a and b using t = {0..1} Both a and b must be > 0.
 
AGXCORE_EXPORT int agx::nextPrime (int n)
 
AGXCORE_EXPORT Real agx::normalizedAngle (Real angle, bool positiveRange=false)
 Normalize an angle.
 
template<typename T1 , typename T2 >
T1 const agx::parametricBlend (T1 const &a, T1 const &b, T2 t)
 Smooth interpolation from a to b using t = {0..1} The value returned will follow a ramp in/out and a parametric mid section.
 
template<typename T >
agx::UInt32 agx::pow2Exponent (T value)
 Finds and returns n given value = 2^n.
 
constexpr Real agx::radiansToDegrees (Real angle)
 
template<typename T >
agx::random (T min, T max)
 
bool agx::relativelyEquivalent (double lhs, double rhs, double epsilon=(double) AGX_EQUIVALENT_EPSILON)
 Compare two values for relative equality.
 
bool agx::relativelyEquivalent (float lhs, float rhs, double epsilon)
 Compare two values for relative equality.
 
bool agx::relativelyEquivalent (float lhs, float rhs, float epsilon=(float) AGX_EQUIVALENT_EPSILON)
 Compare two values for relative equality.
 
template<typename T >
agx::sign (T v)
 
template<typename T >
agx::signedSquare (T v)
 
Real agx::sinc (Real x, Real nearZero=Real(1E-4))
 Sinc function.
 
template<typename T >
agx::square (T v)
 
AGXCORE_EXPORT double agx::strtod (const char *nptr, char **endptr)
 strtod ignoring global locale
 
AGXCORE_EXPORT float agx::strtof (const char *nptr, char **endptr)
 strtod ignoring global locale
 

Variables

static constexpr Real agx::AGX_EQUIVALENT_EPSILON = (double)1E-9
 
static constexpr Real agx::DEG_TO_RAD = agx::Real(0.017453292519943295769236907684886)
 
static constexpr Real agx::GRAVITY_ACCELERATION = Real(9.80665)
 
const Real agx::Infinity = std::numeric_limits<Real>::infinity()
 
static constexpr Real agx::PI = agx::Real(M_PI)
 
static constexpr Real agx::PI_2 = agx::Real(M_PI_2)
 
static constexpr Real agx::PI_4 = agx::Real(M_PI_4)
 
static constexpr Real agx::RAD_TO_DEG = agx::Real(57.295779513082320876798154814105)
 
AGXCORE_EXPORT const Real agx::REAL_SQRT_EPSILON
 

Macro Definition Documentation

◆ AGX_BIT_MASK

#define AGX_BIT_MASK (   bit)    (1 << bit)

Definition at line 58 of file Math.h.

◆ AGX_SET_BIT

#define AGX_SET_BIT (   val,
  bit 
)    (val |= AGX_BIT_MASK(bit))

Definition at line 60 of file Math.h.

◆ AGX_TEST_BIT

#define AGX_TEST_BIT (   val,
  bit 
)    (val & AGX_BIT_MASK(bit))

Definition at line 59 of file Math.h.

◆ AGX_UNSET_BIT

#define AGX_UNSET_BIT (   val,
  bit 
)    (val &= ~AGX_BIT_MASK(bit))

Definition at line 61 of file Math.h.

◆ INT_EQUALS_ZERO

#define INT_EQUALS_ZERO (   T)
Value:
AGX_FORCE_INLINE bool equalsZero( T f ) \
{ \
return ( f == 0 ); \
}
#define AGX_FORCE_INLINE
Definition: macros.h:58
Returns
true if f equals zero

Definition at line 194 of file Math.h.

◆ INT_IS_FINITE

#define INT_IS_FINITE (   T)
Value:
AGX_FORCE_INLINE bool isFinite( T /*v*/ ) \
{ \
return true; \
}

Definition at line 212 of file Math.h.

◆ INT_IS_INF

#define INT_IS_INF (   T)
Value:
AGX_FORCE_INLINE bool isInf( T /*v*/ ) \
{ \
return false; \
}

Definition at line 206 of file Math.h.

◆ INT_IS_NAN

#define INT_IS_NAN (   T)
Value:
AGX_FORCE_INLINE bool isNaN( T /*v*/ ) \
{ \
return false; \
}

Definition at line 200 of file Math.h.

◆ NUMERIC_MAX

#define NUMERIC_MAX (   type)    std::numeric_limits<type>::max()

Definition at line 55 of file Math.h.

◆ NUMERIC_MIN

#define NUMERIC_MIN (   type)    std::numeric_limits<type>::min()

Definition at line 56 of file Math.h.

◆ UINT_ABSOLUTE

#define UINT_ABSOLUTE (   T)
Value:
AGX_FORCE_INLINE T absolute( T v ) \
{ \
return v; \
}

Definition at line 218 of file Math.h.