- 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.

This commit is contained in:
Mitchell Richters 2020-11-22 21:46:17 +11:00 committed by Christoph Oelckers
parent 42689e02c4
commit 35845a63e2

View file

@ -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); }