Enigma
3.2.0
A Simple, Reliable and Efficient Encryption Tool
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
8
NS_ENIGMA_BEGIN
9
10
class
MathUtils
final {
11
ENIGMA_STATIC_CLASS(
MathUtils
);
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
29
NS_ENIGMA_END
30
31
#endif
// !ENIGMA_MATH_UTILS_H
Core.hpp
KeyCode::T
@ T
NS_ENIGMA_BEGIN
#define NS_ENIGMA_BEGIN
Enable/Disable Assertions.
Definition:
Macros.hpp:13
NS_ENIGMA_END
#define NS_ENIGMA_END
Definition:
Macros.hpp:14
MathUtils
Definition:
MathUtils.hpp:10
MathUtils::Map
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
src
Utility
MathUtils.hpp
Generated on Sat Oct 19 2024 20:10:46 for Enigma by
1.9.1