galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
Math.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_MATH_MATH_HPP_
9#define GALAXY_MATH_MATH_HPP_
10
12
13namespace galaxy
14{
15 namespace math
16 {
27 template<meta::is_arithmetic Arithmetic>
28 [[nodiscard]]
29 inline float constexpr normalize(const Arithmetic val, const Arithmetic max) noexcept
30 {
31 if (val != 0 && val != max)
32 {
33 return static_cast<float>(val) / static_cast<float>(max);
34 }
35 else if (val == max)
36 {
37 return 1.0f;
38 }
39 else
40 {
41 return 0.0f;
42 }
43 }
44 } // namespace math
45} // namespace galaxy
46
47#endif
float constexpr normalize(const Arithmetic val, const Arithmetic max) noexcept
Calc normalized value from range.
Definition Math.hpp:29
Animated.cpp galaxy.
Definition Animated.cpp:16