feat(math): add CMath

This commit is contained in:
fallenoak 2020-11-26 09:26:35 -06:00
parent 62d5c2d355
commit 9bebffa8a1
No known key found for this signature in database
GPG key ID: 7628F8E61AEA070D
3 changed files with 94 additions and 0 deletions

30
tempest/math/CMath.hpp Normal file
View file

@ -0,0 +1,30 @@
#ifndef TEMPEST_MATH_C_MATH_HPP
#define TEMPEST_MATH_C_MATH_HPP
#include <cmath>
#include <cstdint>
#include <storm/Error.hpp>
class CMath {
public:
// Static variables
static constexpr float PI = 3.1415927f;
static constexpr float TWO_PI = 6.2831855f;
static constexpr float OO_TWO_PI = 1.0f / TWO_PI;
// Static functions
static uint32_t fuint(float n) {
return static_cast<uint32_t>(n);
}
static uint32_t fuint_n(float n) {
return static_cast<uint32_t>(n + 0.5f);
}
static float sqrt(float x) {
STORM_ASSERT(x >= 0.0f);
return ::sqrt(x);
}
};
#endif