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
Generic.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_MATH_GENERIC_HPP_
9#define GALAXY_MATH_GENERIC_HPP_
10
11#include <algorithm>
12#include <vector>
13
15
16namespace galaxy
17{
18 namespace math
19 {
30 template<meta::is_arithmetic Type>
31 [[nodiscard]]
32 inline float normalize(const Type val, const Type max) noexcept
33 {
34 return (static_cast<float>(val) / static_cast<float>(max));
35 }
36
47 template<typename Type>
48 [[nodiscard]]
49 inline bool contains(const std::vector<Type>& cont, const Type& val) noexcept
50 {
51 auto out = false;
52 std::for_each(cont.begin(), cont.end(), [&](const Type& var) {
53 if (val == var)
54 {
55 out = true;
56 }
57 });
58
59 return out;
60 }
61 } // namespace math
62} // namespace galaxy
63
64#endif
bool contains(const std::vector< Type > &cont, const Type &val) noexcept
See if a vector contains a value.
Definition Generic.hpp:49
float normalize(const Type val, const Type max) noexcept
Calc normalized value from range.
Definition Generic.hpp:32
Timer.hpp galaxy.
Definition Async.hpp:17