From 35845a63e2418e948138e7118d65f472472095e4 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 22 Nov 2020 21:46:17 +1100 Subject: [PATCH] - binaryangle.h: Expand all classes with bit-shift operators and `binangle`/`lookangle` classes with some lt/le/ge/gt bools to have parity with the `fixedhoriz` class. --- source/core/binaryangle.h | 104 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/source/core/binaryangle.h b/source/core/binaryangle.h index cca2d6636..9011d8f01 100644 --- a/source/core/binaryangle.h +++ b/source/core/binaryangle.h @@ -141,6 +141,25 @@ public: int bsin(const int8_t& shift = 0) const { return ::bsin(asbuild(), shift); } int bcos(const int8_t& shift = 0) const { return ::bcos(asbuild(), shift); } + bool operator< (binangle other) const + { + return value < other.value; + } + + bool operator> (binangle other) const + { + return value > other.value; + } + + bool operator<= (binangle other) const + { + return value <= other.value; + } + + bool operator>= (binangle other) const + { + return value >= other.value; + } constexpr bool operator== (binangle other) const { return value == other.value; @@ -173,6 +192,28 @@ public: return binangle(value - other.value); } + constexpr binangle &operator<<= (const uint8_t& shift) + { + value <<= shift; + return *this; + } + + constexpr binangle &operator>>= (const uint8_t& shift) + { + value >>= shift; + return *this; + } + + constexpr binangle operator<< (const uint8_t& shift) const + { + return binangle(value << shift); + } + + constexpr binangle operator>> (const uint8_t& shift) const + { + return binangle(value >> shift); + } + }; inline constexpr binangle bamang(uint32_t v) { return binangle(v); } @@ -223,6 +264,25 @@ public: int bsin(const int8_t& shift = 0) const { return ::bsin(asbuild(), shift); } int bcos(const int8_t& shift = 0) const { return ::bcos(asbuild(), shift); } + bool operator< (lookangle other) const + { + return value < other.value; + } + + bool operator> (lookangle other) const + { + return value > other.value; + } + + bool operator<= (lookangle other) const + { + return value <= other.value; + } + + bool operator>= (lookangle other) const + { + return value >= other.value; + } constexpr bool operator== (lookangle other) const { return value == other.value; @@ -255,6 +315,28 @@ public: return lookangle(value - other.value); } + constexpr lookangle &operator<<= (const uint8_t& shift) + { + value <<= shift; + return *this; + } + + constexpr lookangle &operator>>= (const uint8_t& shift) + { + value >>= shift; + return *this; + } + + constexpr lookangle operator<< (const uint8_t& shift) const + { + return lookangle(value << shift); + } + + constexpr lookangle operator>> (const uint8_t& shift) const + { + return lookangle(value >> shift); + } + }; inline constexpr lookangle bamlook(int32_t v) { return lookangle(v); } @@ -377,6 +459,28 @@ public: return fixedhoriz(value - other.value); } + constexpr fixedhoriz &operator<<= (const uint8_t& shift) + { + value <<= shift; + return *this; + } + + constexpr fixedhoriz &operator>>= (const uint8_t& shift) + { + value >>= shift; + return *this; + } + + constexpr fixedhoriz operator<< (const uint8_t& shift) const + { + return fixedhoriz(value << shift); + } + + constexpr fixedhoriz operator>> (const uint8_t& shift) const + { + return fixedhoriz(value >> shift); + } + }; inline constexpr fixedhoriz q16horiz(fixed_t v) { return fixedhoriz(v); }