diff options
author | bunnei <bunneidev@gmail.com> | 2018-11-21 08:05:39 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-21 08:05:39 -0800 |
commit | 8cdb48224d0c637a7a88def4e17b1ed88efbbe3e (patch) | |
tree | 61e5e8ba7b581b3744a78ea81fea81894f810662 /src/common/math_util.h | |
parent | 81e14c072a961591e699347c63ec16a290c4c4e2 (diff) | |
parent | 45211a7a9183f8f62cb3e90b6e718cf33e46bec6 (diff) |
Merge pull request #1758 from lioncash/rect
common/math_util: Minor cleanup
Diffstat (limited to 'src/common/math_util.h')
-rw-r--r-- | src/common/math_util.h | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/common/math_util.h b/src/common/math_util.h index 343cdd902..94b4394c5 100644 --- a/src/common/math_util.h +++ b/src/common/math_util.h @@ -4,18 +4,12 @@ #pragma once -#include <algorithm> #include <cstdlib> #include <type_traits> namespace MathUtil { -static constexpr float PI = 3.14159265f; - -inline bool IntervalsIntersect(unsigned start0, unsigned length0, unsigned start1, - unsigned length1) { - return (std::max(start0, start1) < std::min(start0 + length0, start1 + length1)); -} +constexpr float PI = 3.14159265f; template <class T> struct Rectangle { @@ -24,16 +18,16 @@ struct Rectangle { T right{}; T bottom{}; - Rectangle() = default; + constexpr Rectangle() = default; - Rectangle(T left, T top, T right, T bottom) + constexpr Rectangle(T left, T top, T right, T bottom) : left(left), top(top), right(right), bottom(bottom) {} T GetWidth() const { - return std::abs(static_cast<typename std::make_signed<T>::type>(right - left)); + return std::abs(static_cast<std::make_signed_t<T>>(right - left)); } T GetHeight() const { - return std::abs(static_cast<typename std::make_signed<T>::type>(bottom - top)); + return std::abs(static_cast<std::make_signed_t<T>>(bottom - top)); } Rectangle<T> TranslateX(const T x) const { return Rectangle{left + x, top, right + x, bottom}; |