Enigma 3.2.2
A Simple, Reliable and Efficient Encryption Tool
Loading...
Searching...
No Matches
MathUtils.hpp
Go to the documentation of this file.
1#pragma once
2#ifndef ENIGMA_MATH_UTILS_H
3#define ENIGMA_MATH_UTILS_H
4
5#include <Core/Core.hpp>
6#include <cmath> // std::log, std::floor, std::round...
7
9
10class MathUtils final {
12
13 public:
14 /*
15 * Maps value from a range to another
16 * @param value: the incoming value to be converted
17 * @param start1: lower bound of the value's current range
18 * @param stop1: upper bound of the value's current range
19 * @param start2: lower bound of the value's target range
20 * @param stop2: upper bound of the value's target range
21 */
22 template<typename T>
23 static constexpr const T Map(const T& value, const T& start1, const T& stop1, const T& start2, const T& stop2) noexcept {
24 return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));
25 }
26};
27
28
30
31#endif // !ENIGMA_MATH_UTILS_H
#define NS_ENIGMA_BEGIN
Enable/Disable Assertions.
Definition Macros.hpp:13
#define NS_ENIGMA_END
Definition Macros.hpp:14
#define ENIGMA_STATIC_CLASS(Class)
Makes a class static, which will prevent creating instances from it and only use it as Class::Func()....
Definition Macros.hpp:120
static constexpr const T Map(const T &value, const T &start1, const T &stop1, const T &start2, const T &stop2) noexcept
Definition MathUtils.hpp:23