mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-12 03:02:30 +00:00
chore: initial commit
This commit is contained in:
commit
70b00c5c38
965 changed files with 264882 additions and 0 deletions
10
src/math/CMakeLists.txt
Normal file
10
src/math/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
file(GLOB PRIVATE_SOURCES "*.cpp")
|
||||
|
||||
add_library(math STATIC
|
||||
${PRIVATE_SOURCES}
|
||||
)
|
||||
|
||||
target_include_directories(math
|
||||
PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
)
|
||||
7
src/math/Types.cpp
Normal file
7
src/math/Types.cpp
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include "math/Types.hpp"
|
||||
#include "math/Utils.hpp"
|
||||
#include <cmath>
|
||||
|
||||
fixed16::operator float() const {
|
||||
return this->n / 32767.0f;
|
||||
}
|
||||
12
src/math/Types.hpp
Normal file
12
src/math/Types.hpp
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef MATH_TYPES_HPP
|
||||
#define MATH_TYPES_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
struct fixed16 {
|
||||
int16_t n;
|
||||
|
||||
explicit operator float() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
22
src/math/Utils.hpp
Normal file
22
src/math/Utils.hpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef MATH_UTILS_HPP
|
||||
#define MATH_UTILS_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
|
||||
#define WHOA_EPSILON_1 0.00000023841858
|
||||
#define WHOA_EPSILON_2 0.0000099999997
|
||||
|
||||
inline bool AreEqual(float a, float b, double epsilon) {
|
||||
return std::abs(a - b) < epsilon;
|
||||
}
|
||||
|
||||
inline bool NotEqual(float a, float b, double epsilon) {
|
||||
return std::abs(a - b) >= epsilon;
|
||||
}
|
||||
|
||||
inline float SignOf(float value) {
|
||||
return value >= 0.0 ? 1.0f : -1.0f;
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue