diff options
Diffstat (limited to 'src/common/math_util.h')
| -rw-r--r-- | src/common/math_util.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/common/math_util.h b/src/common/math_util.h index 83ef0201f..b35ad8507 100644 --- a/src/common/math_util.h +++ b/src/common/math_util.h | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | 9 | ||
| 10 | namespace Common { | 10 | namespace Common { |
| 11 | 11 | ||
| 12 | constexpr float PI = 3.14159265f; | 12 | constexpr float PI = 3.1415926535f; |
| 13 | 13 | ||
| 14 | template <class T> | 14 | template <class T> |
| 15 | struct Rectangle { | 15 | struct Rectangle { |
| @@ -23,7 +23,7 @@ struct Rectangle { | |||
| 23 | constexpr Rectangle(T left, T top, T right, T bottom) | 23 | constexpr Rectangle(T left, T top, T right, T bottom) |
| 24 | : left(left), top(top), right(right), bottom(bottom) {} | 24 | : left(left), top(top), right(right), bottom(bottom) {} |
| 25 | 25 | ||
| 26 | T GetWidth() const { | 26 | [[nodiscard]] T GetWidth() const { |
| 27 | if constexpr (std::is_floating_point_v<T>) { | 27 | if constexpr (std::is_floating_point_v<T>) { |
| 28 | return std::abs(right - left); | 28 | return std::abs(right - left); |
| 29 | } else { | 29 | } else { |
| @@ -31,7 +31,7 @@ struct Rectangle { | |||
| 31 | } | 31 | } |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | T GetHeight() const { | 34 | [[nodiscard]] T GetHeight() const { |
| 35 | if constexpr (std::is_floating_point_v<T>) { | 35 | if constexpr (std::is_floating_point_v<T>) { |
| 36 | return std::abs(bottom - top); | 36 | return std::abs(bottom - top); |
| 37 | } else { | 37 | } else { |
| @@ -39,21 +39,21 @@ struct Rectangle { | |||
| 39 | } | 39 | } |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | Rectangle<T> TranslateX(const T x) const { | 42 | [[nodiscard]] Rectangle<T> TranslateX(const T x) const { |
| 43 | return Rectangle{left + x, top, right + x, bottom}; | 43 | return Rectangle{left + x, top, right + x, bottom}; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | Rectangle<T> TranslateY(const T y) const { | 46 | [[nodiscard]] Rectangle<T> TranslateY(const T y) const { |
| 47 | return Rectangle{left, top + y, right, bottom + y}; | 47 | return Rectangle{left, top + y, right, bottom + y}; |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | Rectangle<T> Scale(const float s) const { | 50 | [[nodiscard]] Rectangle<T> Scale(const float s) const { |
| 51 | return Rectangle{left, top, static_cast<T>(left + GetWidth() * s), | 51 | return Rectangle{left, top, static_cast<T>(left + GetWidth() * s), |
| 52 | static_cast<T>(top + GetHeight() * s)}; | 52 | static_cast<T>(top + GetHeight() * s)}; |
| 53 | } | 53 | } |
| 54 | }; | 54 | }; |
| 55 | 55 | ||
| 56 | template <typename T> | 56 | template <typename T> |
| 57 | Rectangle(T, T, T, T)->Rectangle<T>; | 57 | Rectangle(T, T, T, T) -> Rectangle<T>; |
| 58 | 58 | ||
| 59 | } // namespace Common | 59 | } // namespace Common |