9 #include <nap/numeric.h>
11 #include <utility/dllexport.h>
19 inline constexpr
double E = 2.71828182845904523536;
20 inline constexpr
double LOG2E = 1.44269504088896340736;
21 inline constexpr
double LOG10E = 0.434294481903251827651;
22 inline constexpr
double LN2 = 0.693147180559945309417;
23 inline constexpr
double LN10 = 2.30258509299404568402;
24 inline constexpr
double PI = 3.14159265358979323846;
25 inline constexpr
double PIX2 = 6.28318530717958647692;
26 inline constexpr
double PI_2 = 1.57079632679489661923;
27 inline constexpr
double PI_4 = 0.785398163397448309616;
28 inline constexpr
double M1_PI = 0.318309886183790671538;
29 inline constexpr
double M2_PI = 0.636619772367581343076;
30 inline constexpr
double M2_SQRTPI = 1.12837916709551257390;
31 inline constexpr
double SQRT2 = 1.41421356237309504880;
32 inline constexpr
double SQRT1_2 = 0.707106781186547524401;
34 inline constexpr glm::vec3
X_AXIS = { 1.0f, 0.0f, 0.0f };
35 inline constexpr glm::vec3
Y_AXIS = { 0.0f, 1.0f, 0.0f };
36 inline constexpr glm::vec3
Z_AXIS = { 0.0f, 0.0f, 1.0f };
37 inline constexpr glm::vec3
FORWARD = { 0.0f, 0.0f, -1.0f };
51 T
fit(T value, T
min, T
max, T outMin, T outMax);
61 T
lerp(
const T& start,
const T& end,
float percent);
81 T
min(T left, T right);
90 T
max(T left, T right);
116 T
power(T value, T exp);
166 T
bell(T time, T strength);
199 T NAPAPI
smoothDamp(T currentValue, T targetValue, T& currentVelocity,
float deltaTime,
float smoothTime,
float maxSpeed = math::max<float>());
214 void NAPAPI
smooth(T& currentValue,
const T& targetValue, T& currentVelocity,
float deltaTime,
float smoothTime,
float maxSpeed);
223 glm::mat4 NAPAPI
composeMatrix(
const glm::vec3& translate,
const glm::quat& rotate,
const glm::vec3& scale);
231 glm::quat NAPAPI
eulerToQuat(
const glm::vec3& eulerAngle);
241 glm::quat NAPAPI
eulerToQuat(
float roll,
float pitch,
float yaw);
248 glm::vec3 NAPAPI
radians(
const glm::vec3& eulerDegrees);
258 glm::vec3 NAPAPI
radians(
float roll,
float pitch,
float yaw);
288 glm::vec3 NAPAPI
objectToWorld(
const glm::vec3& point,
const glm::mat4x4& objectToWorldMatrix);
297 glm::vec3 NAPAPI
worldToObject(
const glm::vec3& point,
const glm::mat4x4& objectToWorldMatrix);
311 T v = glm::clamp<T>(value,
min,
max);
313 m = (m == 0.0f) ? std::numeric_limits<T>::epsilon() : m;
314 return (v -
min) / (m) * (outMax - outMin) + outMin;
320 return glm::clamp<T>(value,
min,
max);
326 return std::min<T>(left, right);
332 return std::max<T>(left, right);
338 return glm::floor(value);
344 return glm::ceil(value);
350 return std::numeric_limits<T>::epsilon();
356 return std::numeric_limits<T>::max();
362 return std::numeric_limits<T>::lowest();
368 return static_cast<T
>(value == 0 ? 0 : value > 0 ? 1 : -1);
374 return power<T>(4.0f, strength) * power<T>(t *(1.0f - t), strength);
380 T x = math::clamp<T>((value - edge0) / (edge1 - edge0), 0, 1);
381 return x * x * (3 - 2 * x);
390 NAPAPI
float lerp<float>(
const float& start,
const float& end,
float percent);
393 NAPAPI
double lerp<double>(
const double& start,
const double& end,
float percent);
396 NAPAPI glm::vec2 lerp<glm::vec2>(
const glm::vec2& start,
const glm::vec2& end,
float percent);
399 NAPAPI glm::vec3 lerp<glm::vec3>(
const glm::vec3& start,
const glm::vec3& end,
float percent);
402 NAPAPI glm::vec4 lerp<glm::vec4>(
const glm::vec4& start,
const glm::vec4& end,
float percent);
414 NAPAPI
void smooth(
float& currentValue,
const float& targetValue,
float& currentVelocity,
float deltaTime,
float smoothTime,
float maxSpeed);
417 NAPAPI
void smooth(
double& currentValue,
const double& targetValue,
double& currentVelocity,
float deltaTime,
float smoothTime,
float maxSpeed);
420 NAPAPI
void smooth(glm::vec2& currentValue,
const glm::vec2& targetValue, glm::vec2& currentVelocity,
float deltaTime,
float smoothTime,
float maxSpeed);
423 NAPAPI
void smooth(glm::vec3& currentValue,
const glm::vec3& targetValue, glm::vec3& currentVelocity,
float deltaTime,
float smoothTime,
float maxSpeed);
426 NAPAPI
void smooth(glm::vec4& currentValue,
const glm::vec4& targetValue, glm::vec4& currentVelocity,
float deltaTime,
float smoothTime,
float maxSpeed);
447 NAPAPI glm::ivec2
random(glm::ivec2
min, glm::ivec2
max);
450 NAPAPI glm::ivec3
random(glm::ivec3
min, glm::ivec3
max);
453 NAPAPI glm::ivec4
random(glm::ivec4
min, glm::ivec4
max);
459 NAPAPI
float abs(
float value);
462 NAPAPI
int abs(
int value);
void NAPAPI smooth(T ¤tValue, const T &targetValue, T ¤tVelocity, float deltaTime, float smoothTime, float maxSpeed)
unsigned int uint
Definition: numeric.h:23
glm::vec3 NAPAPI worldToObject(const glm::vec3 &point, const glm::mat4x4 &objectToWorldMatrix)
constexpr double LOG2E
Definition: mathutils.h:20
constexpr double M1_PI
Definition: mathutils.h:28
T fit(T value, T min, T max, T outMin, T outMax)
Definition: mathutils.h:309
NAPAPI float lerp< float >(const float &start, const float &end, float percent)
T sign(T value)
Definition: mathutils.h:366
constexpr double LN10
Definition: mathutils.h:23
NAPAPI double lerp< double >(const double &start, const double &end, float percent)
std::string NAPAPI generateUUID()
constexpr double SQRT1_2
Definition: mathutils.h:32
T NAPAPI smoothDamp(T currentValue, T targetValue, T ¤tVelocity, float deltaTime, float smoothTime, float maxSpeed=math::max< float >())
constexpr glm::vec3 FORWARD
Definition: mathutils.h:37
glm::mat4 NAPAPI composeMatrix(const glm::vec3 &translate, const glm::quat &rotate, const glm::vec3 &scale)
NAPAPI double power< double >(double value, double exp)
T max(T left, T right)
Definition: mathutils.h:330
glm::quat NAPAPI eulerToQuat(const glm::vec3 &eulerAngle)
T bell(T time, T strength)
Definition: mathutils.h:372
T min(T left, T right)
Definition: mathutils.h:324
constexpr T epsilon()
Definition: mathutils.h:348
T ceil(T value)
Definition: mathutils.h:342
constexpr glm::vec3 Y_AXIS
Definition: mathutils.h:35
T smoothStep(T value, T edge0, T edge1)
Definition: mathutils.h:378
T floor(T value)
Definition: mathutils.h:336
constexpr double PIX2
Definition: mathutils.h:25
glm::vec3 NAPAPI objectToWorld(const glm::vec3 &point, const glm::mat4x4 &objectToWorldMatrix)
NAPAPI float power< float >(float value, float exp)
float NAPAPI degrees(float radians)
constexpr double LOG10E
Definition: mathutils.h:21
constexpr double PI_2
Definition: mathutils.h:26
constexpr double E
Definition: mathutils.h:19
constexpr double PI
Definition: mathutils.h:24
constexpr double M2_SQRTPI
Definition: mathutils.h:30
constexpr double PI_4
Definition: mathutils.h:27
constexpr glm::vec3 X_AXIS
Definition: mathutils.h:34
glm::vec3 NAPAPI extractPosition(const glm::mat4x4 &matrix)
constexpr double LN2
Definition: mathutils.h:22
T lerp(const T &start, const T &end, float percent)
Definition: templateapp.h:17
glm::vec3 NAPAPI radians(const glm::vec3 &eulerDegrees)
constexpr double SQRT2
Definition: mathutils.h:31
constexpr double M2_PI
Definition: mathutils.h:29
constexpr glm::vec3 Z_AXIS
Definition: mathutils.h:36
T clamp(T value, T min, T max)
Definition: mathutils.h:318
NAPAPI int power< int >(int value, int exp)
void NAPAPI setRandomSeed(int value)