15#ifndef MOMENTUM_MATH_H
16#define MOMENTUM_MATH_H
18#include "momentum_namespace.h"
19#include "momentum_export.h"
32 const double Infinity = std::numeric_limits<double>::infinity();
37 const double PI = double(M_PI);
38 const double PI_2 = double(M_PI_2);
39 const double PI_4 = double(M_PI_4);
49 return (lhs + epsilon >= rhs) && (lhs - epsilon <= rhs);
59 return _equivalent< double >(lhs, rhs, epsilon);
72 return _equivalent(lhs, rhs, (std::abs(lhs) + std::abs(rhs) + T(1)) * relativeEpsilon);
83 return _relativelyEquivalent< double >(lhs, rhs, epsilon);
87 inline bool equalsZero(
double d,
double eps=DBL_EPSILON )
89 return ( d < eps && d > -eps );
94 template<
typename T1,
typename T2>
95 inline T1
const lerp(T1
const& a, T1
const& b, T2 s)
102 return (T1)(a*(1-s) + b*s);
109 return std::pow(T(10), agx::lerp(std::log10(a), std::log10(b), s));
Namespace for Momentum Scripting API.
Definition: AffineMatrix4x4.h:29
bool relativelyEquivalent(double lhs, double rhs, double epsilon=(double) MOMENTUM_EQUIVALENT_EPSILON)
Compare two values for relative equality.
Definition: momentum_math.h:81
const double MOMENTUM_EQUIVALENT_EPSILON
Definition: momentum_math.h:30
const double PI_4
Definition: momentum_math.h:39
const double GRAVITY_ACCELERATION
Definition: momentum_math.h:28
const double PI_2
Definition: momentum_math.h:38
T1 const lerp(T1 const &a, T1 const &b, T2 s)
Linearly interpolate from a to b using s = {0,..1}.
Definition: momentum_math.h:95
bool _relativelyEquivalent(T lhs, T rhs, T relativeEpsilon=T(MOMENTUM_EQUIVALENT_EPSILON))
Compare two values for relative equality.
Definition: momentum_math.h:70
T const logInterpolate(T const &a, T const &b, float s)
logarithmic interpolation from a to b using s = {0,..1}
Definition: momentum_math.h:107
bool _equivalent(T lhs, T rhs, T epsilon=T(MOMENTUM_EQUIVALENT_EPSILON))
Compare two values for equality.
Definition: momentum_math.h:47
bool equalsZero(double d, double eps=DBL_EPSILON)
Definition: momentum_math.h:87
const double Infinity
Definition: momentum_math.h:32
const double REAL_SQRT_EPSILON
Definition: momentum_math.h:34
const double PI
Definition: momentum_math.h:37
bool equivalent(const Matrix3x3 &a, const Matrix3x3 &b, double epsilon=1e-6)
Definition: Matrix3x3.h:905