MostlyHarmless 0.0.1
 
Loading...
Searching...
No Matches
marvin_Reciprocal.h
Go to the documentation of this file.
1// ========================================================================================================
2// _______ _______ ______ ___ ___ _______ _______
3// | | | _ | __ \ | |_ _| | |
4// | | | < | |_| |_| |
5// |__|_|__|___|___|___|__|\_____/|_______|__|____|
6//
7// This file is part of the Marvin open source library and is licensed under the terms of the MIT License.
8//
9// ========================================================================================================
10
11#ifndef RITE_OF_SPRING_MARVIN_RECIPROCAL_H
12#define RITE_OF_SPRING_MARVIN_RECIPROCAL_H
14namespace marvin::math {
18 template <FloatType T>
23 T min;
24
29
33 T max;
34 };
35
36 template <FloatType T>
38 return {
39 .min = other.min + constant,
40 .centre = other.centre + constant,
41 .max = other.max + constant
42 };
43 }
44
45 template <FloatType T>
47 return {
48 .min = other.min - constant,
49 .centre = other.centre - constant,
50 .max = other.max - constant
51 };
52 }
53
54 template <FloatType T>
56 return {
57 .min = other.min * constant,
58 .centre = other.centre * constant,
59 .max = other.max * constant
60 };
61 }
62
63 template <FloatType T>
65 return {
66 .min = other.min / constant,
67 .centre = other.centre / constant,
68 .max = other.max / constant
69 };
70 }
71
72
78 template <FloatType T>
79 class Reciprocal final {
80 public:
96 T operator()(T toMap) noexcept;
97
98 private:
99 T m_a, m_b, m_c, m_d;
100 };
101} // namespace marvin::math
102
103#endif // RITE_OF_SPRING_MARVIN_RECIPROCAL_H
Reciprocal(ReciprocalRange< T > dest)
Reciprocal(ReciprocalRange< T > src, ReciprocalRange< T > dest)
T operator()(T toMap) noexcept
Math helper functions and classes.
Definition marvin_Math.h:22
ReciprocalRange< T > operator/(const ReciprocalRange< T > &other, T constant)
Definition marvin_Reciprocal.h:64
ReciprocalRange< T > operator*(const ReciprocalRange< T > &other, T constant)
Definition marvin_Reciprocal.h:55
ReciprocalRange< T > operator-(const ReciprocalRange< T > &other, T constant)
Definition marvin_Reciprocal.h:46
ReciprocalRange< T > operator+(const ReciprocalRange< T > &other, T constant)
Definition marvin_Reciprocal.h:37
Convenience POD struct for representing a range used by marvin::math::ReciprocalRange.
Definition marvin_Reciprocal.h:19
T min
Definition marvin_Reciprocal.h:23
T centre
Definition marvin_Reciprocal.h:28
T max
Definition marvin_Reciprocal.h:33