This commit is contained in:
Pascal Serrarens 2024-03-05 10:17:29 +01:00
parent 0468031b4b
commit 273ebae33b
3 changed files with 19 additions and 3 deletions

View File

@ -5,13 +5,20 @@
// A fixed angle between (-180..180]
template <typename T> class AngleUsing : RangeUsing<T> {
template <typename T> class AngleUsing {
public:
AngleUsing(T sourceValue);
float ToFloat();
inline T GetValue() { return this->value; }
inline AngleUsing<T> operator-(AngleUsing<T> a) {
return this->value - a.value;
}
protected:
T value;
};
#endif
template <typename T> inline float AngleUsing<T>::ToFloat() { return 0.0f; }
// template <typename T> inline float AngleUsing<T>::ToFloat() { return 0.0f; }

View File

@ -38,4 +38,11 @@ bool Range16::operator<(Range16 a) { return (this->range < a.range); }
bool Range16::operator>(Range16 a) { return (this->range > a.range); }
bool Range16::operator<=(Range16 a) { return (this->range <= a.range); }
bool Range16::operator>=(Range16 a) { return (this->range >= a.range); }
*/
*/
template <> RangeUsing<unsigned char>::RangeUsing(float f) {
this->value = (unsigned char)((f + 1.0f) * 127.0F);
}
template <> RangeUsing<unsigned short>::RangeUsing(float f) {
this->value = (unsigned short)((f + 1.0F) * 32767.0F);
}

View File

@ -30,6 +30,8 @@ protected:
template <typename T> class RangeUsing {
public:
RangeUsing<T>(float range); // range -1..1
inline RangeUsing<T> operator-(RangeUsing<T> a) { this->value - a.value; }
inline RangeUsing<T> operator+(RangeUsing<T> a) { this->value + a.value; }
inline RangeUsing<T> operator-() { this->value = -this.value; }